From dfd6097f7bb573dfa9e713149d33e6d9b92e3e99 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=A0t=C4=9Bp=C3=A1n=20Bal=C3=A1=C5=BEik?= Date: Wed, 4 Jun 2025 14:41:35 +0200 Subject: [PATCH 1/5] Add a check for existence and sanity of the junit.xml file And use if after system tests are run using pytest. --- .gitlab-ci.yml | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index dff20918b5..e006364fa9 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -311,6 +311,21 @@ stages: .fips-feature-test: &fips_feature_test - if build/feature-test --have-fips-mode; then fips-mode-setup --check; fips-mode-setup --is-enabled; fi +.check_for_junit_xml: &check_for_junit_xml + # test if junit.xml file exists and is longer 40 bytes + # (i.e., contains more than ``) + - if [ -f "$CI_PROJECT_DIR"/junit.xml ]; then + if [ $(wc -c < "$CI_PROJECT_DIR"/junit.xml) -gt 40 ]; then + echo "junit.xml file exists and is longer than 40 bytes."; + else + echo "junit.xml file exists but is too short."; + exit 1; + fi + else + echo "junit.xml file does not exist."; + exit 1; + fi + .build: &build_job <<: *default_triggering_rules stage: build @@ -394,14 +409,23 @@ stages: stage: system before_script: - *setup_interfaces + # This script needs to: 1) fail if the system tests fail, 2) fail if + # the junit.xml file is broken, 3) produce the junit.xml file even if + # the system tests fail. Therefore, $RET is used to "cache" the + # result of running pytest as interrupting the script immediately when + # system tests fail would make checking the contents of the junit.xml + # file impossible (GitLab Runner uses "set -o pipefail"). script: - *fips_feature_test - *find_pytest - *find_python - ( if [ "${CI_DISPOSABLE_ENVIRONMENT}" = "true" ]; then sleep 3000; "$PYTHON" "${CI_PROJECT_DIR}/util/get-running-system-tests.py"; fi ) & - cd bin/tests/system + - RET=0 - > - "$PYTEST" --junit-xml="$CI_PROJECT_DIR"/junit.xml -n "$TEST_PARALLEL_JOBS" | tee pytest.out.txt + ("$PYTEST" --junit-xml="$CI_PROJECT_DIR"/junit.xml -n "$TEST_PARALLEL_JOBS" | tee pytest.out.txt) || RET=1 + - *check_for_junit_xml + - (exit $RET) - '( ! grep -F "grep: warning:" pytest.out.txt )' - test "$CLEAN_BUILD_ARTIFACTS_ON_SUCCESS" -eq 0 || ( cd ../../.. && ninja -C build clean >/dev/null 2>&1 ) after_script: From c61ff639b3a5aa7d4513efdc893aadff95a56c60 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=A0t=C4=9Bp=C3=A1n=20Bal=C3=A1=C5=BEik?= Date: Wed, 4 Jun 2025 15:06:09 +0200 Subject: [PATCH 2/5] Hoist the artifact handling to the `&system_test_common` anchor In the past artifacts of different types of system test jobs were treated differently but this is no longer the case. --- .gitlab-ci.yml | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index e006364fa9..80cfda53b6 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -430,9 +430,6 @@ stages: - test "$CLEAN_BUILD_ARTIFACTS_ON_SUCCESS" -eq 0 || ( cd ../../.. && ninja -C build clean >/dev/null 2>&1 ) after_script: - *display_pytest_failures - -.system_test: &system_test_job - <<: *system_test_common artifacts: untracked: true exclude: @@ -441,26 +438,17 @@ stages: reports: junit: junit.xml +.system_test: &system_test_job + <<: *system_test_common + .system_test_gcov: &system_test_gcov_job <<: *system_test_common - artifacts: - untracked: true - exclude: - - "**/__pycache__/**/*" - when: always .system_test_tsan: &system_test_tsan_job <<: *system_test_common after_script: - *display_pytest_failures - *parse_tsan - artifacts: - untracked: true - exclude: - - "**/__pycache__/**/*" - when: always - reports: - junit: junit.xml .unit_test_common: &unit_test_common <<: *default_triggering_rules From cbe9972d3e3c682621c8b6ddf338ffd2f8a872ca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=A0t=C4=9Bp=C3=A1n=20Bal=C3=A1=C5=BEik?= Date: Wed, 4 Jun 2025 15:13:23 +0200 Subject: [PATCH 3/5] Clean up the definitions and usages of `&system_test_*` anchors Remove redundant indirections and overwrites. --- .gitlab-ci.yml | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 80cfda53b6..cbf3bf688e 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -404,7 +404,7 @@ stages: artifacts: true timeout: 2h -.system_test_common: &system_test_common +.system_test_common: &system_test_job <<: *default_triggering_rules stage: system before_script: @@ -438,14 +438,8 @@ stages: reports: junit: junit.xml -.system_test: &system_test_job - <<: *system_test_common - -.system_test_gcov: &system_test_gcov_job - <<: *system_test_common - .system_test_tsan: &system_test_tsan_job - <<: *system_test_common + <<: *system_test_job after_script: - *display_pytest_failures - *parse_tsan @@ -924,7 +918,7 @@ gcc:bookworm:amd64: system:gcc:bookworm:amd64: <<: *debian_bookworm_amd64_image - <<: *system_test_gcov_job + <<: *system_test_job variables: CI_ENABLE_ALL_TESTS: 1 CLEAN_BUILD_ARTIFACTS_ON_SUCCESS: 0 From 4ec1a37ca090df41f046e20c6a6c788e7a4a0afe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=A0t=C4=9Bp=C3=A1n=20Bal=C3=A1=C5=BEik?= Date: Wed, 4 Jun 2025 15:18:29 +0200 Subject: [PATCH 4/5] Hoist the junit and artifact handling to the `&unit_test_common` anchor In some cases the report wasn't generated, sometimes it wasn't kept properly. This unifies the way artifacts are generated and kept. --- .gitlab-ci.yml | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index cbf3bf688e..f7ad056ef5 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -447,37 +447,37 @@ stages: .unit_test_common: &unit_test_common <<: *default_triggering_rules stage: unit + # 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 + # running "meson test" as interrupting the script immediately when + # unit tests fail would make checking the contents of the junit.xml + # file impossible (GitLab Runner uses "set -o pipefail"). script: - *fips_feature_test - - meson test -C build --no-rebuild - after_script: + - RET=0 + - meson test -C build --no-rebuild || RET=1 - cp build/meson-logs/testlog.junit.xml $CI_PROJECT_DIR/junit.xml + - *check_for_junit_xml + - (exit $RET) - test "$CLEAN_BUILD_ARTIFACTS_ON_SUCCESS" -eq 0 || ninja -C build clean >/dev/null 2>&1 - -.unit_test: &unit_test_job - <<: *unit_test_common 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 - artifacts: - untracked: true - when: always - reports: - junit: junit.xml .docs: &docs_job stage: docs From 4303e0691968824ae8b8938e1ab121386f32f83a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=A0t=C4=9Bp=C3=A1n=20Bal=C3=A1=C5=BEik?= Date: Wed, 4 Jun 2025 15:22:12 +0200 Subject: [PATCH 5/5] Clean up the definitions and usages of `&unit_test_*` anchors Remove redundant indirections and overwrites. --- .gitlab-ci.yml | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index f7ad056ef5..51ea3d1a73 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -444,7 +444,7 @@ stages: - *display_pytest_failures - *parse_tsan -.unit_test_common: &unit_test_common +.unit_test_common: &unit_test_job <<: *default_triggering_rules stage: unit # This script needs to: 1) fail if the unit tests fail, 2) fail if the @@ -467,14 +467,8 @@ stages: reports: junit: junit.xml -.unit_test: &unit_test_job - <<: *unit_test_common - -.unit_test_gcov: &unit_test_gcov_job - <<: *unit_test_common - .unit_test_tsan: &unit_test_tsan_job - <<: *unit_test_common + <<: *unit_test_job after_script: - *find_python - *parse_tsan @@ -929,7 +923,7 @@ system:gcc:bookworm:amd64: unit:gcc:bookworm:amd64: <<: *debian_bookworm_amd64_image - <<: *unit_test_gcov_job + <<: *unit_test_job variables: CI_ENABLE_ALL_TESTS: 1 CLEAN_BUILD_ARTIFACTS_ON_SUCCESS: 0