fix(ci): retry go module download in env image

This commit is contained in:
lyon
2026-06-19 04:14:51 +08:00
parent 028ff83e45
commit d80f2c3954
+2 -1
View File
@@ -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`