Skip to content

Commit 842dfa7

Browse files
committed
CI caching: include resolver in the cache key
1 parent 38c553d commit 842dfa7

File tree

3 files changed

+35
-17
lines changed

3 files changed

+35
-17
lines changed

.github/workflows/test-linux.yaml

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

19+
- name: Determine stack resolver
20+
run: |
21+
STACK_RESOLVER=$(yq .resolver stack.yaml)
22+
echo STACK_RESOLVER="${STACK_RESOLVER}" >> "${GITHUB_ENV}"
23+
1924
# things to be restored:
25+
# Include STACK_RESOLVER in cache key, otherwise caches accumulate build products for different resolvers.
2026

2127
- name: 💾 Restore cached stack global package db
2228
id: stack-global
2329
uses: actions/cache/restore@v3
2430
with:
2531
path: ~/.stack
26-
key: ${{ runner.os }}-stack-global-${{ hashFiles('**.yaml') }}
32+
key: ${{ runner.os }}-stack-resolver-${{ env.STACK_RESOLVER }}-global-${{ hashFiles('**.yaml') }}
2733
restore-keys: |
28-
${{ runner.os }}-stack-global
34+
${{ runner.os }}-stack-resolver-${{ env.STACK_RESOLVER }}-global
2935
3036
- name: 💾 Restore cached .stack-work
3137
id: stack-work
3238
uses: actions/cache/restore@v3
3339
with:
3440
path: .stack-work
35-
key: ${{ runner.os }}-stack-work-${{ hashFiles('**.yaml') }}
41+
key: ${{ runner.os }}-stack-resolver-${{ env.STACK_RESOLVER }}-work-${{ hashFiles('**.yaml') }}
3642
restore-keys: |
37-
${{ runner.os }}-stack-work
43+
${{ runner.os }}-stack-resolver-${{ env.STACK_RESOLVER }}-work
3844
3945
# actions:
4046

.github/workflows/test-mac.yaml

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

19+
- name: Determine stack resolver
20+
run: |
21+
STACK_RESOLVER=$(yq .resolver stack.yaml)
22+
echo STACK_RESOLVER="${STACK_RESOLVER}" >> "${GITHUB_ENV}"
23+
1924
# things to be restored:
25+
# Include STACK_RESOLVER in cache key, otherwise caches accumulate build products for different resolvers.
2026

2127
- name: 💾 Restore cached stack global package db
2228
id: stack-global
2329
uses: actions/cache/restore@v3
2430
with:
2531
path: ~/.stack
26-
key: ${{ runner.os }}-stack-global-${{ hashFiles('**.yaml') }}
32+
key: ${{ runner.os }}-stack-resolver-${{ env.STACK_RESOLVER }}-global-${{ hashFiles('**.yaml') }}
2733
restore-keys: |
28-
${{ runner.os }}-stack-global
34+
${{ runner.os }}-stack-resolver-${{ env.STACK_RESOLVER }}-global
2935
3036
- name: 💾 Restore cached .stack-work
3137
id: stack-work
3238
uses: actions/cache/restore@v3
3339
with:
3440
path: .stack-work
35-
key: ${{ runner.os }}-stack-work-${{ hashFiles('**.yaml') }}
41+
key: ${{ runner.os }}-stack-resolver-${{ env.STACK_RESOLVER }}-work-${{ hashFiles('**.yaml') }}
3642
restore-keys: |
37-
${{ runner.os }}-stack-work
43+
${{ runner.os }}-stack-resolver-${{ env.STACK_RESOLVER }}-work
3844
3945
# actions:
4046

.github/workflows/test-windows.yaml

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,42 +17,48 @@ jobs:
1717
runs-on: windows-latest
1818
steps:
1919

20-
- name: Determine stack root
20+
- name: 📥 Checkout repository
21+
uses: actions/checkout@v4
22+
23+
- name: 🏗 Install yq
24+
uses: frenck/action-setup-yq@v1
25+
26+
- name: Determine stack root and resolver
2127
## 2023-11-21 https://github.com/commercialhaskell/stack/issues/6340
2228
## Asking stack for the stack root unfortunately does not work
2329
## if stack is not fully operational (meaning e.g. that GHC is installed)
2430
## so we hardcode its location instead.
2531
run: |
2632
STACK_ROOT="C:/Users/runneradmin/AppData/Local/Programs/stack/x86_64-windows"
27-
echo STACK_ROOT="${STACK_ROOT}" >> "${GITHUB_ENV}"
33+
STACK_RESOLVER=$(yq .resolver stack.yaml)
34+
echo STACK_ROOT="${STACK_ROOT}" >> "${GITHUB_ENV}"
35+
echo STACK_RESOLVER="${STACK_RESOLVER}" >> "${GITHUB_ENV}"
2836
# run: |
2937
# STACK_ROOT="$(stack --system-ghc --no-install-ghc path --stack-root || echo "C:/Users/runneradmin/AppData/Local/Programs/stack/x86_64-windows")"
3038
# echo "STACK_ROOT = ${STACK_ROOT}"
3139
# echo STACK_ROOT="${STACK_ROOT}" >> "${GITHUB_ENV}"
3240
# What about C:/Users/runneradmin/AppData/Roaming/stack ?
3341

34-
- name: 📥 Checkout repository
35-
uses: actions/checkout@v4
36-
3742
# things to be restored:
43+
# Include STACK_RESOLVER in cache key, otherwise caches accumulate build products for different resolvers.
3844

3945
- name: 💾 Restore cached stack global package db
4046
id: stack-global
4147
uses: actions/cache/restore@v3
4248
with:
4349
path: ${{ env.STACK_ROOT }}
44-
key: ${{ runner.os }}-stack-global-${{ hashFiles('**.yaml') }}
50+
key: ${{ runner.os }}-stack-resolver-${{ env.STACK_RESOLVER }}-global-${{ hashFiles('**.yaml') }}
4551
restore-keys: |
46-
${{ runner.os }}-stack-global
52+
${{ runner.os }}-stack-resolver-${{ env.STACK_RESOLVER }}-global
4753
4854
- name: 💾 Restore cached .stack-work
4955
id: stack-work
5056
uses: actions/cache/restore@v3
5157
with:
5258
path: .stack-work
53-
key: ${{ runner.os }}-stack-work-${{ hashFiles('**.yaml') }}
59+
key: ${{ runner.os }}-stack-resolver-${{ env.STACK_RESOLVER }}-work-${{ hashFiles('**.yaml') }}
5460
restore-keys: |
55-
${{ runner.os }}-stack-work
61+
${{ runner.os }}-stack-resolver-${{ env.STACK_RESOLVER }}-work
5662
5763
# actions
5864

0 commit comments

Comments
 (0)