Skip to content

Commit 55e75a6

Browse files
committed
Save GitHub cache on failure as well
The cache contains built dependencies. When job fails due to compilation error in the project itself, or due to test failure, next one will have to recompile the same dependencies all over again, because they were not cached for failed job. This commit saves cache unconditionally, using recently introduced GitHub action 'actions/cache/save@v3'.
1 parent aebe30d commit 55e75a6

File tree

12 files changed

+112
-26
lines changed

12 files changed

+112
-26
lines changed

.github/workflows/haskell-ci.yml

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,7 @@ jobs:
148148
run: |
149149
$CABAL v2-update -v
150150
- name: cache (tools)
151-
uses: actions/cache@v2
151+
uses: actions/cache/restore@v3
152152
with:
153153
key: ${{ runner.os }}-${{ matrix.compiler }}-tools-ddfe230f
154154
path: ~/.haskell-ci-tools
@@ -174,8 +174,14 @@ jobs:
174174
run: |
175175
if [ $((HCNUMVER < 90000)) -ne 0 ] ; then $CABAL --store-dir=$HOME/.haskell-ci-tools/store v2-install $ARG_COMPILER --ignore-project -j2 doctest --constraint='doctest ^>=0.20' ; fi
176176
if [ $((HCNUMVER < 90000)) -ne 0 ] ; then doctest --version ; fi
177+
- name: save cache (tools)
178+
uses: actions/cache/save@v3
179+
if: always()
180+
with:
181+
key: ${{ runner.os }}-${{ matrix.compiler }}-tools-ddfe230f
182+
path: ~/.haskell-ci-tools
177183
- name: checkout
178-
uses: actions/checkout@v2
184+
uses: actions/checkout@v3
179185
with:
180186
path: source
181187
- name: initial cabal.project for sdist
@@ -226,8 +232,8 @@ jobs:
226232
run: |
227233
$CABAL v2-build $ARG_COMPILER $ARG_TESTS $ARG_BENCH --dry-run all
228234
cabal-plan
229-
- name: cache
230-
uses: actions/cache@v2
235+
- name: restore cache
236+
uses: actions/cache/restore@v3
231237
with:
232238
key: ${{ runner.os }}-${{ matrix.compiler }}-${{ github.sha }}
233239
path: ~/.cabal/store
@@ -277,3 +283,9 @@ jobs:
277283
if [ $((HCNUMVER < 80400)) -ne 0 ] ; then $CABAL v2-build $ARG_COMPILER --disable-tests --disable-benchmarks --constraint='deepseq ==1.4.*' --constraint='binary installed' --dependencies-only -j2 all ; fi
278284
if [ $((HCNUMVER < 80400)) -ne 0 ] ; then $CABAL v2-build $ARG_COMPILER --disable-tests --disable-benchmarks --constraint='deepseq ==1.4.*' --constraint='binary installed' all ; fi
279285
if [ $((HCNUMVER < 80400)) -ne 0 ] ; then $CABAL v2-haddock --haddock-all $ARG_COMPILER --with-haddock $HADDOCK --disable-tests --disable-benchmarks --constraint='deepseq ==1.4.*' --constraint='binary installed' all ; fi
286+
- name: save cache
287+
uses: actions/cache/save@v3
288+
if: always()
289+
with:
290+
key: ${{ runner.os }}-${{ matrix.compiler }}-${{ github.sha }}
291+
path: ~/.cabal/store

fixtures/all-versions.github

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -474,8 +474,8 @@ jobs:
474474
run: |
475475
$CABAL v2-build $ARG_COMPILER $ARG_TESTS $ARG_BENCH --dry-run all
476476
cabal-plan
477-
- name: cache
478-
uses: actions/cache@v3
477+
- name: restore cache
478+
uses: actions/cache/restore@v3
479479
with:
480480
key: ${{ runner.os }}-${{ matrix.compiler }}-${{ github.sha }}
481481
path: ~/.cabal/store
@@ -504,3 +504,9 @@ jobs:
504504
run: |
505505
rm -f cabal.project.local
506506
$CABAL v2-build $ARG_COMPILER --disable-tests --disable-benchmarks all
507+
- name: save cache
508+
uses: actions/cache/save@v3
509+
if: always()
510+
with:
511+
key: ${{ runner.os }}-${{ matrix.compiler }}-${{ github.sha }}
512+
path: ~/.cabal/store

fixtures/copy-fields-all.github

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -349,8 +349,8 @@ jobs:
349349
run: |
350350
$CABAL v2-build $ARG_COMPILER $ARG_TESTS $ARG_BENCH --dry-run all
351351
cabal-plan
352-
- name: cache
353-
uses: actions/cache@v3
352+
- name: restore cache
353+
uses: actions/cache/restore@v3
354354
with:
355355
key: ${{ runner.os }}-${{ matrix.compiler }}-${{ github.sha }}
356356
path: ~/.cabal/store
@@ -385,3 +385,9 @@ jobs:
385385
run: |
386386
rm -f cabal.project.local
387387
$CABAL v2-build $ARG_COMPILER --disable-tests --disable-benchmarks all
388+
- name: save cache
389+
uses: actions/cache/save@v3
390+
if: always()
391+
with:
392+
key: ${{ runner.os }}-${{ matrix.compiler }}-${{ github.sha }}
393+
path: ~/.cabal/store

fixtures/copy-fields-none.github

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -338,8 +338,8 @@ jobs:
338338
run: |
339339
$CABAL v2-build $ARG_COMPILER $ARG_TESTS $ARG_BENCH --dry-run all
340340
cabal-plan
341-
- name: cache
342-
uses: actions/cache@v3
341+
- name: restore cache
342+
uses: actions/cache/restore@v3
343343
with:
344344
key: ${{ runner.os }}-${{ matrix.compiler }}-${{ github.sha }}
345345
path: ~/.cabal/store
@@ -374,3 +374,9 @@ jobs:
374374
run: |
375375
rm -f cabal.project.local
376376
$CABAL v2-build $ARG_COMPILER --disable-tests --disable-benchmarks all
377+
- name: save cache
378+
uses: actions/cache/save@v3
379+
if: always()
380+
with:
381+
key: ${{ runner.os }}-${{ matrix.compiler }}-${{ github.sha }}
382+
path: ~/.cabal/store

fixtures/copy-fields-some.github

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -341,8 +341,8 @@ jobs:
341341
run: |
342342
$CABAL v2-build $ARG_COMPILER $ARG_TESTS $ARG_BENCH --dry-run all
343343
cabal-plan
344-
- name: cache
345-
uses: actions/cache@v3
344+
- name: restore cache
345+
uses: actions/cache/restore@v3
346346
with:
347347
key: ${{ runner.os }}-${{ matrix.compiler }}-${{ github.sha }}
348348
path: ~/.cabal/store
@@ -377,3 +377,9 @@ jobs:
377377
run: |
378378
rm -f cabal.project.local
379379
$CABAL v2-build $ARG_COMPILER --disable-tests --disable-benchmarks all
380+
- name: save cache
381+
uses: actions/cache/save@v3
382+
if: always()
383+
with:
384+
key: ${{ runner.os }}-${{ matrix.compiler }}-${{ github.sha }}
385+
path: ~/.cabal/store

fixtures/empty-line.github

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -357,8 +357,8 @@ jobs:
357357
run: |
358358
$CABAL v2-build $ARG_COMPILER $ARG_TESTS $ARG_BENCH --dry-run all
359359
cabal-plan
360-
- name: cache
361-
uses: actions/cache@v3
360+
- name: restore cache
361+
uses: actions/cache/restore@v3
362362
with:
363363
key: ${{ runner.os }}-${{ matrix.compiler }}-${{ github.sha }}
364364
path: ~/.cabal/store
@@ -393,3 +393,9 @@ jobs:
393393
run: |
394394
rm -f cabal.project.local
395395
$CABAL v2-build $ARG_COMPILER --disable-tests --disable-benchmarks all
396+
- name: save cache
397+
uses: actions/cache/save@v3
398+
if: always()
399+
with:
400+
key: ${{ runner.os }}-${{ matrix.compiler }}-${{ github.sha }}
401+
path: ~/.cabal/store

fixtures/enabled-jobs.github

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -384,8 +384,8 @@ jobs:
384384
run: |
385385
$CABAL v2-build $ARG_COMPILER $ARG_TESTS $ARG_BENCH --dry-run all
386386
cabal-plan
387-
- name: cache
388-
uses: actions/cache@v3
387+
- name: restore cache
388+
uses: actions/cache/restore@v3
389389
with:
390390
key: ${{ runner.os }}-${{ matrix.compiler }}-${{ github.sha }}
391391
path: ~/.cabal/store
@@ -414,3 +414,9 @@ jobs:
414414
run: |
415415
rm -f cabal.project.local
416416
$CABAL v2-build $ARG_COMPILER --disable-tests --disable-benchmarks all
417+
- name: save cache
418+
uses: actions/cache/save@v3
419+
if: always()
420+
with:
421+
key: ${{ runner.os }}-${{ matrix.compiler }}-${{ github.sha }}
422+
path: ~/.cabal/store

fixtures/irc-channels.github

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -347,8 +347,8 @@ jobs:
347347
run: |
348348
$CABAL v2-build $ARG_COMPILER $ARG_TESTS $ARG_BENCH --dry-run all
349349
cabal-plan
350-
- name: cache
351-
uses: actions/cache@v3
350+
- name: restore cache
351+
uses: actions/cache/restore@v3
352352
with:
353353
key: ${{ runner.os }}-${{ matrix.compiler }}-${{ github.sha }}
354354
path: ~/.cabal/store
@@ -377,3 +377,9 @@ jobs:
377377
run: |
378378
rm -f cabal.project.local
379379
$CABAL v2-build $ARG_COMPILER --disable-tests --disable-benchmarks all
380+
- name: save cache
381+
uses: actions/cache/save@v3
382+
if: always()
383+
with:
384+
key: ${{ runner.os }}-${{ matrix.compiler }}-${{ github.sha }}
385+
path: ~/.cabal/store

fixtures/messy.github

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -358,8 +358,8 @@ jobs:
358358
run: |
359359
$CABAL v2-build $ARG_COMPILER $ARG_TESTS $ARG_BENCH --dry-run all
360360
cabal-plan
361-
- name: cache
362-
uses: actions/cache@v3
361+
- name: restore cache
362+
uses: actions/cache/restore@v3
363363
with:
364364
key: ${{ runner.os }}-${{ matrix.compiler }}-${{ github.sha }}
365365
path: ~/.cabal/store
@@ -394,3 +394,9 @@ jobs:
394394
run: |
395395
rm -f cabal.project.local
396396
$CABAL v2-build $ARG_COMPILER --disable-tests --disable-benchmarks all
397+
- name: save cache
398+
uses: actions/cache/save@v3
399+
if: always()
400+
with:
401+
key: ${{ runner.os }}-${{ matrix.compiler }}-${{ github.sha }}
402+
path: ~/.cabal/store

fixtures/psql.github

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -326,8 +326,8 @@ jobs:
326326
run: |
327327
$CABAL v2-build $ARG_COMPILER $ARG_TESTS $ARG_BENCH --dry-run all
328328
cabal-plan
329-
- name: cache
330-
uses: actions/cache@v3
329+
- name: restore cache
330+
uses: actions/cache/restore@v3
331331
with:
332332
key: ${{ runner.os }}-${{ matrix.compiler }}-${{ github.sha }}
333333
path: ~/.cabal/store
@@ -356,3 +356,9 @@ jobs:
356356
run: |
357357
rm -f cabal.project.local
358358
$CABAL v2-build $ARG_COMPILER --disable-tests --disable-benchmarks all
359+
- name: save cache
360+
uses: actions/cache/save@v3
361+
if: always()
362+
with:
363+
key: ${{ runner.os }}-${{ matrix.compiler }}-${{ github.sha }}
364+
path: ~/.cabal/store

0 commit comments

Comments
 (0)