From 93412f612d35018a21eafd7cf28b523b92f5038a Mon Sep 17 00:00:00 2001 From: Nikolai Emil Damm Date: Thu, 12 Nov 2026 21:32:25 +0100 Subject: [PATCH 1/2] ci: download Go modules with a bounded retry after the module restore A cache miss, for example on a pull request that changes go.sum, fetches modules fresh, and one dropped Go proxy stream failed the whole job. The restore-go-modules action now runs the shared bounded download retry from its own pinned checkout, the same way setup-desktop-build does, and the retry script is bound to the audited action content. Part of #8053 Co-Authored-By: Claude Opus 5.5 --- .../actions/restore-go-modules/action.yaml | 13 +++++- internal/ciharness/go_module_cache_test.go | 41 ++++++++++++++++++- internal/ciharness/module_download_test.go | 9 ++-- .../kubescape/release_action_pins_test.go | 8 +++- 4 files changed, 65 insertions(+), 6 deletions(-) diff --git a/.github/actions/restore-go-modules/action.yaml b/.github/actions/restore-go-modules/action.yaml index 1332746bcc..d4d938cec2 100644 --- a/.github/actions/restore-go-modules/action.yaml +++ b/.github/actions/restore-go-modules/action.yaml @@ -1,5 +1,7 @@ name: Restore Go modules -description: Restore the shared main-backed module archive without saving duplicate Go caches. +description: >- + Restore the shared main-backed module archive without saving duplicate Go caches, + then download any missing modules with a bounded retry. runs: using: composite @@ -21,3 +23,12 @@ runs: # Match the released validator: main starts from exact inputs, while a # PR may reuse modules from an earlier default-branch dependency graph. restore-keys: ${{ github.ref != format('refs/heads/{0}', github.event.repository.default_branch) && format('go-mod-v1-{0}-{1}-.-', runner.os, runner.arch) || '' }} + + # A cache miss, such as a pull request that changes go.sum, fetches modules + # fresh, and one dropped Go proxy stream would otherwise fail the job (#8053). + # Download whatever the restore did not supply through the shared bounded + # retry, read from this action's own pinned checkout. Only downloads are + # retried: a later build or test failure still stops the job at once. + - name: Download Go modules + shell: bash + run: bash "$GITHUB_ACTION_PATH/../../scripts/download-go-modules.sh" diff --git a/internal/ciharness/go_module_cache_test.go b/internal/ciharness/go_module_cache_test.go index f5f2f79f40..047dbd5e54 100644 --- a/internal/ciharness/go_module_cache_test.go +++ b/internal/ciharness/go_module_cache_test.go @@ -21,7 +21,7 @@ func TestGoModuleRestoreConsumerBindings(t *testing.T) { t.Parallel() contents := readRepoFile(t, ".github/actions/restore-go-modules/action.yaml") - require.Equal(t, "0cc2a584876350f4b355373c4a290e4a59b9cc0e0657acdb2a14e101e4d02f53", + require.Equal(t, "bfa9a94ba8de19ad4f8918a7220548b7af6ad2f751f7a9a131bffda3a06be329", fmt.Sprintf("%x", sha256.Sum256(contents))) for path, jobs := range map[string][]string{ @@ -148,6 +148,45 @@ func TestGoModuleRestoreOnly(t *testing.T) { } } +// A restore that misses the cache, such as on a pull request that changes go.sum, must not let one +// dropped Go proxy stream fail the job (#8053). The action downloads whatever the restore did not +// supply through the shared bounded retry, read from its own pinned checkout, so every consumer +// recovers a transient download failure while a later build or test failure still stops the job. +func TestGoModuleRestoreDownloadsThroughBoundedRetry(t *testing.T) { + t.Parallel() + requireTestExecutable(t, "bash") + + const actionPath = ".github/actions/restore-go-modules" + + steps := readCompositeAction(t, actionPath+"/action.yaml").Runs.Steps + download := findHarnessStep(t, steps, "Download Go modules") + + assert.Equal(t, + `bash "$GITHUB_ACTION_PATH/../../scripts/download-go-modules.sh"`, + strings.TrimSpace(download.Run), + "consumers must run the audited retry from the action's own pinned checkout") + assert.Empty(t, download.If, "every consumer must download through the retry") + assert.False(t, download.ContinueOnError, "an exhausted download must fail the job") + assert.Less(t, + harnessStepIndex(t, steps, "Restore Go module cache"), + harnessStepIndex(t, steps, download.Name), + "download only what the restored archive did not supply") + assert.Equal(t, len(steps)-1, harnessStepIndex(t, steps, download.Name), + "the consumer's own steps must start with every module present") + + for _, scenario := range []moduleDownloadScenario{ + {name: "cache_warm", downloads: 1, operations: 1}, + {name: "two_proxy_blips", failures: 2, downloads: 3, operations: 1, backoff: "5\n10\n"}, + {name: "exhausted", failures: 3, downloads: 3, backoff: "5\n10\n"}, + {name: "downstream_error", operationExit: 37, downloads: 1, operations: 1}, + } { + t.Run(scenario.name, func(t *testing.T) { + t.Parallel() + runModuleDownloadScenario(t, download, "go build", actionPath, scenario) + }) + } +} + func TestGoModuleRestorePathMetadata(t *testing.T) { t.Parallel() diff --git a/internal/ciharness/module_download_test.go b/internal/ciharness/module_download_test.go index aec0e6a2f0..842e3283b3 100644 --- a/internal/ciharness/module_download_test.go +++ b/internal/ciharness/module_download_test.go @@ -75,7 +75,9 @@ func TestReleaseModuleDownloadRetries(t *testing.T) { } { t.Run(scenario.name, func(t *testing.T) { t.Parallel() - runModuleDownloadScenario(t, prefetch, downstreamRun, scenario) + runModuleDownloadScenario( + t, prefetch, downstreamRun, ".github/actions/setup-desktop-build", scenario, + ) }) } }) @@ -155,10 +157,11 @@ func releaseModuleDownloadStep(t *testing.T, steps []harnessStep) harnessStep { } // Execute the checked-in downloader with recorded transport, backoff and downstream results. +// actionPath is the composite action directory a GITHUB_ACTION_PATH-relative step resolves from. func runModuleDownloadScenario( t *testing.T, prefetch harnessStep, - downstreamRun string, + downstreamRun, actionPath string, scenario moduleDownloadScenario, ) { t.Helper() @@ -178,7 +181,7 @@ func runModuleDownloadScenario( command.Dir = root command.Env = append(os.Environ(), "PATH="+directory+string(os.PathListSeparator)+os.Getenv("PATH"), - "GITHUB_ACTION_PATH="+filepath.Join(root, ".github/actions/setup-desktop-build"), + "GITHUB_ACTION_PATH="+filepath.Join(root, actionPath), "DOWNLOAD_CALLS="+filepath.Join(directory, "calls"), "DOWNLOAD_DELAYS="+filepath.Join(directory, "delays"), "DOWNLOAD_FAILURES="+strconv.Itoa(scenario.failures), diff --git a/pkg/client/kubescape/release_action_pins_test.go b/pkg/client/kubescape/release_action_pins_test.go index 1daaf90ec5..4bab903ecb 100644 --- a/pkg/client/kubescape/release_action_pins_test.go +++ b/pkg/client/kubescape/release_action_pins_test.go @@ -66,7 +66,13 @@ func auditedActionBindings() []struct{ path, action, content string } { { ".github/actions/restore-go-modules/action.yaml", "restore-go-modules", - "0cc2a584876350f4b355373c4a290e4a59b9cc0e0657acdb2a14e101e4d02f53", + "bfa9a94ba8de19ad4f8918a7220548b7af6ad2f751f7a9a131bffda3a06be329", + }, + // restore-go-modules runs the bounded module download from its own pinned checkout. + { + ".github/scripts/download-go-modules.sh", + "restore-go-modules", + "e5af8edf61a77de4397e952a05b1cc6ca0f83cd848523c4cf6b3aaa2539561fa", }, // setup-desktop-build runs these scripts from its own pinned checkout ($GITHUB_ACTION_PATH). { From e892f8539b39e48480b2b91cc351400750a8645d Mon Sep 17 00:00:00 2001 From: Nikolai Emil Damm Date: Thu, 12 Nov 2026 21:34:24 +0100 Subject: [PATCH 2/2] ci: run every Go module restore through the bounded download retry Pin all restore-go-modules consumers to the commit that adds the bounded download, and restore modules in the workflow-contract job, whose tests resolved modules with no cache and no retry. Part of #8053 Co-Authored-By: Claude Opus 5.5 --- .github/workflows/ci.yaml | 23 +++++++++++-------- .github/workflows/copilot-setup-steps.yml | 2 +- .github/workflows/mutation-testing.yaml | 2 +- .github/workflows/system-test-eks.yaml | 2 +- .github/workflows/system-test-hetzner.yaml | 4 ++-- .github/workflows/system-test-omni.yaml | 4 ++-- .../workflows/update-hetzner-talos-iso.yaml | 2 +- internal/ciharness/go_module_cache_test.go | 1 + 8 files changed, 23 insertions(+), 17 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 0cf856f5dd..b46a24e175 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -1081,7 +1081,7 @@ jobs: cache: false - name: ♻️ Restore Go modules - uses: devantler-tech/ksail/.github/actions/restore-go-modules@46fdd72dff3ccc24a494508fde43426c7e65a0e3 + uses: devantler-tech/ksail/.github/actions/restore-go-modules@93412f612d35018a21eafd7cf28b523b92f5038a - name: 📦 Cache KSail Binary id: binary @@ -1216,7 +1216,7 @@ jobs: - name: ♻️ Restore Go modules if: steps.calico-cache.outputs.cache-hit != 'true' - uses: devantler-tech/ksail/.github/actions/restore-go-modules@46fdd72dff3ccc24a494508fde43426c7e65a0e3 + uses: devantler-tech/ksail/.github/actions/restore-go-modules@93412f612d35018a21eafd7cf28b523b92f5038a - name: 🏗️ Build Calico migration baseline if: steps.calico-cache.outputs.cache-hit != 'true' @@ -1318,7 +1318,7 @@ jobs: cache: false - name: ♻️ Restore Go modules - uses: devantler-tech/ksail/.github/actions/restore-go-modules@46fdd72dff3ccc24a494508fde43426c7e65a0e3 + uses: devantler-tech/ksail/.github/actions/restore-go-modules@93412f612d35018a21eafd7cf28b523b92f5038a - name: 📝 Generate JSON schema if: needs.changes.outputs.schema == 'true' @@ -1658,7 +1658,7 @@ jobs: cache: false - name: ♻️ Restore Go modules - uses: devantler-tech/ksail/.github/actions/restore-go-modules@46fdd72dff3ccc24a494508fde43426c7e65a0e3 + uses: devantler-tech/ksail/.github/actions/restore-go-modules@93412f612d35018a21eafd7cf28b523b92f5038a - name: 🏠 Verify tests never touch the real home directory shell: bash @@ -2008,7 +2008,7 @@ jobs: cache: false - name: ♻️ Restore Go modules - uses: devantler-tech/ksail/.github/actions/restore-go-modules@46fdd72dff3ccc24a494508fde43426c7e65a0e3 + uses: devantler-tech/ksail/.github/actions/restore-go-modules@93412f612d35018a21eafd7cf28b523b92f5038a - name: 🧪 Run Operator Chart E2E uses: ./.github/actions/operator-chart-e2e @@ -2050,7 +2050,7 @@ jobs: cache: false - name: ♻️ Restore Go modules - uses: devantler-tech/ksail/.github/actions/restore-go-modules@46fdd72dff3ccc24a494508fde43426c7e65a0e3 + uses: devantler-tech/ksail/.github/actions/restore-go-modules@93412f612d35018a21eafd7cf28b523b92f5038a - name: 📦 Cache KSail Binary uses: ./.github/actions/cache-ksail-binary @@ -2587,6 +2587,11 @@ jobs: go-version-file: go.mod cache: false + # The contract tests resolve modules too; without this restore, one dropped Go proxy + # stream failed the job on a pull request that changed go.sum (#8053). + - name: ♻️ Restore Go modules + uses: devantler-tech/ksail/.github/actions/restore-go-modules@93412f612d35018a21eafd7cf28b523b92f5038a + # -count=1 is load-bearing: this test's real subject is a YAML file the Go build graph # cannot see, so a cached PASS from an earlier run would be replayed over a changed # workflow and report success without executing anything. @@ -2771,7 +2776,7 @@ jobs: cache: false - name: ♻️ Restore Go modules - uses: devantler-tech/ksail/.github/actions/restore-go-modules@46fdd72dff3ccc24a494508fde43426c7e65a0e3 + uses: devantler-tech/ksail/.github/actions/restore-go-modules@93412f612d35018a21eafd7cf28b523b92f5038a # -count=1 is load-bearing: the files under test are invisible to the Go build graph, # so a cached PASS from an earlier run would be replayed over the changed configuration. @@ -2844,7 +2849,7 @@ jobs: cache: false - name: ♻️ Restore Go modules - uses: devantler-tech/ksail/.github/actions/restore-go-modules@46fdd72dff3ccc24a494508fde43426c7e65a0e3 + uses: devantler-tech/ksail/.github/actions/restore-go-modules@93412f612d35018a21eafd7cf28b523b92f5038a - name: 📥 Download Go modules before the audit # Retry transport failures here; the audit verdict itself remains a single run. @@ -2906,7 +2911,7 @@ jobs: cache: false - name: ♻️ Restore Go modules - uses: devantler-tech/ksail/.github/actions/restore-go-modules@46fdd72dff3ccc24a494508fde43426c7e65a0e3 + uses: devantler-tech/ksail/.github/actions/restore-go-modules@93412f612d35018a21eafd7cf28b523b92f5038a - name: 🧪 Reproduce local safety and partial-deletion cases id: local-safety diff --git a/.github/workflows/copilot-setup-steps.yml b/.github/workflows/copilot-setup-steps.yml index 015546ecf2..b1b2c44495 100644 --- a/.github/workflows/copilot-setup-steps.yml +++ b/.github/workflows/copilot-setup-steps.yml @@ -28,7 +28,7 @@ jobs: go-version-file: ./go.mod - name: ♻️ Restore Go modules - uses: devantler-tech/ksail/.github/actions/restore-go-modules@46fdd72dff3ccc24a494508fde43426c7e65a0e3 + uses: devantler-tech/ksail/.github/actions/restore-go-modules@93412f612d35018a21eafd7cf28b523b92f5038a - name: 🔧 Setup golangci-lint uses: golangci/golangci-lint-action@ba0d7d2ec06a0ea1cb5fa41b2e4a3ab91d21278a # v9.3.0 diff --git a/.github/workflows/mutation-testing.yaml b/.github/workflows/mutation-testing.yaml index ad7393744c..402f99903d 100644 --- a/.github/workflows/mutation-testing.yaml +++ b/.github/workflows/mutation-testing.yaml @@ -52,7 +52,7 @@ jobs: cache: false - name: ♻️ Restore Go modules - uses: devantler-tech/ksail/.github/actions/restore-go-modules@46fdd72dff3ccc24a494508fde43426c7e65a0e3 + uses: devantler-tech/ksail/.github/actions/restore-go-modules@93412f612d35018a21eafd7cf28b523b92f5038a - name: 🧪 Test the report summarizer run: bash .github/scripts/summarize-mutation-report.test.sh diff --git a/.github/workflows/system-test-eks.yaml b/.github/workflows/system-test-eks.yaml index 458993e2f8..7e169a471d 100644 --- a/.github/workflows/system-test-eks.yaml +++ b/.github/workflows/system-test-eks.yaml @@ -108,7 +108,7 @@ jobs: cache: false - name: ♻️ Restore Go modules - uses: devantler-tech/ksail/.github/actions/restore-go-modules@46fdd72dff3ccc24a494508fde43426c7e65a0e3 + uses: devantler-tech/ksail/.github/actions/restore-go-modules@93412f612d35018a21eafd7cf28b523b92f5038a - name: 📦 Cache KSail Binary id: binary diff --git a/.github/workflows/system-test-hetzner.yaml b/.github/workflows/system-test-hetzner.yaml index e6da79162c..e860eee4b0 100644 --- a/.github/workflows/system-test-hetzner.yaml +++ b/.github/workflows/system-test-hetzner.yaml @@ -149,7 +149,7 @@ jobs: cache: false - name: ♻️ Restore Go modules - uses: devantler-tech/ksail/.github/actions/restore-go-modules@46fdd72dff3ccc24a494508fde43426c7e65a0e3 + uses: devantler-tech/ksail/.github/actions/restore-go-modules@93412f612d35018a21eafd7cf28b523b92f5038a - name: 📦 Cache KSail Binary uses: $/.github/actions/cache-ksail-binary @@ -178,7 +178,7 @@ jobs: cache: false - name: ♻️ Restore Go modules - uses: devantler-tech/ksail/.github/actions/restore-go-modules@46fdd72dff3ccc24a494508fde43426c7e65a0e3 + uses: devantler-tech/ksail/.github/actions/restore-go-modules@93412f612d35018a21eafd7cf28b523b92f5038a - name: 📦 Cache KSail Binary uses: $/.github/actions/cache-ksail-binary diff --git a/.github/workflows/system-test-omni.yaml b/.github/workflows/system-test-omni.yaml index 8b39f15db4..1762584867 100644 --- a/.github/workflows/system-test-omni.yaml +++ b/.github/workflows/system-test-omni.yaml @@ -101,7 +101,7 @@ jobs: cache: false - name: ♻️ Restore Go modules - uses: devantler-tech/ksail/.github/actions/restore-go-modules@46fdd72dff3ccc24a494508fde43426c7e65a0e3 + uses: devantler-tech/ksail/.github/actions/restore-go-modules@93412f612d35018a21eafd7cf28b523b92f5038a - name: 📦 Cache KSail Binary uses: ./.github/actions/cache-ksail-binary @@ -130,7 +130,7 @@ jobs: cache: false - name: ♻️ Restore Go modules - uses: devantler-tech/ksail/.github/actions/restore-go-modules@46fdd72dff3ccc24a494508fde43426c7e65a0e3 + uses: devantler-tech/ksail/.github/actions/restore-go-modules@93412f612d35018a21eafd7cf28b523b92f5038a - name: 📦 Cache KSail Binary uses: ./.github/actions/cache-ksail-binary diff --git a/.github/workflows/update-hetzner-talos-iso.yaml b/.github/workflows/update-hetzner-talos-iso.yaml index 6c8a69df89..06b98a24f0 100644 --- a/.github/workflows/update-hetzner-talos-iso.yaml +++ b/.github/workflows/update-hetzner-talos-iso.yaml @@ -48,7 +48,7 @@ jobs: cache: false - name: ♻️ Restore Go modules - uses: devantler-tech/ksail/.github/actions/restore-go-modules@46fdd72dff3ccc24a494508fde43426c7e65a0e3 + uses: devantler-tech/ksail/.github/actions/restore-go-modules@93412f612d35018a21eafd7cf28b523b92f5038a - name: 🔎 Read official Hetzner catalog id: catalog diff --git a/internal/ciharness/go_module_cache_test.go b/internal/ciharness/go_module_cache_test.go index 047dbd5e54..4acb3554f4 100644 --- a/internal/ciharness/go_module_cache_test.go +++ b/internal/ciharness/go_module_cache_test.go @@ -31,6 +31,7 @@ func TestGoModuleRestoreConsumerBindings(t *testing.T) { // TestKSailBinaryArtifactMirrorWarmerConsumer instead. "warm-helm-cache", "test-release-config", "release-graph-audit", "local-recovery-trial", + "verify-todos-workflow-contract", }, "copilot-setup-steps.yml": {"copilot-setup-steps"}, "system-test-eks.yaml": {"build-artifact"},