From d80f2c39549f28bd656466ea8fb532dd4dbaebbe Mon Sep 17 00:00:00 2001 From: lyon Date: Fri, 19 Jun 2026 04:14:51 +0800 Subject: [PATCH] fix(ci): retry go module download in env image --- scripts/artifact-publish.mjs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/scripts/artifact-publish.mjs b/scripts/artifact-publish.mjs index f4806e18..3c4cfdf3 100644 --- a/scripts/artifact-publish.mjs +++ b/scripts/artifact-publish.mjs @@ -884,8 +884,9 @@ function envReuseDockerfile(baseImage, labels = [], recipe, service = null) { ["GOPROXY", goProxy], ["GOTOOLCHAIN", normalizedRecipe.goToolchain || "local"] ]) : ""; + const goDownloadRetryScript = `retry_go_mod_download() { attempts=6; n=1; while ! go mod download; do if [ "$n" -ge "$attempts" ]; then return 1; fi; echo "go mod download attempt $n/$attempts failed; retrying" >&2; n=$((n + 1)); sleep 5; done; }`; const goDownloadScript = goCacheEnabled - ? `RUN ${downloadEnvPrefix}${goBuildEnvPrefix}set -eu; mkdir -p ${shellQuote(normalizedRecipe.runtimeGoModCachePath)} ${shellQuote(normalizedRecipe.runtimeGoBuildCachePath)}; go mod download` + ? `RUN ${downloadEnvPrefix}${goBuildEnvPrefix}set -eu; mkdir -p ${shellQuote(normalizedRecipe.runtimeGoModCachePath)} ${shellQuote(normalizedRecipe.runtimeGoBuildCachePath)}; ${goDownloadRetryScript}; retry_go_mod_download` : null; const goReadiness = goCacheEnabled ? `; mkdir -p ${shellQuote(normalizedRecipe.runtimeGoModCachePath)} ${shellQuote(normalizedRecipe.runtimeGoBuildCachePath)}; command -v go >/dev/null; go version >/tmp/hwlab-env-go-version.txt`