diff --git a/scripts/quality_gate.sh b/scripts/quality_gate.sh index 0be39cf..1ffdfcf 100755 --- a/scripts/quality_gate.sh +++ b/scripts/quality_gate.sh @@ -158,15 +158,9 @@ mkdir -p "${BUILD_DIR}" rm -f "${COVERAGE_PROFILE}" "${COVERAGE_PERCENT_FILE}" printf 'failed\n' > "${BUILD_DIR}/docs-naming.status" -echo "[quality] unit tests + workspace coverage profile" +echo "[quality] dependency download" export GOPROXY="${GOPROXY:-https://proxy.golang.org,direct}" run_with_retry 4 go mod download -run_with_retry 3 go test -coverprofile="${COVERAGE_PROFILE}" ./... -coverage_percent="$(go tool cover -func="${COVERAGE_PROFILE}" | awk '/^total:/ {gsub("%","",$3); print $3}')" -if [[ -z "${coverage_percent}" ]]; then - coverage_percent="0" -fi -printf '%s\n' "${coverage_percent}" > "${COVERAGE_PERCENT_FILE}" echo "[quality] hygiene: doc contracts" cd testing @@ -189,6 +183,14 @@ echo "[quality] lint" echo "[quality] installer template contracts" ./scripts/verify_install_templates.sh +echo "[quality] unit tests + workspace coverage profile" +run_with_retry 3 go test -coverprofile="${COVERAGE_PROFILE}" ./... +coverage_percent="$(go tool cover -func="${COVERAGE_PROFILE}" | awk '/^total:/ {gsub("%","",$3); print $3}')" +if [[ -z "${coverage_percent}" ]]; then + coverage_percent="0" +fi +printf '%s\n' "${coverage_percent}" > "${COVERAGE_PERCENT_FILE}" + echo "[quality] per-file coverage gate (95%)" cd testing ANANKE_ENFORCE_COVERAGE=1 ANANKE_PER_FILE_COVERAGE_TARGET=95 go test ./coverage -run TestPerFileCoverageReport -count=1 -v