]> git.ipfire.org Git - thirdparty/dbus.git/commitdiff
tools/ci-build.sh: Add a ci_cmake_junit_output argument
authorAlex Richardson <arichardson.kde@gmail.com>
Sun, 20 Mar 2022 00:40:22 +0000 (00:40 +0000)
committerRalf Habacker <ralf.habacker@freenet.de>
Tue, 17 May 2022 10:48:06 +0000 (10:48 +0000)
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.

.gitlab-ci.yml
tools/ci-build.sh

index ae26845928153456d7fdbbb63fac7189abfdbbc8..baf345603a91ff7965dba51ff61f586a9d27afea 100644 (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:
index 38c87fe570e7bf09810634d9e22151c19e427ec3..e81e0dd43dde023e5c02af47a0124b2fc7d7d52d 100755 (executable)
@@ -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)
         ;;