@@ -11,24 +11,42 @@ inputs:
11
11
runs :
12
12
using : composite
13
13
steps :
14
- - name : Restore SCons cache directory
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
15
19
uses : actions/cache/restore@v4
20
+ id : cache-ping
16
21
with :
17
22
path : ${{ inputs.scons-cache }}
18
- key : ${{ inputs.cache-name }}-${{ env.GODOT_BASE_BRANCH }}-${{ github.ref }}-${{ github.sha }}
23
+ key : ${{ github.sha }} # Dummy key; we have to rely on the fallback value.
24
+ restore-keys : ${{ inputs.cache-name }}|${{ github.event.repository.default_branch }}
25
+ lookup-only : true
19
26
20
- # We try to match an existing cache to restore from it. Each potential key is checked against
21
- # all existing caches as a prefix. E.g. 'linux-template-minimal' would match any cache that
22
- # starts with "linux-template-minimal", such as "linux-template-minimal-master-refs/heads/master-6588a4a29af1621086feac0117d5d4d37af957fd".
23
- #
24
- # We check these prefixes in this order:
25
- #
26
- # 1. The exact match, including the base branch, the commit reference, and the SHA hash of the commit.
27
- # 2. A partial match for the same base branch and the same commit reference.
28
- # 3. A partial match for the same base branch and the base branch commit reference.
29
- # 4. A partial match for the same base branch only (not ideal, matches any PR with the same base branch).
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
30
35
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
46
+ uses : actions/cache/restore@v4
47
+ with :
48
+ path : ${{ inputs.scons-cache }}
49
+ key : ${{ inputs.cache-name }}|${{ github.ref_name }}|${{ github.sha }}
31
50
restore-keys : |
32
- ${{ inputs.cache-name }}-${{ env.GODOT_BASE_BRANCH }}-${{ github.ref }}
33
- ${{ inputs.cache-name }}-${{ env.GODOT_BASE_BRANCH }}-refs/heads/${{ env.GODOT_BASE_BRANCH }}
34
- ${{ inputs.cache-name }}-${{ env.GODOT_BASE_BRANCH }}
51
+ ${{ inputs.cache-name }}|${{ github.ref_name }}
52
+ ${{ inputs.cache-name }}|${{ github.event.repository.default_branch }}
0 commit comments