ci(ananke): retry Go dependency fetch in quality gate
This commit is contained in:
parent
add6683e3c
commit
ce2b6c8441
@ -19,6 +19,25 @@ QUALITY_LAST_SUCCESS=0
|
|||||||
QUALITY_LAST_RUN_TS=0
|
QUALITY_LAST_RUN_TS=0
|
||||||
QUALITY_SUCCESS_PERCENT="0.00"
|
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() {
|
read_quality_counter() {
|
||||||
local key="$1"
|
local key="$1"
|
||||||
if [[ ! -f "${QUALITY_STATE_FILE}" ]]; then
|
if [[ ! -f "${QUALITY_STATE_FILE}" ]]; then
|
||||||
@ -137,9 +156,12 @@ trap 'quality_gate_finalize $?' EXIT
|
|||||||
cd "${REPO_DIR}"
|
cd "${REPO_DIR}"
|
||||||
mkdir -p "${BUILD_DIR}"
|
mkdir -p "${BUILD_DIR}"
|
||||||
rm -f "${COVERAGE_PROFILE}" "${COVERAGE_PERCENT_FILE}"
|
rm -f "${COVERAGE_PROFILE}" "${COVERAGE_PERCENT_FILE}"
|
||||||
|
printf 'failed\n' > "${BUILD_DIR}/docs-naming.status"
|
||||||
|
|
||||||
echo "[quality] unit tests + workspace coverage profile"
|
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}')"
|
coverage_percent="$(go tool cover -func="${COVERAGE_PROFILE}" | awk '/^total:/ {gsub("%","",$3); print $3}')"
|
||||||
if [[ -z "${coverage_percent}" ]]; then
|
if [[ -z "${coverage_percent}" ]]; then
|
||||||
coverage_percent="0"
|
coverage_percent="0"
|
||||||
@ -152,6 +174,7 @@ go test ./hygiene -run TestHygieneContracts/doc_contract -count=1
|
|||||||
|
|
||||||
echo "[quality] hygiene: naming contracts"
|
echo "[quality] hygiene: naming contracts"
|
||||||
go test ./hygiene -run TestHygieneContracts/naming_contract -count=1
|
go test ./hygiene -run TestHygieneContracts/naming_contract -count=1
|
||||||
|
printf 'ok\n' > "${BUILD_DIR}/docs-naming.status"
|
||||||
|
|
||||||
echo "[quality] hygiene: LOC limits"
|
echo "[quality] hygiene: LOC limits"
|
||||||
go test ./hygiene -run TestHygieneContracts/loc_limit -count=1
|
go test ./hygiene -run TestHygieneContracts/loc_limit -count=1
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user