From e659714335ac81730e16462fb7b2141382e1c0aa Mon Sep 17 00:00:00 2001 From: codex Date: Mon, 20 Apr 2026 12:58:51 -0300 Subject: [PATCH] ci(metis): anchor quality stage to workspace path --- Jenkinsfile | 49 ++++++++++++++++++++++++++++++++----------------- 1 file changed, 32 insertions(+), 17 deletions(-) diff --git a/Jenkinsfile b/Jenkinsfile index a5db45b..e04007c 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -95,6 +95,7 @@ spec: } options { disableConcurrentBuilds() + buildDiscarder(logRotator(daysToKeepStr: '30', numToKeepStr: '200', artifactDaysToKeepStr: '30', artifactNumToKeepStr: '120')) } parameters { booleanParam( @@ -189,12 +190,38 @@ PY apt-get install -y --no-install-recommends xz-utils >/dev/null mkdir -p build go install github.com/jstemmer/go-junit-report/v2@latest + cd "${WORKSPACE}" + docs_rc=1 + quality_rc=1 + test_rc=1 + set +e - go test -v -count=1 -coverprofile=build/coverage.out ./... > build/test.out 2>&1 - test_rc=$? + cd "${WORKSPACE}/testing" + METIS_USE_EXISTING_COVERAGE=1 go test -v -run TestExportedDocs ./... + docs_rc=$? + printf '%s\n' "${docs_rc}" > "${WORKSPACE}/build/docs-naming.rc" + if [ "${docs_rc}" -eq 0 ]; then + METIS_USE_EXISTING_COVERAGE=1 go test -v ./... + quality_rc=$? + fi + cd "${WORKSPACE}" + + if [ "${docs_rc}" -eq 0 ] && [ "${quality_rc}" -eq 0 ]; then + go test -v -count=1 -coverprofile=build/coverage.out ./... > build/test.out 2>&1 + test_rc=$? + fi set -e - cat build/test.out - "$(go env GOPATH)/bin/go-junit-report" < build/test.out > "${JUNIT_XML}" + + if [ -f build/test.out ]; then + cat build/test.out + "$(go env GOPATH)/bin/go-junit-report" < build/test.out > "${JUNIT_XML}" + else + cat > "${JUNIT_XML}" <<'EOF' + + +EOF + fi + coverage="0" if [ -f build/coverage.out ]; then coverage="$(go tool cover -func=build/coverage.out | awk '/^total:/ {gsub("%","",$3); print $3}')" @@ -202,20 +229,8 @@ PY export GO_COVERAGE="${coverage}" printf '{"summary":{"percent_covered":%s}}\n' "${GO_COVERAGE}" > "${COVERAGE_JSON}" - quality_rc=0 - if [ "${test_rc}" -eq 0 ]; then - set +e - cd testing - METIS_USE_EXISTING_COVERAGE=1 go test -v ./... - quality_rc=$? - set -e - cd "${WORKSPACE}" - else - quality_rc=1 - fi - gate_rc=0 - if [ "${test_rc}" -ne 0 ] || [ "${quality_rc}" -ne 0 ]; then + if [ "${docs_rc}" -ne 0 ] || [ "${quality_rc}" -ne 0 ] || [ "${test_rc}" -ne 0 ]; then gate_rc=1 fi printf '%s\n' "${gate_rc}" > "${TEST_EXIT_CODE_PATH}"