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