From c62957f621ff8169f5f4f0650ac4ccf71a1cafa9 Mon Sep 17 00:00:00 2001 From: Anton Iakimov Date: Wed, 22 Nov 2023 11:37:05 +0100 Subject: [PATCH] feat: publish test_stats report (#4349) Let's publish test_stats as a Jenkins report instead of printing to the build log. --- _assets/ci/Jenkinsfile.tests | 18 ++++++++++++++++-- _assets/scripts/run_unit_tests.sh | 9 +++++++-- 2 files changed, 23 insertions(+), 4 deletions(-) diff --git a/_assets/ci/Jenkinsfile.tests b/_assets/ci/Jenkinsfile.tests index 6407387d2..b6597b904 100644 --- a/_assets/ci/Jenkinsfile.tests +++ b/_assets/ci/Jenkinsfile.tests @@ -103,11 +103,25 @@ pipeline { post { always { script { env.PKG_URL = "${currentBuild.absoluteUrl}/consoleText" } - junit '**/report.xml' + junit testResults: '**/report.xml', + skipOldReports: true, + skipPublishingChecks: true + publishHTML target: [ + allowMissing: true, + alwaysLinkToLastBuild: true, + keepAll: true, + reportDir: 'reports', + reportFiles: 'test_stats.txt', + reportName: 'Reports', + reportTitles: 'Test Stats' + ] } success { script { github.notifyPR(true) } } failure { script { github.notifyPR(false) } } - cleanup { dir(env.TMPDIR) { deleteDir() } } + cleanup { + dir(env.TMPDIR) { deleteDir() } + sh "make git-clean" + } } // post } // pipeline diff --git a/_assets/scripts/run_unit_tests.sh b/_assets/scripts/run_unit_tests.sh index 0537ecdd9..11d99f4d5 100755 --- a/_assets/scripts/run_unit_tests.sh +++ b/_assets/scripts/run_unit_tests.sh @@ -40,17 +40,22 @@ for package in ${UNIT_TEST_PACKAGES}; do fi if [[ "${go_test_exit}" -ne 0 ]]; then - echo -e "${YLW}Failed, see the log:${RST} ${BLD}${output_file}${RST}" + if [[ "${CI}" == 'true' ]]; then + echo -e "${YLW}Failed, see the log:${RST} ${BLD}${output_file}${RST}" + fi + if [[ "$UNIT_TEST_FAILFAST" == 'true' ]]; then exit "${go_test_exit}" fi + last_failing_exit_code="${go_test_exit}" fi done if [[ "${last_failing_exit_code}" -ne 0 ]]; then if [[ "${UNIT_TEST_COUNT}" -gt 1 ]]; then - "${GIT_ROOT}/_assets/scripts/test_stats.py" + mkdir -p "${GIT_ROOT}/reports" + "${GIT_ROOT}/_assets/scripts/test_stats.py" | redirect_stdout "${GIT_ROOT}/reports/test_stats.txt" fi exit "${last_failing_exit_code}"