Skip to content

Commit 1849a87

Browse files
authored
Fix freeze cache key correctly (#2560)
* Update cabal before freeze * Use step outputs for cache key * Remove rm freeze file * Move cabal update for flags * Flags workflow needs rm freeze file
1 parent ee0a0cc commit 1849a87

File tree

4 files changed

+17
-23
lines changed

4 files changed

+17
-23
lines changed

.github/workflows/bench.yml

+3-5
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,9 @@ jobs:
8585
INDEX_STATE1=$(echo "$INDEX_STATE_ENTRY" | cut -d' ' -f2 | tr ':' '-')
8686
echo "INDEX_STATE=$INDEX_STATE1" >> $GITHUB_ENV
8787
88+
# To ensure we get the lastest hackage index and not relying on haskell action logic
89+
- run: cabal update
90+
8891
- name: Form the package list ('cabal.project.freeze')
8992
id: compute-cache-key
9093
run: |
@@ -96,8 +99,6 @@ jobs:
9699
echo '' || \
97100
echo 'WARNING: Could not produce the `freeze`.'
98101
echo ::set-output name=value::${{ hashFiles('cabal.project.freeze') }}
99-
# Removing freeze file as it can break builds using allow-newer
100-
rm -f cabal.project.freeze
101102
102103
- name: Hackage sources cache
103104
uses: actions/cache@v2
@@ -121,9 +122,6 @@ jobs:
121122
${{ env.cache-name }}-${{ runner.os }}-${{ matrix.ghc }}-
122123
${{ env.cache-name }}-${{ runner.os }}-
123124
124-
# To ensure we get the lastest hackage index and not relying on haskell action logic
125-
- run: cabal update
126-
127125
# max-backjumps is increased as a temporary solution
128126
# for dependency resolution failure
129127
- run: cabal configure --enable-benchmarks --max-backjumps 12000

.github/workflows/caching.yml

+3-6
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,9 @@ jobs:
142142
INDEX_STATE1=$(echo "$INDEX_STATE_ENTRY" | cut -d' ' -f2 | tr ':' '-')
143143
echo "INDEX_STATE=$INDEX_STATE1" >> $GITHUB_ENV
144144
145+
# To ensure we get the lastest hackage index and not relying on haskell action logic
146+
- run: cabal update
147+
145148
- name: Form the package list ('cabal.project.freeze')
146149
id: compute-cache-key
147150
run: |
@@ -153,8 +156,6 @@ jobs:
153156
echo '' || \
154157
echo 'WARNING: Could not produce the `freeze`.'
155158
echo ::set-output name=value::${{ hashFiles('cabal.project.freeze') }}
156-
# Removing freeze file as it can break builds using allow-newer
157-
rm -f cabal.project.freeze
158159
159160
# 2021-12-02: NOTE: Cabal Hackage source tree storage does not depend on OS or GHC really,
160161
# but can depend on `base`.
@@ -183,10 +184,6 @@ jobs:
183184
${{ env.cache-name }}-${{ runner.os }}-${{ matrix.ghc }}-
184185
${{ env.cache-name }}-${{ runner.os }}-
185186
186-
# To ensure we get the lastest hackage index and not relying on haskell action logic
187-
- if: steps.compiled-deps.outputs.cache-hit != 'true'
188-
run: cabal update
189-
190187
- if: steps.compiled-deps.outputs.cache-hit != 'true' && runner.os == 'Linux' && matrix.ghc == '8.10.7'
191188
name: Download sources for bench
192189
# Downloaded separately, to match the tested work/PR workflow guarantees

.github/workflows/flags.yml

+8-6
Original file line numberDiff line numberDiff line change
@@ -85,8 +85,11 @@ jobs:
8585
INDEX_STATE1=$(echo "$INDEX_STATE_ENTRY" | cut -d' ' -f2 | tr ':' '-')
8686
echo "INDEX_STATE=$INDEX_STATE1" >> $GITHUB_ENV
8787
88+
# To ensure we get the lastest hackage index and not relying on haskell action logic
89+
- run: cabal update
90+
8891
- name: Form the package list ('cabal.project.freeze')
89-
continue-on-error: true
92+
id: compute-cache-key
9093
run: |
9194
cabal v2-freeze && \
9295
echo "" && \
@@ -95,6 +98,9 @@ jobs:
9598
cat 'cabal.project.freeze' && \
9699
echo "" || \
97100
echo 'WARNING: Could not produce the `freeze`.'
101+
echo ::set-output name=value::${{ hashFiles('cabal.project.freeze') }}
102+
# Removing freeze file as it breaks builds with alternative flags
103+
rm -rf cabal.project.freeze
98104
99105
- name: Hackage sources cache
100106
uses: actions/cache@v2
@@ -112,16 +118,12 @@ jobs:
112118
cache-name: compiled-deps
113119
with:
114120
path: ${{ steps.HaskEnvSetup.outputs.cabal-store }}
115-
key: ${{ env.cache-name }}-${{ runner.os }}-${{ matrix.ghc }}-${{ env.INDEX_STATE }}-${{ hashFiles('cabal.project.freeze') }}
121+
key: ${{ env.cache-name }}-${{ runner.os }}-${{ matrix.ghc }}-${{ env.INDEX_STATE }}-${{ steps.compute-cache-key.outputs.value }}
116122
restore-keys: |
117123
${{ env.cache-name }}-${{ runner.os }}-${{ matrix.ghc }}-${{ env.INDEX_STATE }}-
118124
${{ env.cache-name }}-${{ runner.os }}-${{ matrix.ghc }}-
119125
${{ env.cache-name }}-${{ runner.os }}-
120126
121-
# To ensure we get the lastest hackage index and not relying on haskell action logic
122-
- if: steps.compiled-deps.outputs.cache-hit != 'true'
123-
run: cabal update
124-
125127
- name: Build `hls-graph` with flags
126128
run: cabal v2-build hls-graph --flags="pedantic embed-files stm-stats"
127129

.github/workflows/test.yml

+3-6
Original file line numberDiff line numberDiff line change
@@ -146,6 +146,9 @@ jobs:
146146
INDEX_STATE1=$(echo "$INDEX_STATE_ENTRY" | cut -d' ' -f2 | tr ':' '-')
147147
echo "INDEX_STATE=$INDEX_STATE1" >> $GITHUB_ENV
148148
149+
# To ensure we get the lastest hackage index and not relying on haskell action logic
150+
- run: cabal update
151+
149152
- name: Compute the cache key
150153
id: compute-cache-key
151154
run: |
@@ -157,8 +160,6 @@ jobs:
157160
echo '' || \
158161
echo 'WARNING: Could not produce the `freeze`.'
159162
echo ::set-output name=value::${{ hashFiles('cabal.project.freeze') }}
160-
# Removing freeze file as it can break builds using allow-newer
161-
rm -rf cabal.project.freeze
162163
163164
- name: Hackage sources cache
164165
uses: actions/cache@v2
@@ -182,10 +183,6 @@ jobs:
182183
${{ env.cache-name }}-${{ runner.os }}-${{ matrix.ghc }}-
183184
${{ env.cache-name }}-${{ runner.os }}-
184185
185-
# To ensure we get the lastest hackage index and not relying on haskell action logic
186-
- if: steps.compiled-deps.outputs.cache-hit != 'true'
187-
run: cabal update
188-
189186
# repeating builds to workaround segfaults in windows and ghc-8.8.4
190187
- name: Build
191188
run: cabal build || cabal build || cabal build

0 commit comments

Comments
 (0)