Skip to content

Commit 010a978

Browse files
committed
Once again, the actions caches are immutable
therefore all dimensions of the matrix must be included in the key, otherwise the first to finish within the matrix, wins
1 parent e9d795f commit 010a978

File tree

2 files changed

+1212
-1208
lines changed

2 files changed

+1212
-1208
lines changed

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

+28-24
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@
99
#@ return names
1010
#@ end
1111

12+
#@ def cache_prefix(name):
13+
#@ return "${{ runner.os }}-test-result-cache-${{ needs.xref.outputs.hash }}-"+name+"-${{ matrix.metadata_store }}-${{ matrix.otp_version }}"
14+
#@ end
15+
1216
#@ def test_plugin(name, needs, suites):
1317
test-(@= name @):
1418
name: Test (@= name @)
@@ -24,7 +28,7 @@
2428
- khepri
2529
timeout-minutes: 180
2630
env:
27-
SUCCESS_PATH: /home/runner/test-result-cache/(@= name @)/${{ matrix.metadata_store }}/${{ matrix.otp_version }}
31+
CACHE_PATH: /home/runner/test-result-cache
2832
steps:
2933
#@ if name == "rabbit":
3034
- name: INSTALL DOTNET
@@ -46,12 +50,12 @@
4650
- name: RESTORE TEST RESULT CACHE
4751
uses: actions/cache/restore@v4
4852
with:
49-
path: /home/runner/test-result-cache/
50-
key: ${{ runner.os }}-test-result-cache-${{ needs.xref.outputs.hash }}-(@= name @)-${{ github.run_number }}-${{ github.run_attempt }}
53+
path: ${{ env.CACHE_PATH }}
54+
key: (@= cache_prefix(name) @)-${{ github.run_number }}-${{ github.run_attempt }}
5155
restore-keys: |
52-
${{ runner.os }}-test-result-cache-${{ needs.xref.outputs.hash }}-(@= name @)-${{ github.run_number }}-${{ steps.previous-attempt-outputs.number }}
53-
${{ runner.os }}-test-result-cache-${{ needs.xref.outputs.hash }}-(@= name @)-${{ github.run_number }}-
54-
${{ runner.os }}-test-result-cache-${{ needs.xref.outputs.hash }}-(@= name @)-
56+
(@= cache_prefix(name) @)-${{ github.run_number }}-${{ steps.previous-attempt-outputs.number }}
57+
(@= cache_prefix(name) @)-${{ github.run_number }}-
58+
(@= cache_prefix(name) @)-
5559
- name: PRINT CACHED RESULTS
5660
run: |
5761
set -x
@@ -64,27 +68,27 @@
6468
elixir-version: 1.15
6569
- name: PREPARE
6670
run: |
67-
mkdir -p ${{ env.SUCCESS_PATH }}
71+
mkdir -p ${{ env.CACHE_PATH }}
6872
- name: DIALYZE
6973
run: |
70-
if [[ -f ${{ env.SUCCESS_PATH }}/dialyze ]]; then
74+
if [[ -f ${{ env.CACHE_PATH }}/dialyze ]]; then
7175
echo "dialyze already passed for this key ${{ needs.xref.outputs.hash }}"
7276
else
7377
make -C deps/(@= name @) \
7478
dialyze \
7579
RABBITMQ_METADATA_STORE=${{ matrix.metadata_store }}
76-
touch ${{ env.SUCCESS_PATH }}/dialyze
80+
touch ${{ env.CACHE_PATH }}/dialyze
7781
fi
7882
continue-on-error: #@ name == "rabbitmq_ct_helpers" or name == "trust_store_http"
7983
- name: EUNIT
8084
run: |
81-
if [[ -f ${{ env.SUCCESS_PATH }}/eunit ]]; then
85+
if [[ -f ${{ env.CACHE_PATH }}/eunit ]]; then
8286
echo "eunit already passed for this key ${{ needs.xref.outputs.hash }}"
8387
else
8488
make -C deps/(@= name @) \
8589
eunit \
8690
RABBITMQ_METADATA_STORE=${{ matrix.metadata_store }}
87-
touch ${{ env.SUCCESS_PATH }}/eunit
91+
touch ${{ env.CACHE_PATH }}/eunit
8892
fi
8993
#@ for suite in suites:
9094
- name: CT (@= suite @)
@@ -94,20 +98,20 @@
9498
#@ end
9599
#@ end
96100
run: |
97-
if [[ -f ${{ env.SUCCESS_PATH }}/ct-(@= suite @) ]]; then
101+
if [[ -f ${{ env.CACHE_PATH }}/ct-(@= suite @) ]]; then
98102
echo "ct-(@= suite @) already passed for this key ${{ needs.xref.outputs.hash }}"
99103
else
100104
make -C deps/(@= name @) \
101105
ct-(@= suite @) \
102106
RABBITMQ_METADATA_STORE=${{ matrix.metadata_store }}
103-
touch ${{ env.SUCCESS_PATH }}/ct-(@= suite @)
107+
touch ${{ env.CACHE_PATH }}/ct-(@= suite @)
104108
fi
105109
#@ end
106110
- name: SAVE TEST RESULT CACHE
107111
uses: actions/cache/save@v4
108112
with:
109113
path: /home/runner/test-result-cache/
110-
key: ${{ runner.os }}-test-result-cache-${{ needs.xref.outputs.hash }}-(@= name @)-${{ github.run_number }}-${{ github.run_attempt }}
114+
key: (@= cache_prefix(name) @)-${{ github.run_number }}-${{ github.run_attempt }}
111115
- name: UPLOAD TEST ARTIFACTS
112116
if: always()
113117
uses: actions/[email protected]
@@ -131,7 +135,7 @@
131135
- khepri
132136
timeout-minutes: 20
133137
env:
134-
SUCCESS_PATH: /home/runner/test-result-cache/rabbitmq_cli/${{ matrix.metadata_store }}/${{ matrix.otp_version }}
138+
CACHE_PATH: /home/runner/test-result-cache
135139
steps:
136140
- name: RESTORE BUILT REPO
137141
uses: actions/cache@v4
@@ -147,12 +151,12 @@
147151
- name: RESTORE TEST RESULT CACHE
148152
uses: actions/cache/restore@v4
149153
with:
150-
path: /home/runner/test-result-cache/
151-
key: ${{ runner.os }}-test-result-cache-${{ needs.xref.outputs.hash }}-rabbitmq_cli-${{ github.run_number }}-${{ github.run_attempt }}
154+
path: ${{ env.CACHE_PATH }}
155+
key: (@= cache_prefix('rabbitmq_cli') @)-${{ github.run_number }}-${{ github.run_attempt }}
152156
restore-keys: |
153-
${{ runner.os }}-test-result-cache-${{ needs.xref.outputs.hash }}-rabbitmq_cli-${{ github.run_number }}-${{ steps.previous-attempt-outputs.number }}
154-
${{ runner.os }}-test-result-cache-${{ needs.xref.outputs.hash }}-rabbitmq_cli-${{ github.run_number }}-
155-
${{ runner.os }}-test-result-cache-${{ needs.xref.outputs.hash }}-rabbitmq_cli-
157+
(@= cache_prefix('rabbitmq_cli') @)-${{ github.run_number }}-${{ steps.previous-attempt-outputs.number }}
158+
(@= cache_prefix('rabbitmq_cli') @)-${{ github.run_number }}-
159+
(@= cache_prefix('rabbitmq_cli') @)-
156160
- name: PRINT CACHED RESULTS
157161
run: |
158162
set -x
@@ -165,23 +169,23 @@
165169
elixir-version: 1.15
166170
- name: PREPARE
167171
run: |
168-
mkdir -p ${{ env.SUCCESS_PATH }}
172+
mkdir -p ${{ env.CACHE_PATH }}
169173
- name: TEST
170174
id: test
171175
run: |
172-
if [[ -f ${{ env.SUCCESS_PATH }}/checks ]]; then
176+
if [[ -f ${{ env.CACHE_PATH }}/checks ]]; then
173177
echo "checks already passed for this key ${{ needs.xref.outputs.hash }}"
174178
else
175179
make -C deps/rabbitmq_cli \
176180
checks \
177181
RABBITMQ_METADATA_STORE=${{ matrix.metadata_store }}
178-
touch ${{ env.SUCCESS_PATH }}/checks
182+
touch ${{ env.CACHE_PATH }}/checks
179183
fi
180184
- name: SAVE TEST RESULT CACHE
181185
uses: actions/cache/save@v4
182186
with:
183187
path: /home/runner/test-result-cache/
184-
key: ${{ runner.os }}-test-result-cache-${{ needs.xref.outputs.hash }}-rabbitmq_cli-${{ github.run_number }}-${{ github.run_attempt }}
188+
key: (@= cache_prefix('rabbitmq_cli') @)-${{ github.run_number }}-${{ github.run_attempt }}
185189
- name: UPLOAD TEST ARTIFACTS
186190
if: always()
187191
uses: actions/[email protected]

0 commit comments

Comments
 (0)