diff --git a/.github/workflows/e2e-test-kind.yaml b/.github/workflows/e2e-test-kind.yaml index 79e07fded..fcf0d37c2 100644 --- a/.github/workflows/e2e-test-kind.yaml +++ b/.github/workflows/e2e-test-kind.yaml @@ -39,14 +39,14 @@ jobs: # Look for a CLI that's made for this PR - name: Fetch built CLI id: cli-cache - uses: actions/cache@v6 + uses: actions/cache/restore@v6 with: path: ./_output/bin/linux/amd64/velero # The cache key a combination of the current PR number and the commit SHA key: velero-cli-${{ github.event.pull_request.number }}-${{ github.sha }} - name: Fetch built image id: image-cache - uses: actions/cache@v6 + uses: actions/cache/restore@v6 with: path: ./velero.tar # The cache key a combination of the current PR number and the commit SHA @@ -64,7 +64,7 @@ jobs: docker save velero:pr-test-linux-amd64 -o ./velero.tar # Build the MinIO image once for all e2e tests, from the reviewed bitnami/containers commit. - name: Cache MinIO Image - uses: actions/cache@v6 + uses: actions/cache/restore@v6 id: minio-cache with: path: ./minio-image.tar @@ -81,6 +81,29 @@ jobs: cd /tmp/bitnami-containers/bitnami/minio/2026/debian-12 docker build -t bitnami/minio:local . docker save bitnami/minio:local > ${{ github.workspace }}/minio-image.tar + # Save the freshly built artifacts to the cache explicitly, before this + # job reports completion. actions/cache saves in a post-job hook that + # runs *after* the job finishes, so the dependent run-e2e-test jobs (which + # start as soon as build completes) would race the save and miss the cache + # on a force push. See #9927. + - name: Save built CLI to cache + if: steps.cli-cache.outputs.cache-hit != 'true' + uses: actions/cache/save@v6 + with: + path: ./_output/bin/linux/amd64/velero + key: velero-cli-${{ github.event.pull_request.number }}-${{ github.sha }} + - name: Save built image to cache + if: steps.image-cache.outputs.cache-hit != 'true' + uses: actions/cache/save@v6 + with: + path: ./velero.tar + key: velero-image-${{ github.event.pull_request.number }}-${{ github.sha }} + - name: Save MinIO image to cache + if: steps.minio-cache.outputs.cache-hit != 'true' + uses: actions/cache/save@v6 + with: + path: ./minio-image.tar + key: minio-bitnami-${{ steps.minio-version.outputs.dockerfile_sha }} # Create json of k8s versions to test # from guide: https://stackoverflow.com/a/65094398/4590470 setup-test-matrix: @@ -157,7 +180,7 @@ jobs: # Fetch the pre-built MinIO image from the build job - name: Fetch built MinIO Image - uses: actions/cache@v6 + uses: actions/cache/restore@v6 id: minio-cache with: path: ./minio-image.tar @@ -176,13 +199,13 @@ jobs: node_image: "kindest/node:v${{ matrix.k8s }}" - name: Fetch built CLI id: cli-cache - uses: actions/cache@v6 + uses: actions/cache/restore@v6 with: path: ./_output/bin/linux/amd64/velero key: velero-cli-${{ github.event.pull_request.number }}-${{ github.sha }} - name: Fetch built Image id: image-cache - uses: actions/cache@v6 + uses: actions/cache/restore@v6 with: path: ./velero.tar key: velero-image-${{ github.event.pull_request.number }}-${{ github.sha }} diff --git a/changelogs/unreleased/9952-alliasgher b/changelogs/unreleased/9952-alliasgher new file mode 100644 index 000000000..0f96ef5da --- /dev/null +++ b/changelogs/unreleased/9952-alliasgher @@ -0,0 +1 @@ +Fix e2e-test-kind workflow cache miss on force push by saving build artifacts explicitly instead of relying on the actions/cache post-job hook