From ce2b6c84412c7f0216eb1b95bb6e07c9312950fb Mon Sep 17 00:00:00 2001 From: codex Date: Mon, 20 Apr 2026 10:49:24 -0300 Subject: [PATCH] ci(ananke): retry Go dependency fetch in quality gate --- scripts/quality_gate.sh | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/scripts/quality_gate.sh b/scripts/quality_gate.sh index 487a61a..0be39cf 100755 --- a/scripts/quality_gate.sh +++ b/scripts/quality_gate.sh @@ -19,6 +19,25 @@ QUALITY_LAST_SUCCESS=0 QUALITY_LAST_RUN_TS=0 QUALITY_SUCCESS_PERCENT="0.00" +run_with_retry() { + local attempts="$1" + shift + local try=1 + local delay=3 + local rc=0 + while true; do + "$@" && return 0 + rc=$? + if [[ "${try}" -ge "${attempts}" ]]; then + return "${rc}" + fi + echo "[quality] retry ${try}/${attempts} after rc=${rc}: $*" >&2 + sleep "${delay}" + delay=$((delay * 2)) + try=$((try + 1)) + done +} + read_quality_counter() { local key="$1" if [[ ! -f "${QUALITY_STATE_FILE}" ]]; then @@ -137,9 +156,12 @@ trap 'quality_gate_finalize $?' EXIT cd "${REPO_DIR}" 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" -go test -coverprofile="${COVERAGE_PROFILE}" ./... +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" @@ -152,6 +174,7 @@ go test ./hygiene -run TestHygieneContracts/doc_contract -count=1 echo "[quality] hygiene: naming contracts" go test ./hygiene -run TestHygieneContracts/naming_contract -count=1 +printf 'ok\n' > "${BUILD_DIR}/docs-naming.status" echo "[quality] hygiene: LOC limits" go test ./hygiene -run TestHygieneContracts/loc_limit -count=1