@@ -217,14 +217,21 @@ jobs:
217
217
- name : Checkout repository
218
218
uses : actions/checkout@v3
219
219
220
- - name : Compilation cache
221
- uses : actions/cache@v3
222
- with :
223
- # It looks like this path needs to be hard-coded.
224
- path : C:/msys64/home/runneradmin/.ccache
220
+ - name : Prepare ccache
221
+ # Get cache location of ccache
222
+ # Create key that is used in action/cache/restore and action/cache/save steps
223
+ id : ccache-prepare
224
+ run : |
225
+ echo "ccachedir=$(cygpath -m $(ccache -k cache_dir))" >> $GITHUB_OUTPUT
225
226
# We include the commit sha in the cache key, as new cache entries are
226
227
# only created if there is no existing entry for the key yet.
227
- key : ccache-msys2-${{ matrix.msystem }}-${{ matrix.idx }}-${{ matrix.build-type }}-${{ github.ref }}-${{ github.sha }}
228
+ echo "key=ccache-msys2-${{ matrix.msystem }}-${{ matrix.idx }}-${{ matrix.build-type }}-${{ github.ref }}-${{ github.sha }}" >> $GITHUB_OUTPUT
229
+
230
+ - name : Restore ccache
231
+ uses : actions/cache/restore@v3
232
+ with :
233
+ path : ${{ steps.ccache-prepare.outputs.ccachedir }}
234
+ key : ${{ steps.ccache-prepare.outputs.key }}
228
235
# Restore a matching ccache cache entry. Prefer same branch.
229
236
restore-keys : |
230
237
ccache-msys2-${{ matrix.msystem }}-${{ matrix.idx }}-${{ matrix.build-type }}-${{ github.ref }}
@@ -234,9 +241,10 @@ jobs:
234
241
# Limit the maximum size and switch on compression to avoid exceeding the total disk or cache quota.
235
242
run : |
236
243
which ccache
237
- test -d ~/.ccache || mkdir -p ~/.ccache
238
- echo "max_size = 250M" > ~/.ccache/ccache.conf
239
- echo "compression = true" >> ~/.ccache/ccache.conf
244
+ test -d ${{ steps.ccache-prepare.outputs.ccachedir }} || mkdir -p ${{ steps.ccache-prepare.outputs.ccachedir }}
245
+ echo "max_size = 250M" > ${{ steps.ccache-prepare.outputs.ccachedir }}/ccache.conf
246
+ echo "compression = true" >> ${{ steps.ccache-prepare.outputs.ccachedir }}/ccache.conf
247
+ ccache -p
240
248
ccache -s
241
249
echo $HOME
242
250
cygpath -w $HOME
@@ -264,6 +272,13 @@ jobs:
264
272
continue-on-error : true
265
273
run : ccache -s
266
274
275
+ - name : Save ccache
276
+ # Save the cache after we are done (successfully) building
277
+ uses : actions/cache/save@v3
278
+ with :
279
+ path : ${{ steps.ccache-prepare.outputs.ccachedir }}
280
+ key : ${{ steps.ccache-prepare.outputs.key }}
281
+
267
282
- name : Run tests
268
283
timeout-minutes : 60
269
284
run : cd build && ctest
0 commit comments