diff --git a/scripts/lint.sh b/scripts/lint.sh index 44ad343..b4db8c8 100755 --- a/scripts/lint.sh +++ b/scripts/lint.sh @@ -6,9 +6,28 @@ cd "${REPO_DIR}" export PATH="$(go env GOPATH)/bin:${PATH}" STATICCHECK_VERSION="${ANANKE_STATICCHECK_VERSION:-2025.1.1}" +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 "[lint] retry ${try}/${attempts} after rc=${rc}: $*" >&2 + sleep "${delay}" + delay=$((delay * 2)) + try=$((try + 1)) + done +} + if ! command -v staticcheck >/dev/null 2>&1 || ! staticcheck -version 2>/dev/null | grep -q "${STATICCHECK_VERSION}"; then echo "[lint] installing staticcheck ${STATICCHECK_VERSION}" - go install "honnef.co/go/tools/cmd/staticcheck@${STATICCHECK_VERSION}" + run_with_retry 4 go install "honnef.co/go/tools/cmd/staticcheck@${STATICCHECK_VERSION}" fi echo "[lint] go vet"