Skip to content

Commit c109133

Browse files
committed
CI caching: split restore and save into separate steps
1 parent a572c66 commit c109133

File tree

3 files changed

+102
-27
lines changed

3 files changed

+102
-27
lines changed

.github/workflows/test-linux.yaml

Lines changed: 33 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,35 +16,35 @@ jobs:
1616
- name: 📥 Checkout repository
1717
uses: actions/checkout@v4
1818

19-
# things to be cached/restored:
19+
# things to be restored:
2020

21-
- name: 💾 Cache stack global package db
21+
- name: 💾 Restore cached stack global package db
2222
id: stack-global
23-
uses: actions/cache@v3
23+
uses: actions/cache/restore@v3
2424
with:
2525
path: ~/.stack
2626
key: ${{ runner.os }}-stack-global-${{ hashFiles('**.yaml') }}
2727
restore-keys: |
2828
${{ runner.os }}-stack-global
2929
30-
- name: 💾 Cache stack-installed programs in ~/.local/bin
30+
- name: 💾 Restore cached stack-installed programs in ~/.local/bin
3131
id: stack-programs
32-
uses: actions/cache@v3
32+
uses: actions/cache/restore@v3
3333
with:
3434
path: ~/.local/bin
3535
key: ${{ runner.os }}-stack-programs-${{ hashFiles('**.yaml') }}
3636
restore-keys: |
3737
${{ runner.os }}-stack-programs
3838
39-
- name: 💾 Cache .stack-work
40-
uses: actions/cache@v3
39+
- name: 💾 Restore cached .stack-work
40+
id: stack-work
41+
uses: actions/cache/restore@v3
4142
with:
4243
path: .stack-work
4344
key: ${{ runner.os }}-stack-work-${{ hashFiles('**.yaml') }}
4445
restore-keys: |
4546
${{ runner.os }}-stack-work
4647
47-
4848
# actions:
4949

5050
- name: ⏬ Install stack
@@ -69,6 +69,31 @@ jobs:
6969
run: |
7070
stack test
7171
72+
# things to be cached
73+
74+
- name: 💾 Cache stack global package db
75+
if: always() && steps.stack-global.outputs.cache-hit != 'true'
76+
uses: actions/cache/save@v3
77+
with:
78+
path: ~/.stack
79+
key: ${{ steps.stack-global.outputs.cache-primary-key }}
80+
81+
- name: 💾 Cache stack-installed programs in ~/.local/bin
82+
if: always() && steps.stack-programs.outputs.cache-hit != 'true'
83+
uses: actions/cache/save@v3
84+
with:
85+
path: ~/.local/bin
86+
key: ${{ steps.stack-programs.outputs.cache-primary-key }}
87+
88+
- name: 💾 Cache .stack-work
89+
if: always() && steps.stack-work.outputs.cache-hit != 'true'
90+
uses: actions/cache/save@v3
91+
with:
92+
path: .stack-work
93+
key: ${{ steps.stack-work.outputs.cache-primary-key }}
94+
95+
# release (optional)
96+
7297
- name: 📦 Compress files
7398
id: zip
7499
run: |
@@ -89,7 +114,6 @@ jobs:
89114
cd ..
90115
mv zip/als-ubuntu.zip .
91116
92-
93117
- name: 🚢 Release Artifacts
94118
uses: softprops/action-gh-release@v1
95119
if: startsWith(github.ref, 'refs/tags/') # so that only commits with a git tag would upload artifacts

.github/workflows/test-mac.yaml

Lines changed: 35 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,28 +16,29 @@ jobs:
1616
- name: 📥 Checkout repository
1717
uses: actions/checkout@v4
1818

19-
# things to be cached/restored:
19+
# things to be restored:
2020

21-
- name: 💾 Cache stack global package db
21+
- name: 💾 Restore cached stack global package db
2222
id: stack-global
23-
uses: actions/cache@v3
23+
uses: actions/cache/restore@v3
2424
with:
2525
path: ~/.stack
26-
key: ${{ runner.os }}-stack-global-after20210110-${{ hashFiles('**.yaml') }}
26+
key: ${{ runner.os }}-stack-global-${{ hashFiles('**.yaml') }}
2727
restore-keys: |
28-
${{ runner.os }}-stack-global-after202110110
28+
${{ runner.os }}-stack-global
2929
30-
- name: 💾 Cache stack-installed programs in ~/.local/bin
30+
- name: 💾 Restore cached stack-installed programs in ~/.local/bin
3131
id: stack-programs
32-
uses: actions/cache@v3
32+
uses: actions/cache/restore@v3
3333
with:
3434
path: ~/.local/bin
3535
key: ${{ runner.os }}-stack-programs-${{ hashFiles('**.yaml') }}
3636
restore-keys: |
3737
${{ runner.os }}-stack-programs
3838
39-
- name: 💾 Cache .stack-work
40-
uses: actions/cache@v3
39+
- name: 💾 Restore cached .stack-work
40+
id: stack-work
41+
uses: actions/cache/restore@v3
4142
with:
4243
path: .stack-work
4344
key: ${{ runner.os }}-stack-work-${{ hashFiles('**.yaml') }}
@@ -70,6 +71,31 @@ jobs:
7071
run: |
7172
stack test
7273
74+
# things to be cached
75+
76+
- name: 💾 Cache stack global package db
77+
if: always() && steps.stack-global.outputs.cache-hit != 'true'
78+
uses: actions/cache/save@v3
79+
with:
80+
path: ~/.stack
81+
key: ${{ steps.stack-global.outputs.cache-primary-key }}
82+
83+
- name: 💾 Cache stack-installed programs in ~/.local/bin
84+
if: always() && steps.stack-programs.outputs.cache-hit != 'true'
85+
uses: actions/cache/save@v3
86+
with:
87+
path: ~/.local/bin
88+
key: ${{ steps.stack-programs.outputs.cache-primary-key }}
89+
90+
- name: 💾 Cache .stack-work
91+
if: always() && steps.stack-work.outputs.cache-hit != 'true'
92+
uses: actions/cache/save@v3
93+
with:
94+
path: .stack-work
95+
key: ${{ steps.stack-work.outputs.cache-primary-key }}
96+
97+
# release (optional)
98+
7399
- name: 🔗 Bundle ICU4C DLLs
74100
run: | # Bundle icu4c DLLs
75101

.github/workflows/test-windows.yaml

Lines changed: 34 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,20 +16,20 @@ jobs:
1616
- name: 📥 Checkout repository
1717
uses: actions/checkout@v4
1818

19-
# things to be cached/restored:
19+
# things to be restored:
2020

21-
- name: 💾 Cache stack global package db
22-
id: stack-global-package-db
23-
uses: actions/cache@v3
21+
- name: 💾 Restore cached stack global package db
22+
id: stack-global
23+
uses: actions/cache/restore@v3
2424
with:
2525
path: C:\Users\runneradmin\AppData\Roaming\stack\
2626
key: ${{ runner.os }}-appdata-roaming-stack-${{ hashFiles('**.yaml') }}
2727
restore-keys: |
2828
${{ runner.os }}-appdata-roaming-stack
2929
30-
- name: 💾 Cache stack programs dir # ghc, ghc-included packages and their haddocks, mingw, msys2
31-
id: stack-programs-dir
32-
uses: actions/cache@v3
30+
- name: 💾 Restore cached stack-installed programs in ~/.local/bin
31+
id: stack-programs
32+
uses: actions/cache/restore@v3
3333
with:
3434
path: C:\Users\runneradmin\AppData\Local\Programs\stack\
3535
# which files signal a change in stack's global db ?
@@ -38,8 +38,9 @@ jobs:
3838
restore-keys: |
3939
${{ runner.os }}-appdata-local-programs-stack
4040
41-
- name: 💾 Cache .stack-work
42-
uses: actions/cache@v3
41+
- name: 💾 Restore cached .stack-work
42+
id: stack-work
43+
uses: actions/cache/restore@v3
4344
with:
4445
path: .stack-work
4546
key: ${{ runner.os }}-stack-work-${{ hashFiles('**.yaml') }}
@@ -83,6 +84,30 @@ jobs:
8384
run: |
8485
./stack test
8586
87+
# things to be cached
88+
89+
- name: 💾 Cache stack global package db
90+
if: always() && steps.stack-global.outputs.cache-hit != 'true'
91+
uses: actions/cache/save@v3
92+
with:
93+
path: ~/.stack
94+
key: ${{ steps.stack-global.outputs.cache-primary-key }}
95+
96+
- name: 💾 Cache stack-installed programs in ~/.local/bin
97+
if: always() && steps.stack-programs.outputs.cache-hit != 'true'
98+
uses: actions/cache/save@v3
99+
with:
100+
path: ~/.local/bin
101+
key: ${{ steps.stack-programs.outputs.cache-primary-key }}
102+
103+
- name: 💾 Cache .stack-work
104+
if: always() && steps.stack-work.outputs.cache-hit != 'true'
105+
uses: actions/cache/save@v3
106+
with:
107+
path: .stack-work
108+
key: ${{ steps.stack-work.outputs.cache-primary-key }}
109+
110+
# release (optional)
86111
# artifacts:
87112

88113
- name: 📦 Compress executable and data files

0 commit comments

Comments
 (0)