Skip to content

Commit 5283cc8

Browse files
authored
ci: force save cache (#2738)
1 parent 632e3c9 commit 5283cc8

1 file changed

Lines changed: 14 additions & 1 deletion

File tree

.github/workflows/test_all.yml

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,9 @@ jobs:
164164
uses: actions/cache/restore@v5
165165
with:
166166
path: nimcache
167-
key: nimcache-test_all-${{ matrix.platform.os }}-${{ matrix.platform.cpu }}-${{ matrix.platform.cc }}-${{ matrix.nim.ref }}-${{ matrix.nim.memory_management }}
167+
key: nimcache-test_all-${{ matrix.platform.os }}-${{ matrix.platform.cpu }}-${{ matrix.platform.cc }}-${{ matrix.nim.ref }}-${{ matrix.nim.memory_management }}-${{ github.run_id }}
168+
restore-keys: |
169+
nimcache-test_all-${{ matrix.platform.os }}-${{ matrix.platform.cpu }}-${{ matrix.platform.cc }}-${{ matrix.nim.ref }}-${{ matrix.nim.memory_management }}
168170
169171
- name: Build test_all
170172
id: build-test-all
@@ -193,6 +195,17 @@ jobs:
193195
path: nimcache
194196
key: ${{ steps.nimcache-restore.outputs.cache-primary-key }}
195197

198+
- name: Prune old nimcache entries
199+
if: github.ref_name == 'master'
200+
env:
201+
GH_TOKEN: ${{ github.token }}
202+
run: |
203+
PREFIX="nimcache-test_all-${{ matrix.platform.os }}-${{ matrix.platform.cpu }}-${{ matrix.platform.cc }}-${{ matrix.nim.ref }}-${{ matrix.nim.memory_management }}"
204+
KEEP="${{ steps.nimcache-restore.outputs.cache-primary-key }}"
205+
gh cache list --ref "${{ github.ref }}" --limit 100 --json id,key \
206+
--jq ".[] | select(.key | startswith(\"$PREFIX\")) | select(.key != \"$KEEP\") | .id" \
207+
| xargs -r -n1 gh cache delete
208+
196209
- name: Run tests
197210
id: run-tests
198211
run: |

0 commit comments

Comments
 (0)