]> git.ipfire.org Git - thirdparty/bind9.git/commitdiff
Hoist the junit and artifact handling to the `&unit_test_common` anchor
authorŠtěpán Balážik <stepan@isc.org>
Wed, 4 Jun 2025 13:18:29 +0000 (15:18 +0200)
committerŠtěpán Balážik <stepan@isc.org>
Thu, 26 Jun 2025 15:05:20 +0000 (17:05 +0200)
In some cases the report wasn't generated, sometimes it wasn't kept
properly. This unifies the way artifacts are generated and kept.

(cherry picked from commit 4ec1a37ca090df41f046e20c6a6c788e7a4a0afe)

.gitlab-ci.yml

index 68374614ace3e87292b9f1a210c6a4b23c7dcbd7..08d0e8dbd78620f5bebed7a570a52a82fc61d536 100644 (file)
@@ -500,44 +500,38 @@ stages:
   stage: unit
   before_script:
     - test -n "${OUT_OF_TREE_WORKSPACE}" && cd "${OUT_OF_TREE_WORKSPACE}"
+  # This script needs to: 1) fail if the unit tests fail, 2) fail if the
+  # junit.xml file is broken, 3) produce the junit.xml file even if the
+  # unit tests fail.  Therefore, $RET is used to "cache" the result of
+  # "make unit" as interrupting the script immediately when unit tests
+  # fail would prevent the junit.xml file from being produced.
   script:
     - *fips_feature_test
-    - make -j${TEST_PARALLEL_JOBS:-1} -k unit V=1
-    - test "$CLEAN_BUILD_ARTIFACTS_ON_SUCCESS" -eq 0 || make clean >/dev/null 2>&1
-  after_script:
-    - test -d bind-* && cd bind-*
-    - REALSOURCEDIR="$PWD"
-    - test -n "${OUT_OF_TREE_WORKSPACE}" && cd "${OUT_OF_TREE_WORKSPACE}"
+    - RET=0
+    - make -j${TEST_PARALLEL_JOBS:-1} -k unit V=1 || RET=$?
     - *find_python
     - >
-      "$PYTHON" "$REALSOURCEDIR"/bin/tests/convert-trs-to-junit.py . > "$CI_PROJECT_DIR"/junit.xml
-
-.unit_test: &unit_test_job
-  <<: *unit_test_common
+      "$PYTHON" "$CI_PROJECT_DIR"/bin/tests/convert-trs-to-junit.py . > "$CI_PROJECT_DIR"/junit.xml
+    - *check_for_junit_xml
+    - (exit $RET)
+    - test "$CLEAN_BUILD_ARTIFACTS_ON_SUCCESS" -eq 0 || make clean >/dev/null 2>&1
   artifacts:
     untracked: true
     when: always
     reports:
       junit: junit.xml
 
+.unit_test: &unit_test_job
+  <<: *unit_test_common
+
 .unit_test_gcov: &unit_test_gcov_job
   <<: *unit_test_common
-  artifacts:
-    untracked: true
-    when: always
 
 .unit_test_tsan: &unit_test_tsan_job
   <<: *unit_test_common
   after_script:
     - *find_python
     - *parse_tsan
-    - >
-      "$PYTHON" bin/tests/convert-trs-to-junit.py . > "$CI_PROJECT_DIR"/junit.xml
-  artifacts:
-    untracked: true
-    when: always
-    reports:
-      junit: junit.xml
 
 .docs: &docs_job
   variables: