Skip to content

Commit eabe93d

Browse files
committed
chore(ci): refresh main ccache, scope PRs
Use cache/restore+save to roll main ccache on every commit. Save PR caches only for non-fork PRs with PR-scoped keys so main caches are not replaced by PR runs.
1 parent ba00aed commit eabe93d

File tree

1 file changed

+22
-2
lines changed

1 file changed

+22
-2
lines changed

.github/workflows/main.yml

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,14 @@ jobs:
3232
run: chown root:root .
3333

3434
- name: Restore ccache
35-
uses: actions/cache@v4
35+
id: ccache-restore
36+
uses: actions/cache/restore@v4
3637
with:
3738
path: ${{ env.CCACHE_DIR }}
3839
key: >
3940
ccache-${{ runner.os }}-${{ github.job }}-
40-
${{ hashFiles('**/CMakeLists.txt', '**/*.cmake') }}
41+
${{ hashFiles('**/CMakeLists.txt', '**/*.cmake', '.github/workflows/main.yml', 'build.sh') }}-
42+
${{ github.ref_name }}-${{ github.sha }}
4143
restore-keys: |
4244
ccache-${{ runner.os }}-${{ github.job }}-
4345
@@ -51,6 +53,24 @@ jobs:
5153
- name: ccache stats
5254
run: ccache -s || true
5355

56+
- name: Save ccache (main)
57+
if: github.ref == 'refs/heads/main'
58+
uses: actions/cache/save@v4
59+
with:
60+
path: ${{ env.CCACHE_DIR }}
61+
key: ${{ steps.ccache-restore.outputs.cache-primary-key }}
62+
63+
- name: Save ccache (PR, non-fork)
64+
if: >
65+
github.event_name == 'pull_request' &&
66+
github.event.pull_request.head.repo.fork == false
67+
uses: actions/cache/save@v4
68+
with:
69+
path: ${{ env.CCACHE_DIR }}
70+
key: >
71+
ccache-${{ runner.os }}-${{ github.job }}-
72+
${{ github.event.pull_request.number }}-${{ github.sha }}
73+
5474
- name: Testing
5575
run: ./test.sh --no-build
5676

0 commit comments

Comments
 (0)