From 4942c9b914d45dae9aadf193c97ddeb4acc8a466 Mon Sep 17 00:00:00 2001 From: Ivan Gabaldon Date: Thu, 7 Aug 2025 16:53:37 +0200 Subject: [PATCH] [fix] ci: cache is not overwritten (#5089) Due to current limitations of `actions/cache`, the cache cannot be overwritten. In our case, we need to accumulate cached wheels from different architectures. To solve this, we simply delete the key before storing the cache again. --- .github/workflows/container.yml | 24 ++++++++++++++++++++++-- 1 file changed, 22 insertions(+), 2 deletions(-) diff --git a/.github/workflows/container.yml b/.github/workflows/container.yml index 496130edc..6369f1b7a 100644 --- a/.github/workflows/container.yml +++ b/.github/workflows/container.yml @@ -121,6 +121,8 @@ jobs: permissions: # Organization GHCR packages: write + # Clean key cache step + actions: write outputs: docker_tag: ${{ steps.build.outputs.docker_tag }} @@ -144,8 +146,9 @@ jobs: restore-keys: "python-${{ env.PYTHON_VERSION }}-${{ runner.arch }}-" path: "./local/" - - name: Setup cache container mounts - uses: actions/cache@v4 + - name: Restore cache container mounts + id: cache-container-mounts + uses: actions/cache/restore@v4 with: key: "container-mounts-${{ hashFiles('./container/*.dockerfile') }}" restore-keys: "container-mounts-" @@ -153,6 +156,14 @@ jobs: /var/tmp/buildah-cache/ /var/tmp/buildah-cache-*/ + # https://github.com/actions/cache/pull/1308 + - if: steps.cache-container-mounts.outputs.cache-hit == 'true' + name: Clean key cache container mounts + continue-on-error: true + env: + GH_TOKEN: "${{ secrets.GITHUB_TOKEN }}" + run: gh cache delete container-mounts-${{ hashFiles('./container/*.dockerfile') }} + - if: ${{ matrix.emulation }} name: Setup QEMU uses: docker/setup-qemu-action@v3 @@ -170,6 +181,15 @@ jobs: OVERRIDE_ARCH: "${{ matrix.arch }}" run: make podman.build + - if: always() + name: Save cache container mounts + uses: actions/cache/save@v4 + with: + key: "container-mounts-${{ hashFiles('./container/*.dockerfile') }}" + path: | + /var/tmp/buildah-cache/ + /var/tmp/buildah-cache-*/ + test: name: Test (${{ matrix.arch }}) runs-on: ${{ matrix.os }}