ci: enable tests in meson builds #498
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Meson CI | |
on: | |
push: | |
branches: [ master, ci ] | |
pull_request: | |
branches: [ master ] | |
jobs: | |
build: | |
name: ${{ matrix.config.name }} | |
runs-on: ${{ matrix.config.os }} | |
strategy: | |
fail-fast: false | |
matrix: | |
config: | |
- { | |
name: Windows MSVC Release, | |
os: windows-latest, | |
msvc: true, | |
msystem: MINGW64, | |
shell: 'powershell', | |
buildtype: release, | |
args: '-Ddefault_library=static' | |
} | |
- { | |
name: Windows MinGW Release, | |
os: windows-latest, | |
msvc: false, | |
pkgmanager: msys, | |
msystem: MINGW64, | |
shell: 'msys2 {0}', | |
buildtype: debugoptimized, | |
args: '' | |
} | |
- { | |
name: Ubuntu Debug, | |
os: ubuntu-latest, | |
buildtype: debugoptimized, | |
args: '' | |
} | |
- { | |
name: macOS Debug, | |
os: macos-latest, | |
buildtype: debugoptimized, | |
args: '' | |
} | |
defaults: | |
run: | |
shell: ${{ matrix.config.shell || 'bash' }} | |
env: | |
ART_SAMPLES: ${{ github.workspace }}/ext_art-samples | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: '0' | |
- name: download test samples | |
uses: actions/checkout@v4 | |
with: | |
repository: libass/libass-tests | |
path: ${{ env.ART_SAMPLES }} | |
- name: Setup MSys2 | |
if: startsWith(matrix.config.os, 'windows') | |
uses: msys2/setup-msys2@v2 | |
with: | |
msystem: ${{ matrix.config.msystem }} | |
update: false | |
- name: Setup MSVC | |
if: matrix.config.os == 'windows-latest' && matrix.config.msvc == true | |
uses: ilammy/msvc-dev-cmd@v1 | |
- name: Install MSVC dependecies with choco | |
if: matrix.config.msvc | |
run: | | |
# for whatever reason choco insist on a reboot if it installs meson | |
choco install ninja nasm python pkgconfiglite | |
python -m pip install --upgrade pip | |
pip install meson | |
- name: Install more MSVC dependecies with msys | |
if: matrix.config.msvc | |
shell: 'msys2 {0}' | |
run: | | |
pre="$MINGW_PACKAGE_PREFIX" | |
mkdir pacman-root | |
ln -s /var pacman-root/var | |
pacman -r ./pacman-root --noconfirm -S \ | |
$pre-fribidi $pre-freetype $pre-harfbuzz \ | |
$pre-fontconfig $pre-libpng | |
echo "PKG_CONFIG_PATH=$(cygpath -w "$PWD/pacman-root/mingw64/lib/pkgconfig")" >> "$GITHUB_ENV" | |
cygpath -w "$PWD/pacman-root/mingw64/bin" >> "$GITHUB_PATH" | |
cp "$PWD/pacman-root/mingw64/lib/libharfbuzz.dll.a" "$PWD/pacman-root/mingw64/lib/libharfbuzz.lib" | |
cp "$PWD/pacman-root/mingw64/lib/libfreetype.dll.a" "$PWD/pacman-root/mingw64/lib/libfreetype.lib" | |
cp "$PWD/pacman-root/mingw64/lib/libfribidi.dll.a" "$PWD/pacman-root/mingw64/lib/libfribidi.lib" | |
cp "$PWD/pacman-root/mingw64/lib/libfontconfig.dll.a" "$PWD/pacman-root/mingw64/lib/libfontconfig.lib" | |
cp "$PWD/pacman-root/mingw64/lib/libpng.dll.a" "$PWD/pacman-root/mingw64/lib/libpng.lib" | |
cp "$PWD/pacman-root/mingw64/lib/libpng16.dll.a" "$PWD/pacman-root/mingw64/lib/libpng16.lib" | |
- name: Install dependencies (not MSVC) | |
if: ${{ !matrix.config.msvc }} | |
run: | | |
case "${{ matrix.config.pkgmanager || matrix.config.os }}" in | |
msys) | |
pre="$MINGW_PACKAGE_PREFIX" | |
pacman --noconfirm -S \ | |
$pre-gcc $pre-meson $pre-ninja nasm \ | |
$pre-fribidi $pre-freetype $pre-harfbuzz \ | |
$pre-fontconfig $pre-libpng | |
;; | |
macos-*) | |
brew install nasm ninja pkg-config meson | |
;; | |
ubuntu-*) | |
sudo apt-get update | |
sudo apt-get install ninja-build build-essential pkg-config nasm \ | |
libfreetype-dev libfontconfig-dev libharfbuzz-dev libfribidi-dev \ | |
python3-pip | |
# Drop once 24.04 is available in GHA | |
pip3 install meson | |
;; | |
esac | |
- name: Set up WrapDB | |
if: matrix.config.pkgmanager == 'choco' || matrix.config.os == 'macos-latest' | |
run: | | |
meson wrap update-db | |
- name: Configure | |
run: meson setup build ${{ matrix.config.args }} -Dbuildtype=${{ matrix.config.buildtype }} -Dtest=enabled -Dcompare=enabled -Dprofile=enabled -Dfuzz=enabled '-Dart-samples=${{ env.ART_SAMPLES }}' | |
- name: Build | |
run: meson compile -C build | |
- name: Run tests | |
id: run-tests | |
if: matrix.config.skip_tests != 'yes' | |
env: | |
ART_REG_SKIP: ${{ matrix.config.art_reg_skip }} | |
run: meson test -C build | |
- name: Dump Meson Debug Info | |
if: failure() | |
run: cat build/meson-logs/meson-log.txt | |
- name: Dump Meson Test Debug Info | |
if: ${{ failure() && steps.run-tests.conclusion == 'failure' }} | |
run: cat build/meson-logs/testlog.txt | |
build-muon: | |
runs-on: ubuntu-latest | |
container: | |
image: alpine:edge | |
strategy: | |
fail-fast: false | |
matrix: | |
cc: [gcc] | |
steps: | |
- name: add testing repo | |
run: | | |
echo "http://dl-cdn.alpinelinux.org/alpine/edge/testing" >> /etc/apk/repositories | |
apk update | |
- name: install deps | |
run: | | |
# muon's style lint uses git | |
apk add nasm ${{ matrix.cc }} musl-dev muon samurai \ | |
freetype-dev fribidi-dev harfbuzz-dev \ | |
fontconfig-dev libpng-dev git | |
- name: checkout code | |
uses: actions/checkout@v4 | |
- name: configure | |
run: | | |
muon version | |
muon setup -Dtest=enabled build | |
- name: build | |
run: | | |
samu -C build | |
- name: check binary works | |
run: | | |
build/test/libass_test /tmp/out.png compare/test/sub1.ass 0.5 | |
- name: lint style (informational) | |
run: | | |
# `muon fmt -q` already lets us check _if_ there’d be changes, but | |
# doesn’t show what would change. `git diff` doesn’t want to work | |
# (even with increased fetch-depth) either, possibly due to container env | |
LINT_FILES="$(find . -name "meson.build" | sort)" | |
for f in $LINT_FILES ; do | |
cp "$f" "${f}.org" | |
done | |
if muon fmt -q $LINT_FILES ; then | |
echo "ok" | |
else | |
muon fmt -i $LINT_FILES | |
for f in $LINT_FILES ; do | |
git diff --no-index "${f}.org" "$f" || : | |
done | |
# currently formatting rules are being tweaked; | |
# maybe reformat and fail here after muon 0.3.0 is released | |
exit 0 | |
fi | |
- name: validate meson.build | |
run: | | |
# our test build above doesn't hit all conditional paths | |
# for now ignore warnings, only fail on errors | |
muon analyze | |
build-from-tarball: | |
runs-on: ubuntu-latest | |
container: | |
# currently GHA’s ubuntu-latest still has a too old meson | |
image: debian:stable | |
strategy: | |
fail-fast: false | |
matrix: | |
cc: [gcc] | |
steps: | |
- name: install dependencies | |
run: | | |
apt-get update #&& sudo apt-get upgrade | |
apt-get install -y --no-install-recommends \ | |
autoconf automake make libtool \ | |
libfontconfig1-dev libfreetype6-dev libfribidi-dev \ | |
libharfbuzz-dev nasm ${{ matrix.cc }} \ | |
libpng-dev meson ninja-build | |
- name: checkout code | |
uses: actions/checkout@v4 | |
- name: setup distdir | |
run: | | |
autoreconf -ivf . | |
./configure | |
make distdir | |
ls -ld libass-* | |
- name: meson build in distdir | |
run: | | |
cd libass-*/ | |
meson setup build | |
ninja -C build | |
DESTIDR="$PWD/TEST_INSTALL" ninja -C build install |