Merge pull request #10656 from MannXo/ci/10653-go-module-cache
e2e-test-kind.yaml / extract (push) Failing after 6s
Run the E2E test on kind / get-go-version (push) Failing after 9s
Run the E2E test on kind / build (push) Skipped
Run the E2E test on kind / setup-test-matrix (push) Failing after 3s
Run the E2E test on kind / run-e2e-test (push) Skipped
Run the E2E test on kind / run-csi-e2e-test (push) Skipped
push.yml / extract (push) Failing after 6s
Main CI / get-go-version (push) Failing after 7s
Main CI / Build (push) Skipped
Scorecard supply-chain security / Scorecard analysis (push) Skipped

Reuse cached Go modules across CI jobs
This commit is contained in:
Xun Jiang/Bruce Jiang
2026-10-16 11:08:27 +08:00
committed by GitHub
4 changed files with 46 additions and 0 deletions
+38
View File
@@ -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
+4
View File
@@ -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:
+3
View File
@@ -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
+1
View File
@@ -0,0 +1 @@
Reuse cached Go modules across CI jobs