Skip to content

Commit c51527a

Browse files
authored
Fixup caching (#185)
1 parent bed8090 commit c51527a

2 files changed

Lines changed: 10 additions & 2 deletions

File tree

.github/workflows/cache-refresh.yml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,13 @@ jobs:
2828
env:
2929
GH_TOKEN: ${{ github.token }}
3030
run: |
31-
# List all ccache-* cache keys, strip the run_id suffix to deduplicate by flavor/arch.
31+
# List main-scoped ccache-* cache keys, strip the run_id suffix to deduplicate
32+
# by flavor/arch. We specifically skip non-main branches, becuse we only want to save/restore
33+
# from main - in GH, PR branches can use `main` caches, but main cannot see PR branch caches,
34+
# and saving duplicated PR branch caches counts against our 10GB github limit
3235
matrix=$(gh api "/repos/${{ github.repository }}/actions/caches" --paginate \
3336
--jq '[.actions_caches[]
34-
| select(.key | startswith("ccache-"))
37+
| select(.ref == "refs/heads/main" and (.key | startswith("ccache-")))
3538
| {prefix: (.key | gsub("-[0-9]+$"; ""))}]
3639
| unique_by(.prefix)
3740
| {entry: .}')

.github/workflows/matrix.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,11 @@ jobs:
123123
compression-level: 0
124124
retention-days: 1
125125
- name: save ccache
126+
# Only save from main. GH's per-repo 10GB cache pool is shared across all refs,
127+
# so PR-scoped saves evict main-scoped entries via LRU - and main is the only ref
128+
# whose entries the next build can actually restore. PRs still benefit because
129+
# they will fallthrough to/inherit parent branch caches
130+
if: github.ref == 'refs/heads/main'
126131
uses: actions/cache/save@27d5ce7f107fe9357f9df03efb73ab90386fccae # v5.0.2
127132
with:
128133
path: ~/.cache/kernel-ccache

0 commit comments

Comments
 (0)