ci: wire up Meson builds

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 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.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
maint
Patrick Steinhardt 2024-12-13 11:41:23 +01:00 committed by Junio C Hamano
parent 9faf3963b6
commit eab5dbab92
6 changed files with 48 additions and 9 deletions

View File

@ -286,6 +286,9 @@ jobs:
- jobname: osx-gcc - jobname: osx-gcc
cc: gcc-13 cc: gcc-13
pool: macos-13 pool: macos-13
- jobname: osx-meson
cc: clang
pool: macos-13
- jobname: linux-gcc-default - jobname: linux-gcc-default
cc: gcc cc: gcc
pool: ubuntu-latest pool: ubuntu-latest
@ -298,11 +301,15 @@ jobs:
- jobname: linux-asan-ubsan - jobname: linux-asan-ubsan
cc: clang cc: clang
pool: ubuntu-latest pool: ubuntu-latest
- jobname: linux-meson
cc: gcc
pool: ubuntu-latest
env: env:
CC: ${{matrix.vector.cc}} CC: ${{matrix.vector.cc}}
CC_PACKAGE: ${{matrix.vector.cc_package}} CC_PACKAGE: ${{matrix.vector.cc_package}}
jobname: ${{matrix.vector.jobname}} jobname: ${{matrix.vector.jobname}}
distro: ${{matrix.vector.pool}} distro: ${{matrix.vector.pool}}
TEST_OUTPUT_DIRECTORY: ${{github.workspace}}/t
runs-on: ${{matrix.vector.pool}} runs-on: ${{matrix.vector.pool}}
steps: steps:
- uses: actions/checkout@v4 - uses: actions/checkout@v4

View File

@ -20,6 +20,7 @@ test:linux:
- saas-linux-medium-amd64 - saas-linux-medium-amd64
variables: variables:
CUSTOM_PATH: "/custom" CUSTOM_PATH: "/custom"
TEST_OUTPUT_DIRECTORY: "/tmp/test-output"
before_script: before_script:
- ./ci/install-dependencies.sh - ./ci/install-dependencies.sh
script: script:
@ -31,6 +32,7 @@ test:linux:
if test "$CI_JOB_STATUS" != 'success' if test "$CI_JOB_STATUS" != 'success'
then then
sudo --preserve-env --set-home --user=builder ./ci/print-test-failures.sh sudo --preserve-env --set-home --user=builder ./ci/print-test-failures.sh
mv "$TEST_OUTPUT_DIRECTORY"/failed-test-artifacts t/
fi fi
parallel: parallel:
matrix: matrix:
@ -67,6 +69,9 @@ test:linux:
image: fedora:latest image: fedora:latest
- jobname: linux-musl - jobname: linux-musl
image: alpine:latest image: alpine:latest
- jobname: linux-meson
image: ubuntu:latest
CC: gcc
artifacts: artifacts:
paths: paths:
- t/failed-test-artifacts - t/failed-test-artifacts
@ -104,6 +109,9 @@ test:osx:
- jobname: osx-reftable - jobname: osx-reftable
image: macos-13-xcode-14 image: macos-13-xcode-14
CC: clang CC: clang
- jobname: osx-meson
image: macos-14-xcode-15
CC: clang
artifacts: artifacts:
paths: paths:
- t/failed-test-artifacts - t/failed-test-artifacts

View File

@ -58,6 +58,7 @@ ubuntu-*|ubuntu32-*|debian-*)
make libssl-dev libcurl4-openssl-dev libexpat-dev wget sudo default-jre \ make libssl-dev libcurl4-openssl-dev libexpat-dev wget sudo default-jre \
tcl tk gettext zlib1g-dev perl-modules liberror-perl libauthen-sasl-perl \ 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 \ 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 ${CC_PACKAGE:-${CC:-gcc}} $PYTHON_PACKAGE


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


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

if test -n "$CC_PACKAGE" if test -n "$CC_PACKAGE"
then then
BREW_PACKAGE=${CC_PACKAGE/-/@} BREW_PACKAGE=${CC_PACKAGE/-/@}

View File

@ -236,7 +236,7 @@ then
CC="${CC_PACKAGE:-${CC:-gcc}}" CC="${CC_PACKAGE:-${CC:-gcc}}"
DONT_SKIP_TAGS=t DONT_SKIP_TAGS=t
handle_failed_tests () { 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 create_failed_test_artifacts
return 1 return 1
} }

View File

@ -46,7 +46,7 @@ do
;; ;;
github-actions) github-actions)
mkdir -p failed-test-artifacts 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/ cp "${TEST_EXIT%.exit}.out" failed-test-artifacts/
tar czf failed-test-artifacts/"$test_name".trash.tar.gz "$trash_dir" tar czf failed-test-artifacts/"$test_name".trash.tar.gz "$trash_dir"
continue continue

View File

@ -48,12 +48,29 @@ pedantic)
;; ;;
esac esac


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
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
)
fi
;;
*)
group Build make group Build make
if test -n "$run_tests" if test -n "$run_tests"
then then
group "Run tests" make test || group "Run tests" make test ||
handle_failed_tests handle_failed_tests
fi fi
check_unignored_build_artifacts ;;
esac


check_unignored_build_artifacts
save_good_tree save_good_tree