tools/ci-build.sh: Add a ci_cmake_junit_output argument

CMake 3.21 can emit JUnit XML test results which can be visualized by
GitLab. This also updates the gitlab CI config file to make use of this
feature whenever possible.
This commit is contained in:
Alex Richardson 2022-03-20 00:40:22 +00:00 committed by Ralf Habacker
parent f385a747b5
commit f366b38f31
2 changed files with 48 additions and 13 deletions

View file

@ -62,6 +62,21 @@ variables:
FDO_DISTRIBUTION_VERSION: 'leap'
FDO_DISTRIBUTION_TAG: '2022-04-17' # Bump this version on every ci-install.sh change
.cmake-common:
variables:
# Default to generating JUnit XML output for all CMake jobs.
# This works fine even for older versions of CMake since the extra arguments
# to CTest are ignored and a missing JUnit XML file does not fail the build.
ci_cmake_junit_output: "$CI_PROJECT_DIR/test-results.xml"
ci_buildsys: "cmake"
artifacts:
name: dbus-$CI_JOB_NAME
when: always
paths:
- $CI_PROJECT_DIR/test-results.xml
reports:
junit: $CI_PROJECT_DIR/test-results.xml
windows amd64 image:
stage: "build docker"
variables:
@ -143,7 +158,9 @@ debian autotools legacy:
ci_variant: "legacy"
debian cmake:
extends: .debian-build
extends:
- .cmake-common
- .debian-build
when: manual
variables:
ci_buildsys: "cmake-dist"
@ -155,10 +172,11 @@ debian mingw32 autotools debug:
ci_variant: "debug"
debian mingw32 cmake:
extends: .debian-build
extends:
- .cmake-common
- .debian-build
when: manual
variables:
ci_buildsys: "cmake"
ci_host: "i686-w64-mingw32"
debian mingw64 autotools:
@ -167,7 +185,9 @@ debian mingw64 autotools:
ci_host: "x86_64-w64-mingw32"
debian mingw64 cmake debug:
extends: .debian-build
extends:
- .cmake-common
- .debian-build
when: manual
variables:
ci_buildsys: "cmake"
@ -196,23 +216,26 @@ opensuse image:
stage: build
opensuse cmake:
extends: .suse-build
extends:
- .cmake-common
- .suse-build
variables:
ci_buildsys: "cmake"
ci_local_packages: "no"
opensuse mingw32 cmake:
extends: .suse-build
extends:
- .cmake-common
- .suse-build
when: manual
variables:
ci_buildsys: "cmake"
ci_host: "i686-w64-mingw32"
ci_local_packages: "no"
opensuse mingw64 cmake debug:
extends: .suse-build
extends:
- .cmake-common
- .suse-build
variables:
ci_buildsys: "cmake"
ci_host: "x86_64-w64-mingw32"
ci_local_packages: "no"
ci_variant: "debug"
@ -257,12 +280,14 @@ windows msys64 ucrt64 cmake:
- C:\msys64\usr\bin\bash -lc 'cmake -G \"MinGW Makefiles\" -S . -B build -DDBUS_WITH_GLIB=OFF && cmake --build build --config Release'
windows vs15-64 cmake:
extends: .win-build
extends:
- .cmake-common
- .win-build
script:
- cmake -DCMAKE_PREFIX_PATH=C:/ -G "Visual Studio 15 2017 Win64" -DCMAKE_BUILD_TYPE=Debug -DDBUS_ENABLE_VERBOSE_MODE=OFF -S . -B build
- cmake --build build --config Debug
- cmake --install build --config Debug
# FIXME: a few tests timeout on gitlab runner for unknown reason
- cd build ; ctest -C Debug -VV --timeout 1200 -E '(dbus-daemon|monitor)'
- cd build ; ctest -C Debug -VV --timeout 1200 -E '(dbus-daemon|monitor)' --output-junit $ci_cmake_junit_output
# vim:set sw=2 sts=2 et:

View file

@ -117,6 +117,11 @@ init_wine() {
# If yes, run tests; if no, just build
: "${ci_test:=yes}"
# ci_cmake_junit_output:
# If non-empty, emit JUnit XML output from CTest tests to that file
# Note: requires CMake 3.21 or newer.
: "${ci_cmake_junit_output:=}"
# ci_test_fatal:
# If yes, test failures break the build; if no, they are reported but ignored
: "${ci_test_fatal:=yes}"
@ -418,7 +423,12 @@ case "$ci_buildsys" in
# The test coverage for OOM-safety is too verbose to be useful on
# travis-ci.
export DBUS_TEST_MALLOC_FAILURES=0
[ "$ci_test" = no ] || $cmdwrapper ctest -VV --timeout 180 || maybe_fail_tests
ctest_args="-VV --timeout 180"
if [ -n "$ci_cmake_junit_output" ]; then
ctest_args="--output-junit $ci_cmake_junit_output $ctest_args"
fi
[ "$ci_test" = no ] || $cmdwrapper ctest $ctest_args || maybe_fail_tests
${make} install DESTDIR=$(pwd)/DESTDIR
( cd DESTDIR && find . -ls)
;;