From b942f823d9ae11f0cefd13e32753d4458a83480a 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 | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/scripts/quality_gate.sh b/scripts/quality_gate.sh index f56a4d4..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 @@ -140,7 +159,9 @@ 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"