From 3b2f209d8abf953a6e55a55ddcbe9550e7ca090e Mon Sep 17 00:00:00 2001 From: Olivier Mattelaer Date: Wed, 26 Aug 2026 11:14:38 +0200 Subject: [PATCH] warm_cache: only delete the caches of the ref it runs on The refresh jobs delete a cache before saving it, because actions/cache never overwrites an existing key. The delete was written without --ref, and `gh cache delete ` matches the key across every ref unless one is given, so a refresh deletes the copy held by every branch, not just its own. The save is ref scoped, so what comes back exists only under the ref that ran the workflow. That is fine on main, whose caches every branch can read, and destructive anywhere else: the shared copy is gone and the replacement is visible only to the branch that made it. With fail-on-cache-miss set on the restore actions, every other branch then fails before running a test. That is not hypothetical. A manual dispatch on madspin_branch left heptools-ubuntu24, delphes-ubuntu24 and root-ubuntu24 held solely by refs/heads/madspin_branch, and every branch except that one failed on Failed to restore cache entry. Exiting as fail-on-cache-miss is set. Input key: heptools-ubuntu24 The ref guard on the refresh job does not prevent it: workflow_dispatch and schedule are accepted from any branch, by design, so that a cache can be rebuilt without pushing to main. Pass --ref "${{ github.ref }}" to all fifteen live deletes (the split-out ufo/pip steps and the new root/delphes step included). A refresh now replaces only what its own ref holds, and a dispatch on a feature branch gives that branch its own copy while leaving the main-scoped one intact. The two commented-out deletes are left as they are. warm_cache never runs on a pull_request event -- only push, schedule and workflow_dispatch -- so github.ref is always refs/heads/ here. Note this does not repair the current state: a run on main is still needed to recreate the main-scoped caches that the madspin_branch dispatch removed. Co-Authored-By: Claude Opus 5 --- .github/workflows/warm_cache.yml | 30 +++++++++++++++--------------- 1 file changed, 15 insertions(+), 15 deletions(-) diff --git a/.github/workflows/warm_cache.yml b/.github/workflows/warm_cache.yml index 8d7d64f26..71218b5c6 100644 --- a/.github/workflows/warm_cache.yml +++ b/.github/workflows/warm_cache.yml @@ -50,25 +50,25 @@ jobs: - name: Delete heptools related cache if: inputs.reset_heptools == 'true' run: | - gh cache delete heptools-${{ env.CACHE_KEY }} --repo $GITHUB_REPOSITORY || true - gh cache delete lhapdf-${{ env.CACHE_KEY }} --repo $GITHUB_REPOSITORY || true - gh cache delete pythia8-${{ env.CACHE_KEY }} --repo $GITHUB_REPOSITORY || true - gh cache delete emela-${{ env.CACHE_KEY }} --repo $GITHUB_REPOSITORY || true - gh cache delete contur-${{ env.CACHE_KEY }} --repo $GITHUB_REPOSITORY || true + gh cache delete heptools-${{ env.CACHE_KEY }} --repo $GITHUB_REPOSITORY --ref "${{ github.ref }}" || true + gh cache delete lhapdf-${{ env.CACHE_KEY }} --repo $GITHUB_REPOSITORY --ref "${{ github.ref }}" || true + gh cache delete pythia8-${{ env.CACHE_KEY }} --repo $GITHUB_REPOSITORY --ref "${{ github.ref }}" || true + gh cache delete emela-${{ env.CACHE_KEY }} --repo $GITHUB_REPOSITORY --ref "${{ github.ref }}" || true + gh cache delete contur-${{ env.CACHE_KEY }} --repo $GITHUB_REPOSITORY --ref "${{ github.ref }}" || true env: GH_TOKEN: ${{ github.token }} - name: Delete ufo cache if: inputs.reset_ufo == 'true' run: | - gh cache delete ufomodel-${{ env.CACHE_KEY }} --repo $GITHUB_REPOSITORY || true + gh cache delete ufomodel-${{ env.CACHE_KEY }} --repo $GITHUB_REPOSITORY --ref "${{ github.ref }}" || true env: GH_TOKEN: ${{ github.token }} - name: Delete pip cache if: inputs.reset_pip == 'true' run: | - gh cache delete pip-numpy-${{ env.CACHE_KEY }} --repo $GITHUB_REPOSITORY || true + gh cache delete pip-numpy-${{ env.CACHE_KEY }} --repo $GITHUB_REPOSITORY --ref "${{ github.ref }}" || true env: GH_TOKEN: ${{ github.token }} @@ -78,8 +78,8 @@ jobs: - name: Delete root/delphes cache if: inputs.reset_delphes == 'true' run: | - gh cache delete root-${{ env.CACHE_KEY }} --repo $GITHUB_REPOSITORY || true - gh cache delete delphes-${{ env.CACHE_KEY }} --repo $GITHUB_REPOSITORY || true + gh cache delete root-${{ env.CACHE_KEY }} --repo $GITHUB_REPOSITORY --ref "${{ github.ref }}" || true + gh cache delete delphes-${{ env.CACHE_KEY }} --repo $GITHUB_REPOSITORY --ref "${{ github.ref }}" || true env: GH_TOKEN: ${{ github.token }} @@ -467,7 +467,7 @@ jobs: # sub-caches succeeded, so a partial rebuild never replaces a good cache. - name: Delete previous combined cache (so the fresh one can be saved) if: needs.pythia8_cache.result == 'success' && needs.emela_cache.result == 'success' && needs.contur_cache.result == 'success' && needs.looptools_cache.result == 'success' - run: gh cache delete heptools-${{ env.CACHE_KEY }} --repo $GITHUB_REPOSITORY || true + run: gh cache delete heptools-${{ env.CACHE_KEY }} --repo $GITHUB_REPOSITORY --ref "${{ github.ref }}" || true env: GH_TOKEN: ${{ github.token }} @@ -480,11 +480,11 @@ jobs: - name: Cleanup intermediate caches (only if all succeeded) if: needs.pythia8_cache.result == 'success' && needs.emela_cache.result == 'success' && needs.contur_cache.result == 'success' && needs.looptools_cache.result == 'success' run: | - gh cache delete lhapdf-${{ env.CACHE_KEY }} --repo $GITHUB_REPOSITORY || true - gh cache delete pythia8-${{ env.CACHE_KEY }} --repo $GITHUB_REPOSITORY || true - gh cache delete emela-${{ env.CACHE_KEY }} --repo $GITHUB_REPOSITORY || true - gh cache delete contur-${{ env.CACHE_KEY }} --repo $GITHUB_REPOSITORY || true - gh cache delete looptools-${{ env.CACHE_KEY }} --repo $GITHUB_REPOSITORY || true + gh cache delete lhapdf-${{ env.CACHE_KEY }} --repo $GITHUB_REPOSITORY --ref "${{ github.ref }}" || true + gh cache delete pythia8-${{ env.CACHE_KEY }} --repo $GITHUB_REPOSITORY --ref "${{ github.ref }}" || true + gh cache delete emela-${{ env.CACHE_KEY }} --repo $GITHUB_REPOSITORY --ref "${{ github.ref }}" || true + gh cache delete contur-${{ env.CACHE_KEY }} --repo $GITHUB_REPOSITORY --ref "${{ github.ref }}" || true + gh cache delete looptools-${{ env.CACHE_KEY }} --repo $GITHUB_REPOSITORY --ref "${{ github.ref }}" || true env: GH_TOKEN: ${{ github.token }}