Skip to content

Commit 25666de

Browse files
committed
CI: Add strict cache key matching on master builds
1 parent 6534a24 commit 25666de

File tree

3 files changed

+11
-2
lines changed

3 files changed

+11
-2
lines changed

.github/workflows/build-fp-modules.yaml

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ on:
3434
description: Size of the cache uncompressed
3535
type: string
3636
required: true
37+
strict-cache-key-matching:
38+
description: Only allow to restore a specific cache or build from scratch if no match
39+
default: false
40+
type: boolean
3741
env:
3842
PROJECT_OPTIONS: target_arch ${{ inputs.arch }}
3943
jobs:
@@ -65,8 +69,7 @@ jobs:
6569
with:
6670
server-quota-high: ${{ inputs.max-uncompressed-cache-size }}
6771
key: ${{ inputs.cache-key-prefix }}${{ inputs.cache-key-hash }}
68-
restore-keys: |
69-
${{ inputs.cache-key-prefix }}
72+
restore-keys: ${{ inputs.strict-cache-key-matching && null || inputs.cache-key-prefix }}
7073

7174
- name: Build ${{ inputs.element }}
7275
id: build

.github/workflows/build-project.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,10 @@ on:
1414
description: Re-upload the cache to avoid automatic eviction
1515
default: false
1616
type: boolean
17+
strict-cache-strategy:
18+
description: Build from scratch if no matching cache is found
19+
default: false
20+
type: boolean
1721
jobs:
1822
prepare:
1923
name: Prepare cache key hash
@@ -48,6 +52,7 @@ jobs:
4852
arch: ${{ matrix.arch }}
4953
upload-artifacts: ${{ inputs.upload-artifacts }}
5054
reupload-cache: ${{ inputs.reupload-cache }}
55+
strict-cache-key-matching: ${{ inputs.strict-cache-strategy }}
5156
max-uncompressed-cache-size: 2G
5257

5358
fp-qt:

.github/workflows/push.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ jobs:
1717
uses: ./.github/workflows/build-project.yaml
1818
with:
1919
arches: '["x86_64", "aarch64"]'
20+
strict-cache-strategy: ${{ github.ref == 'refs/heads/master' }}
2021
upload-artifacts: ${{ github.ref == 'refs/heads/master' }}
2122

2223
check-code:

0 commit comments

Comments
 (0)