-
Notifications
You must be signed in to change notification settings - Fork 4
350 lines (312 loc) · 12.7 KB
/
art.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
name: Automatic Regression Tests
on:
push:
branches: [master, ci]
pull_request:
schedule:
- cron: '22 2 * * *'
workflow_dispatch:
# Even with defaults, jobs not started via dispatch will only have blank inputs
inputs:
libass_repo:
description: 'An instance of a libass git repo'
required: false
default: 'https://github.com/libass/libass.git'
libass_ref:
description: 'Git ref of libass repo to run tests on; defaults to newest commit on default branch'
required: false
default: ''
jobs:
ART:
runs-on: ${{ matrix.host_os || 'ubuntu-latest' }}
# Run on each arch we support ASM on and furthemore
# some additional little and big endian archs
# ASM: amd64, i386, arm64 (x32 is no longer supported in GHA kernels)
# Big: s390x
# Little: riscv64, mips64el
strategy:
fail-fast: false
matrix:
arch: [amd64, s390x, arm64, mips64el]
suite: [bookworm]
chroot-rev: [10]
confopts: [""]
cflags: [""]
include:
# i386 needs some SSE usage enabled to get a bit-identical result (even without ASM).
# This is due to different (higher) precision of 387 floating math (default for <=i686).
# SSE2 was introduced in 2000 by Intel and is present in both 32bit and 64bit
# CPUs from both AMD and Intel since 2003. Our ASM needs at least SSE2 anyway.
- arch: i386
suite: bookworm
# 24.04’s kernel doesn't enable all 32bit compat options leading to segfaults
host_os: 'ubuntu-22.04'
cflags: '-msse -msse2 -mfpmath=sse'
sanity: sane?
chroot-rev: 11
- arch: arm64
host_os: ubuntu-24.04-arm
sanity: sane?
- arch: riscv64
suite: sid
port: no
chroot-rev: 12
# Enable sanitisers for native build
- arch: amd64
sanity: sane?
steps:
- name: Prepare System
run: |
sudo apt-get update
sudo apt-get install -y \
debian-keyring debian-archive-keyring debian-ports-archive-keyring \
debootstrap qemu-user-static zstd \
git ca-certificates
sudo mkdir -p /var/chroot/imgs
sudo chmod -R 777 /var/chroot
luser="$(whoami)"
sudo chown $luser:$luser /var/chroot/imgs
- name: Determine Configuration
id: config
run: |
# Map debian arch/abi name to qemu arch name
case "${{ matrix.arch }}" in
amd64) qarch="x86_64" ;;
arm64) qarch="aarch64" ;;
armel|armhf) qarch="arm" ;; # Untested
arm) qarch="armeb" ;; # Untested
ppc64el) qarch="ppc64le" ;;
*) qarch="${{ matrix.arch }}" ;;
esac
# Make sure we have an qemu layer available
if [ x"$qarch" != xi386 ] && [ x"$qarch" != xx86_64 ] \
&& [ ! -x "/usr/bin/qemu-${qarch}-static" ]
then
echo "Arch '${{ matrix.arch }}/${qarch}' not supported!"
exit 1
fi
# Set prefixes as needed
outer_prefix=""
inner_prefix=""
case "${{ matrix.arch }}" in
amd64|arm64)
: ;;
i386)
outer_prefix="linux32"
;;
*)
inner_prefix="/usr/bin/qemu-${qarch}-static"
;;
esac
# Host user and group id
echo "uid=$(id -u)" >> $GITHUB_OUTPUT
echo "gid=$(id -g)" >> $GITHUB_OUTPUT
# Regenerate chroots regularly
# Often a few GHA jobs suffered connection timeouts on regeneration,
# but work just fine on manual rerun. Offset regeneration time
# for some chroots in hopes to avoid this.
# Note: date +%j can have leading zeros causing $(()) to interpret it as octal.
# To avoid this, initially use bc to stick to decimal and remove leading zeros.
if [ "x${{ matrix.port }}" = xyes ] ; then
tmp="$( echo "$(date +%j) + 1" | bc )"
else
tmp="$(echo "$(date +%j)" | bc )"
fi
cache_period="$(printf "%d-%02d" "$(date +%Y)" "$(( tmp / 44 ))")"
echo "cache_period=${cache_period}" >> $GITHUB_OUTPUT
echo "QEMU_ARCH=${qarch}" >> $GITHUB_ENV
echo "OPRE=${outer_prefix}" >> $GITHUB_ENV
echo "IPRE=${inner_prefix}" >> $GITHUB_ENV
echo "CHR_DIR=debian-${{ matrix.suite }}-${{ matrix.arch }}" >> $GITHUB_ENV
# Each repo is allowed up to 10GB total cache
# use it to store our (compressed) chroot dirs
# (cache is branch scoped)
- name: Retrieve Cached Chroots
uses: actions/cache@v4
id: cache
with:
path: /var/chroot/imgs
key: ${{ matrix.suite }}-${{ matrix.arch }}-${{ matrix.chroot-rev }}_${{ steps.config.outputs.cache_period }}
- name: Load and Update Cached Chroot
if: steps.cache.outputs.cache-hit == 'true'
run: |
sudo tar --zstd -xf /var/chroot/imgs/"$CHR_DIR".tar.zstd
if [ ! -z "${IPRE}" ] ; then
echo "Update qemu-binary '${IPRE}' ..."
sudo cp "${IPRE}" "${CHR_DIR}${IPRE}"
fi
sudo $OPRE chroot "$CHR_DIR" $IPRE /bin/dash -c '
export DEBIAN_FRONTEND=noninteractive
export LC_ALL=C.UTF-8
apt-get update && apt-get -y upgrade --with-new-pkgs
cp -a /home/artci/workarea-skel /home/artci/workarea
'
- name: (Re)Create Chroot
if: steps.cache.outputs.cache-hit != 'true'
run: |
echo "Creating '$CHR_DIR' !"
sudo mkdir "$CHR_DIR"
if [ x"${{ matrix.port }}" = xyes ] ; then
crepo="http://ftp.ports.debian.org/debian-ports/"
else
crepo="http://deb.debian.org/debian"
fi
# For simplicity, pretend every arch is foreign
sudo debootstrap --foreign --arch=${{ matrix.arch }} \
--variant=minbase \
--include=debian-ports-archive-keyring \
--no-check-gpg \
${{ matrix.suite }} "$CHR_DIR" "$crepo"
if [ ! -z "${IPRE}" ] ; then
echo "Copy qemu-binary '${IPRE}' into chroot."
sudo cp "${IPRE}" "${CHR_DIR}${IPRE}"
fi
# Set additional packages for some archs
case "${{ matrix.arch }}" in
amd64|i386) add_pkgs="nasm" ;;
*) add_pkgs="" ;;
esac
# ime we don't need to mount everything for those setup steps
sudo $OPRE chroot "$CHR_DIR" $IPRE /bin/dash /debootstrap/debootstrap --second-stage
sudo $OPRE chroot "$CHR_DIR" $IPRE /bin/dash -c '
export DEBIAN_FRONTEND=noninteractive
export LC_ALL=C.UTF-8
add_pkgs="'"$add_pkgs"'"
set -e
# in case something funny happened during initial creation
apt-get --fix-broken install -y
# grab newest sanitiser versions available in chroot
if [ -n "${{ matrix.sanity }}" ] ; then
ubver="$(apt-cache search libubsan | awk '\''/^libubsan[0-9]* / {print substr($1, 9)}'\'' | sort -rn | head -n1)"
asver="$(apt-cache search libasan | awk '\''/^libasan[0-9]* / {print substr($1, 8)}'\'' | sort -rn | head -n1)"
add_pkgs="$add_pkgs libasan${asver} libubsan${ubver}"
fi
apt-get install -y --no-install-recommends --no-install-suggests \
autoconf automake make libtool pkgconf \
gcc \
libfreetype-dev libfribidi-dev libfontconfig-dev libharfbuzz-dev libpng-dev \
$add_pkgs
groupadd -g ${{ steps.config.outputs.gid }} artci
useradd -m -d /home/artci -s /bin/dash -g artci -u ${{ steps.config.outputs.uid }} artci
runuser -u artci mkdir /home/artci/workarea-skel
'
- name: Save Chroot Base to Cache
if: steps.cache.outputs.cache-hit != 'true'
run: |
# Compress and store chroot in cache dir
luser="$(whoami)"
sudo tar --zstd -cf /var/chroot/imgs/"$CHR_DIR".tar.zstd "$CHR_DIR"
sudo chown $luser:$luser /var/chroot/imgs/"$CHR_DIR".tar.zstd
# Initialise workarea for further use
sudo cp -a "$CHR_DIR/home/artci/workarea-skel" "$CHR_DIR/home/artci/workarea"
- name: Checkout Git Repos
env:
LIBASS_REPO: ${{ github.event.inputs.libass_repo }}
LIBASS_REF: ${{ github.event.inputs.libass_ref }}
TESTS_REPO: ${{ github.repository }}
TESTS_REF: ${{ github.ref }}
run: |
if [ -z "$LIBASS_REPO" ] ; then
export LIBASS_REPO="https://github.com/libass/libass.git"
fi
sudo env \
CHR_DIR="$CHR_DIR" \
LIBASS_REPO="$LIBASS_REPO" \
LIBASS_REF="$LIBASS_REF" \
TESTS_REPO="$TESTS_REPO" \
TESTS_REF="$TESTS_REF" \
sh -c '
set -e
cd "$CHR_DIR"/home/artci/workarea
# libass
echo "Cloning Libass Repo: $LIBASS_REPO"
git clone --depth=1 "$LIBASS_REPO" libass
cd libass
if [ -n "$LIBASS_REF" ] ; then
echo "Checking out non-default commit..."
git fetch --depth=1 origin "$LIBASS_REF":artci_laref
git checkout --force artci_laref
fi
echo "Testing libass commit:"
git log -1 --format=%H
cd ..
echo ""
# regression tests
git clone --depth=1 https://github.com/"$TESTS_REPO".git libass-tests
cd libass-tests
if [ -n "$TESTS_REF" ] ; then
git fetch --depth=1 origin "$TESTS_REF":artci_laref
git checkout --force artci_laref
else
echo "Could not determine ref! Fallback to current master."
fi
echo "Using testsuite from commit:"
git log -1 --format=%H
cd ..
echo ""
# Fix ownership
sudo chown -R ${{ steps.config.outputs.uid }}:${{ steps.config.outputs.gid }} *
'
- name: Prepare Chroot Jobs
run: |
cd "$CHR_DIR"/home/artci/workarea
# Make sure we can write to job scripts
sudo touch env.sh build-libass.sh test-libass.sh
sudo chmod 777 env.sh build-libass.sh test-libass.sh
echo '#!/bin/sh
set -e
export DEBIAN_FRONTEND=noninteractive
export LC_ALL=C.UTF-8
export SANITY="'"${{ matrix.sanity }}"'"
export LIBASS_CONF="'"${{ matrix.confopts }}"'"
export LIBASS_CFLAGS="'"${{ matrix.cflags }}"'"
printf "Toolchain: %s\\n" "$(gcc -dumpmachine)"
printf "Kernel-Arch: %s\\n" "$(uname -m)"
printf "Debian Ver.: %s\\n" "$(cat /etc/debian_version)"
printf "Sanity-Check: %s\\n" "$SANITY"
echo ""
' > env.sh
# Build libass
echo '#!/bin/sh
. ./env.sh
cd libass
./autogen.sh
if [ -z "$SANITY" ] ; then
CC=""
else
CC="gcc -fsanitize=address -fsanitize=undefined -fsanitize=float-cast-overflow -fno-sanitize-recover=all"
fi
CC="$CC" CFLAGS="$CFLAGS $LIBASS_CFLAGS" ./configure "$LIBASS_CONF" --enable-fuzz --enable-compare
make -j "$(nproc)"
' > build-libass.sh
# Test libass
echo '#!/bin/sh
. ./env.sh
cd libass
make ART_SAMPLES="../libass-tests" check
' > test-libass.sh
- name: Mount Chroot
run: |
sudo sh -c "
mount --rbind /sys/ $CHR_DIR/sys ;
mount --rbind /proc/ $CHR_DIR/proc ;
mount --rbind /dev/ $CHR_DIR/dev ;
"
- name: Chroot - Build Libass
run: |
sudo $OPRE chroot "$CHR_DIR" $IPRE /bin/dash -c '
su -c '\''/bin/sh -c "cd ~/workarea; dash ./build-libass.sh"'\'' --login artci
'
- name: Chroot - Regression Tests
run: |
sudo $OPRE chroot "$CHR_DIR" $IPRE /bin/dash -c '
su -c '\''/bin/sh -c "cd ~/workarea; dash ./test-libass.sh"'\'' --login artci
'
- name: Umount Chroot
run: |
sudo sh -c '
for m in sys proc dev ; do
mount --make-rslave '"$CHR_DIR"'/$m
umount -R '"$CHR_DIR"'/$m
done
'