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