@@ -11,42 +11,29 @@ inputs:
1111runs :
1212 using : composite
1313 steps :
14- # Because all branches can refer to the repository's default branch's cache, we want it to
15- # persist as the de-facto fallback. However, it easily expunges in a matter of hours if
16- # nothing explicitly calls to it, so we work around that by ensuring it's *always* pinged
17- # prior to any cache operations.
18- - name : Ping main cache
14+ - name : Restore default cache
1915 uses : actions/cache/restore@v4
2016 id : cache-ping
2117 with :
2218 path : ${{ inputs.scons-cache }}
23- key : ${{ github.sha }} # Dummy key; we have to rely on the fallback value.
19+ key : ${{ inputs.cache-name }}|${{ github.event.repository.default_branch }}|${{ github.sha }}
2420 restore-keys : ${{ inputs.cache-name }}|${{ github.event.repository.default_branch }}
25- lookup-only : true
2621
27- # Fallback access isn't logged, so register an explicit cache-hit if found.
28- - name : Ping main cache (exact)
29- if : steps.cache-ping.outputs.cache-matched-key
30- uses : actions/cache/restore@v4
31- with :
32- path : ${{ inputs.scons-cache }}
33- key : ${{ steps.cache-ping.outputs.cache-matched-key }}
34- lookup-only : true
22+ - name : Log default cache files
23+ if : github.ref_name != github.event.repository.default_branch
24+ shell : sh
25+ run : find "${{ inputs.scons-cache }}" >> redundant.txt
3526
36- # We try to match an existing cache to restore from it. Each potential key is checked against
37- # all existing caches as a prefix. E.g. 'linux-template-minimal' would match any cache that
38- # starts with "linux-template-minimal", such as
39- # "linux-template-minimal|master|6588a4a29af1621086feac0117d5d4d37af957fd".
40- #
41- # We check these prefixes in this order:
42- # 1. An exact match for the base branch, reference name, and SHA hash.
43- # 2. A partial match for the same cache name and reference name.
44- # 3. A partial match for the same cache name and default branch name.
45- - name : Restore SCons cache directory
27+ # This is done after pulling the default cache so that PRs can integrate any potential changes
28+ # from the default branch without conflicting with whatever local changes were already made.
29+ - name : Restore local cache
4630 uses : actions/cache/restore@v4
31+ if : github.ref_name != github.event.repository.default_branch
4732 with :
4833 path : ${{ inputs.scons-cache }}
4934 key : ${{ inputs.cache-name }}|${{ github.ref_name }}|${{ github.sha }}
50- restore-keys : |
51- ${{ inputs.cache-name }}|${{ github.ref_name }}
52- ${{ inputs.cache-name }}|${{ github.event.repository.default_branch }}
35+ restore-keys : ${{ inputs.cache-name }}|${{ github.ref_name }}
36+
37+ - name : Store unix timestamp
38+ shell : sh
39+ run : echo "CACHE_TIMESTAMP=$(date +%s)" >> $GITHUB_ENV
0 commit comments