From d36dea8b85b3d3a296fb2493b1b9b5ed21d31646 Mon Sep 17 00:00:00 2001 From: Benjamin Leggett Date: Fri, 22 May 2026 15:40:51 -0400 Subject: [PATCH] Fixup caching --- .github/workflows/cache-refresh.yml | 7 +++++-- .github/workflows/matrix.yml | 5 +++++ 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/.github/workflows/cache-refresh.yml b/.github/workflows/cache-refresh.yml index afe6a09..bc6de88 100644 --- a/.github/workflows/cache-refresh.yml +++ b/.github/workflows/cache-refresh.yml @@ -28,10 +28,13 @@ jobs: env: GH_TOKEN: ${{ github.token }} run: | - # List all ccache-* cache keys, strip the run_id suffix to deduplicate by flavor/arch. + # List main-scoped ccache-* cache keys, strip the run_id suffix to deduplicate + # by flavor/arch. We specifically skip non-main branches, becuse we only want to save/restore + # from main - in GH, PR branches can use `main` caches, but main cannot see PR branch caches, + # and saving duplicated PR branch caches counts against our 10GB github limit matrix=$(gh api "/repos/${{ github.repository }}/actions/caches" --paginate \ --jq '[.actions_caches[] - | select(.key | startswith("ccache-")) + | select(.ref == "refs/heads/main" and (.key | startswith("ccache-"))) | {prefix: (.key | gsub("-[0-9]+$"; ""))}] | unique_by(.prefix) | {entry: .}') diff --git a/.github/workflows/matrix.yml b/.github/workflows/matrix.yml index 0616f50..67b3943 100644 --- a/.github/workflows/matrix.yml +++ b/.github/workflows/matrix.yml @@ -123,6 +123,11 @@ jobs: compression-level: 0 retention-days: 1 - name: save ccache + # Only save from main. GH's per-repo 10GB cache pool is shared across all refs, + # so PR-scoped saves evict main-scoped entries via LRU - and main is the only ref + # whose entries the next build can actually restore. PRs still benefit because + # they will fallthrough to/inherit parent branch caches + if: github.ref == 'refs/heads/main' uses: actions/cache/save@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.2 with: path: ~/.cache/kernel-ccache