Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion .github/actions/restore-go-modules/action.yaml
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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"
23 changes: 14 additions & 9 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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'
Expand Down Expand Up @@ -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'
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/copilot-setup-steps.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/mutation-testing.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/system-test-eks.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/system-test-hetzner.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/system-test-omni.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/update-hetzner-talos-iso.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
42 changes: 41 additions & 1 deletion internal/ciharness/go_module_cache_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{
Expand All @@ -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"},
Expand Down Expand Up @@ -148,6 +149,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()

Expand Down
9 changes: 6 additions & 3 deletions internal/ciharness/module_download_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
)
})
}
})
Expand Down Expand Up @@ -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()
Expand All @@ -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),
Expand Down
8 changes: 7 additions & 1 deletion pkg/client/kubescape/release_action_pins_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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).
{
Expand Down
Loading