From c0d13fc51f4b2bd748d2db0b0f936cadfd67bebb Mon Sep 17 00:00:00 2001 From: Parman Mohammadalizadeh Date: Wed, 14 Oct 2026 20:46:42 +0200 Subject: [PATCH 1/2] Reuse cached Go modules across CI jobs The kind e2e jobs download every module on every run. setup-go restores its cache from main, but push.yml runs `go clean -modcache` before setup-go's post step saves, so main holds an empty entry (1568 bytes) under the key PR jobs ask for. They count it as a hit, so nothing is ever saved over it. - push.yml: turn off setup-go's cache, since the job empties it. - e2e-test-kind.yaml: the build job restores one module cache, downloads what the e2e jobs need on a miss (`go mod download` plus the ginkgo CLI), and saves it before the job ends. The e2e jobs restore the same key. It is keyed on go.mod and go.sum rather than the Go patch version, which differed between runner images within one run. - pr-ci-check.yml: point GOMODCACHE at .go/pkg/mod, which the build container mounts, so `go mod tidy` on the host and the containerised steps share one download that setup-go caches. Fixes #10653 Signed-off-by: Parman Mohammadalizadeh --- .github/workflows/e2e-test-kind.yaml | 38 ++++++++++++++++++++++++++++ .github/workflows/pr-ci-check.yml | 4 +++ .github/workflows/push.yml | 3 +++ 3 files changed, 45 insertions(+) diff --git a/.github/workflows/e2e-test-kind.yaml b/.github/workflows/e2e-test-kind.yaml index 1e4e7761e..c490f7662 100644 --- a/.github/workflows/e2e-test-kind.yaml +++ b/.github/workflows/e2e-test-kind.yaml @@ -37,6 +37,24 @@ jobs: uses: actions/setup-go@v7 with: go-version: ${{ needs.get-go-version.outputs.version }} + cache: false + + # One Go module cache for this job and the e2e jobs. The key leaves out the + # Go patch version, which differs between runner images in the same run. + - name: Restore Go module cache + id: go-mod-cache + uses: actions/cache/restore@v6 + with: + path: ~/go/pkg/mod + key: go-mod-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('**/go.mod', '**/go.sum') }} + restore-keys: go-mod-${{ runner.os }}-${{ runner.arch }}- + # Download everything the e2e jobs need, including the ginkgo CLI's own + # dependencies, so they can run from the cache. + - name: Download Go modules + if: steps.go-mod-cache.outputs.cache-hit != 'true' + run: | + go mod download + make -C test/ ginkgo # Look for a CLI that's made for this PR - name: Fetch built CLI @@ -106,6 +124,12 @@ jobs: with: path: ./minio-image.tar key: minio-bitnami-${{ env.BITNAMI_CONTAINERS_COMMIT }} + - name: Save Go module cache + if: steps.go-mod-cache.outputs.cache-hit != 'true' + uses: actions/cache/save@v6 + with: + path: ~/go/pkg/mod + key: ${{ steps.go-mod-cache.outputs.cache-primary-key }} # Create json of k8s versions to test # from guide: https://stackoverflow.com/a/65094398/4590470 setup-test-matrix: @@ -203,6 +227,13 @@ jobs: uses: actions/setup-go@v7 with: go-version: ${{ needs.get-go-version.outputs.version }} + cache: false + - name: Restore Go module cache + uses: actions/cache/restore@v6 + with: + path: ~/go/pkg/mod + key: go-mod-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('**/go.mod', '**/go.sum') }} + restore-keys: go-mod-${{ runner.os }}-${{ runner.arch }}- # Fetch the pre-built MinIO image from the build job - name: Fetch built MinIO Image @@ -298,6 +329,13 @@ jobs: uses: actions/setup-go@v7 with: go-version: ${{ needs.get-go-version.outputs.version }} + cache: false + - name: Restore Go module cache + uses: actions/cache/restore@v6 + with: + path: ~/go/pkg/mod + key: go-mod-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('**/go.mod', '**/go.sum') }} + restore-keys: go-mod-${{ runner.os }}-${{ runner.arch }}- # Fetch the pre-built MinIO image from the build job - name: Fetch built MinIO Image diff --git a/.github/workflows/pr-ci-check.yml b/.github/workflows/pr-ci-check.yml index 8ab76d198..51ccfa8e5 100644 --- a/.github/workflows/pr-ci-check.yml +++ b/.github/workflows/pr-ci-check.yml @@ -14,6 +14,10 @@ jobs: name: Run CI needs: get-go-version runs-on: ubuntu-latest + # The build container mounts .go/pkg as its GOPATH/pkg, so pointing the host + # here lets go mod tidy and the container share one cached module download. + env: + GOMODCACHE: ${{ github.workspace }}/.go/pkg/mod strategy: fail-fast: false steps: diff --git a/.github/workflows/push.yml b/.github/workflows/push.yml index e037bdd96..340daac39 100644 --- a/.github/workflows/push.yml +++ b/.github/workflows/push.yml @@ -29,6 +29,9 @@ jobs: uses: actions/setup-go@b7ad1dad31e06c5925ef5d2fc7ad053ef454303e # v7.0.0 with: go-version: ${{ needs.get-go-version.outputs.version }} + # The Build step cleans the module cache, so saving it would store an + # empty entry under the key that PR jobs restore. + cache: false - name: Set up QEMU id: qemu From 7802f24fe997cbfc15cb65d9b6da31048d3970f9 Mon Sep 17 00:00:00 2001 From: Parman Mohammadalizadeh Date: Wed, 14 Oct 2026 20:56:26 +0200 Subject: [PATCH 2/2] Add changelog for #10656 Signed-off-by: Parman Mohammadalizadeh --- changelogs/unreleased/10656-MannXo | 1 + 1 file changed, 1 insertion(+) create mode 100644 changelogs/unreleased/10656-MannXo diff --git a/changelogs/unreleased/10656-MannXo b/changelogs/unreleased/10656-MannXo new file mode 100644 index 000000000..f119f7065 --- /dev/null +++ b/changelogs/unreleased/10656-MannXo @@ -0,0 +1 @@ +Reuse cached Go modules across CI jobs