Skip to content

Commit b3255af

Browse files
committed
Handle the fact the github actions cache does not allows updates
If there is a cache hit, there is never a save. Therefore, we need to always miss on the first run attempt, falling back hopefully to the previous run.
1 parent f129eac commit b3255af

File tree

2 files changed

+18
-12
lines changed

2 files changed

+18
-12
lines changed

.github/workflows/test-make.template.yaml

+9-6
Original file line numberDiff line numberDiff line change
@@ -212,13 +212,19 @@ jobs:
212212
id: hash
213213
run: |
214214
echo "hash=${{ hashFiles('**/*', '!.github/**/*', '!*.bazel', '!*.bzl', '!BUILD.*') }}" | tee -a $GITHUB_OUTPUT
215+
- name: COMPUTE PREVIOUS RUN ATTEPMT
216+
id: previous-attempt
217+
run: |
218+
PREVIOUS_ATTEMPT=$((${{ fromJSON(github.run_attempt) }} - 1))
219+
echo "number=$PREVIOUS_ATTEMPT" | tee -a $GITHUB_OUTPUT
215220
- name: MOUNT TEST RESULT CACHE
216221
uses: actions/[email protected]
217222
with:
218223
path: /home/runner/test-result-cache/
219-
key: ${{ runner.os }}-test-result-cache-${{ steps.hash.outputs.hash }}
224+
key: ${{ runner.os }}-test-result-cache-${{ steps.hash.outputs.hash }}-${{ github.run_number }}-${{ steps.previous-attempt.outputs.number }}
220225
restore-keys: |
221-
${{ runner.os }}-test-result-cache-
226+
${{ runner.os }}-test-result-cache-${{ steps.hash.outputs.hash }}-${{ github.run_number }}-
227+
${{ runner.os }}-test-result-cache-${{ steps.hash.outputs.hash }}-
222228
- name: PREP CACHE DIR
223229
run: |
224230
mkdir -p /home/runner/test-result-cache/${{ steps.hash.outputs.hash }}
@@ -250,10 +256,7 @@ jobs:
250256
uses: actions/[email protected]
251257
with:
252258
path: /home/runner/test-result-cache/
253-
key: ${{ runner.os }}-test-result-cache-${{ needs.load-test-result-cache.outputs.hash }}
254-
restore-keys: |
255-
${{ runner.os }}-test-result-cache-
256-
fail-on-cache-miss: true
259+
key: ${{ runner.os }}-test-result-cache-${{ needs.load-test-result-cache.outputs.hash }}-${{ github.run_number }}-${{ github.run_attempt }}
257260
save-always: true
258261
- name: UPDATE CACHE
259262
uses: actions/download-artifact@v4

.github/workflows/test-make.yaml

+9-6
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,19 @@ jobs:
3535
id: hash
3636
run: |
3737
echo "hash=${{ hashFiles('**/*', '!.github/**/*', '!*.bazel', '!*.bzl', '!BUILD.*') }}" | tee -a $GITHUB_OUTPUT
38+
- name: COMPUTE PREVIOUS RUN ATTEPMT
39+
id: previous-attempt
40+
run: |
41+
PREVIOUS_ATTEMPT=$((${{ fromJSON(github.run_attempt) }} - 1))
42+
echo "number=$PREVIOUS_ATTEMPT" | tee -a $GITHUB_OUTPUT
3843
- name: MOUNT TEST RESULT CACHE
3944
uses: actions/[email protected]
4045
with:
4146
path: /home/runner/test-result-cache/
42-
key: ${{ runner.os }}-test-result-cache-${{ steps.hash.outputs.hash }}
47+
key: ${{ runner.os }}-test-result-cache-${{ steps.hash.outputs.hash }}-${{ github.run_number }}-${{ steps.previous-attempt.outputs.number }}
4348
restore-keys: |
44-
${{ runner.os }}-test-result-cache-
49+
${{ runner.os }}-test-result-cache-${{ steps.hash.outputs.hash }}-${{ github.run_number }}-
50+
${{ runner.os }}-test-result-cache-${{ steps.hash.outputs.hash }}-
4551
- name: PREP CACHE DIR
4652
run: |
4753
mkdir -p /home/runner/test-result-cache/${{ steps.hash.outputs.hash }}
@@ -6937,10 +6943,7 @@ jobs:
69376943
uses: actions/[email protected]
69386944
with:
69396945
path: /home/runner/test-result-cache/
6940-
key: ${{ runner.os }}-test-result-cache-${{ needs.load-test-result-cache.outputs.hash }}
6941-
restore-keys: |
6942-
${{ runner.os }}-test-result-cache-
6943-
fail-on-cache-miss: true
6946+
key: ${{ runner.os }}-test-result-cache-${{ needs.load-test-result-cache.outputs.hash }}-${{ github.run_number }}-${{ github.run_attempt }}
69446947
save-always: true
69456948
- name: UPDATE CACHE
69466949
uses: actions/download-artifact@v4

0 commit comments

Comments
 (0)