Skip to content

Commit

Permalink
ci: wire up Meson builds
Browse files Browse the repository at this point in the history
Wire up CI builds for both GitLab and GitHub that use the Meson build
system.

While the setup is mostly trivial, one gotcha is the test output
directory which used to be in "t/", but now it is contained in the build
directory. To unify the logic across Makefile- and Meson-based builds we
explicitly set up the `TEST_OUTPUT_DIRECTORY` variable so that it is the
same for both build systems.

Note that the new Meson-based CI jobs actually take _longer_ to execute
than the Makefile-based ones. This is not due to an inherent slowless of
Meson though, but rather because it sets up a couple of environment
variables:

  - MALLOC_PERTURB causes glibc to initialize allocated memory blocks
    with a specific value. This can be used to detect uninitialized or
    freed heap memory.

  - ASAN_OPTIONS, UBSAN_OPTIONS and MBSAN_OPTIONS are set up such that
    programs will abort on any errors.

The latter does not matter in the context where we don't enable those
sanitizers, but the former does cause a slowdown. And while we could
explicitly disable these I don't see a reason to do so given that they
may help us detect more issues in our CI.

Signed-off-by: Patrick Steinhardt <[email protected]>
  • Loading branch information
pks-t committed Dec 4, 2024
1 parent a543d2c commit d36b21d
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 9 deletions.
7 changes: 7 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -286,6 +286,9 @@ jobs:
- jobname: osx-gcc
cc: gcc-13
pool: macos-13
- jobname: osx-meson
cc: clang
pool: macos-13
- jobname: linux-gcc-default
cc: gcc
pool: ubuntu-latest
Expand All @@ -298,11 +301,15 @@ jobs:
- jobname: linux-asan-ubsan
cc: clang
pool: ubuntu-latest
- jobname: linux-meson
cc: gcc
pool: ubuntu-latest
env:
CC: ${{matrix.vector.cc}}
CC_PACKAGE: ${{matrix.vector.cc_package}}
jobname: ${{matrix.vector.jobname}}
distro: ${{matrix.vector.pool}}
TEST_OUTPUT_DIRECTORY: /tmp/test-output
runs-on: ${{matrix.vector.pool}}
steps:
- uses: actions/checkout@v4
Expand Down
9 changes: 9 additions & 0 deletions .gitlab-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ test:linux:
- saas-linux-medium-amd64
variables:
CUSTOM_PATH: "/custom"
TEST_OUTPUT_DIRECTORY: "/tmp/test-output"
before_script:
- ./ci/install-dependencies.sh
script:
Expand All @@ -31,6 +32,7 @@ test:linux:
if test "$CI_JOB_STATUS" != 'success'
then
sudo --preserve-env --set-home --user=builder ./ci/print-test-failures.sh
mv "$TEST_OUTPUT_DIRECTORY"/failed-test-artifacts t/
fi
parallel:
matrix:
Expand Down Expand Up @@ -67,6 +69,10 @@ test:linux:
image: fedora:latest
- jobname: linux-musl
image: alpine:latest
- jobname: linux-meson
image: ubuntu:latest
CC: gcc
CC_PACKAGE: gcc
artifacts:
paths:
- t/failed-test-artifacts
Expand Down Expand Up @@ -104,6 +110,9 @@ test:osx:
- jobname: osx-reftable
image: macos-14-xcode-15
CC: clang
- jobname: osx-meson
image: macos-14-xcode-15
CC: clang
artifacts:
paths:
- t/failed-test-artifacts
Expand Down
7 changes: 7 additions & 0 deletions ci/install-dependencies.sh
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ ubuntu-*|ubuntu32-*)
make libssl-dev libcurl4-openssl-dev libexpat-dev wget sudo default-jre \
tcl tk gettext zlib1g-dev perl-modules liberror-perl libauthen-sasl-perl \
libemail-valid-perl libio-pty-perl libio-socket-ssl-perl libnet-smtp-ssl-perl libdbd-sqlite3-perl libcgi-pm-perl \
libpcre2-dev meson ninja-build pkg-config \
${CC_PACKAGE:-${CC:-gcc}} $PYTHON_PACKAGE

case "$distro" in
Expand Down Expand Up @@ -89,6 +90,12 @@ macos-*)
sudo xattr -d com.apple.quarantine "$CUSTOM_PATH/p4" "$CUSTOM_PATH/p4d" 2>/dev/null || true
rm helix-core-server.tgz

case "$jobname" in
osx-meson)
brew install meson ninja pcre2
;;
esac

if test -n "$CC_PACKAGE"
then
BREW_PACKAGE=${CC_PACKAGE/-/@}
Expand Down
2 changes: 1 addition & 1 deletion ci/lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ then
CC="${CC_PACKAGE:-${CC:-gcc}}"
DONT_SKIP_TAGS=t
handle_failed_tests () {
echo "FAILED_TEST_ARTIFACTS=t/failed-test-artifacts" >>$GITHUB_ENV
echo "FAILED_TEST_ARTIFACTS=${TEST_OUTPUT_DIRECTORY:-t}/failed-test-artifacts" >>$GITHUB_ENV
create_failed_test_artifacts
return 1
}
Expand Down
2 changes: 1 addition & 1 deletion ci/print-test-failures.sh
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ do
;;
github-actions)
mkdir -p failed-test-artifacts
echo "FAILED_TEST_ARTIFACTS=t/failed-test-artifacts" >>$GITHUB_ENV
echo "FAILED_TEST_ARTIFACTS=${TEST_OUTPUT_DIRECTORY:t}/failed-test-artifacts" >>$GITHUB_ENV
cp "${TEST_EXIT%.exit}.out" failed-test-artifacts/
tar czf failed-test-artifacts/"$test_name".trash.tar.gz "$trash_dir"
continue
Expand Down
33 changes: 26 additions & 7 deletions ci/run-build-and-tests.sh
Original file line number Diff line number Diff line change
Expand Up @@ -48,12 +48,31 @@ pedantic)
;;
esac

group Build make
if test -n "$run_tests"
then
group "Run tests" make test ||
handle_failed_tests
fi
check_unignored_build_artifacts
case "$jobname" in
*-meson)
group "Configure" meson setup build . \
--warnlevel 2 --werror \
--wrap-mode nofallback
group "Build" meson compile -C build --
if test -n "$run_tests"
then
begin_group "Run tests"
meson test -C build --print-errorlogs --test-args="$GIT_TEST_OPTS" || (
./t/aggregate-results.sh "${TEST_OUTPUT_DIRECTORY:-t}/test-results"
handle_failed_tests
)
end_group "Run tests"
fi
;;
*)
group Build make
if test -n "$run_tests"
then
group "Run tests" make test ||
handle_failed_tests
fi
;;
esac

check_unignored_build_artifacts
save_good_tree

0 comments on commit d36b21d

Please sign in to comment.