ci(ananke): retry Go dependency fetch in quality gate

This commit is contained in:
codex 2026-04-20 10:49:24 -03:00
parent 0919c56c61
commit b942f823d9

View File

@ -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"