Skip to content

Commit a8aa016

Browse files
Fix ci update hackage index (#2562)
* Fix ci update hackage index * Make effective freeze file hash Co-authored-by: Anton Latukha <[email protected]>
1 parent 3983d97 commit a8aa016

File tree

5 files changed

+80
-61
lines changed

5 files changed

+80
-61
lines changed

Diff for: .github/workflows/bench.yml

+13-12
Original file line numberDiff line numberDiff line change
@@ -85,11 +85,22 @@ jobs:
8585
INDEX_STATE1=$(echo "$INDEX_STATE_ENTRY" | cut -d' ' -f2 | tr ':' '-')
8686
echo "INDEX_STATE=$INDEX_STATE1" >> $GITHUB_ENV
8787
88+
# We have to restore package sources before `cabal update`
89+
# cause it overwrites the hackage index with the cached one
90+
- name: Hackage sources cache
91+
uses: actions/cache@v2
92+
env:
93+
cache-name: hackage-sources
94+
with:
95+
path: ${{ env.CABAL_PKGS_DIR }}
96+
key: ${{ env.cache-name }}-${{ env.INDEX_STATE }}
97+
restore-keys: ${{ env.cache-name }}-
98+
8899
# To ensure we get the lastest hackage index and not relying on haskell action logic
100+
# It has to be done before `cabal freeze` to make it aware of the new index
89101
- run: cabal update
90102

91103
- name: Form the package list ('cabal.project.freeze')
92-
id: compute-cache-key
93104
run: |
94105
cabal v2-freeze && \
95106
echo "" && \
@@ -98,16 +109,6 @@ jobs:
98109
cat 'cabal.project.freeze' && \
99110
echo '' || \
100111
echo 'WARNING: Could not produce the `freeze`.'
101-
echo ::set-output name=value::${{ hashFiles('cabal.project.freeze') }}
102-
103-
- name: Hackage sources cache
104-
uses: actions/cache@v2
105-
env:
106-
cache-name: hackage-sources
107-
with:
108-
path: ${{ env.CABAL_PKGS_DIR }}
109-
key: ${{ env.cache-name }}-${{ env.INDEX_STATE }}
110-
restore-keys: ${{ env.cache-name }}-
111112
112113
- name: Compiled deps cache
113114
id: compiled-deps
@@ -116,7 +117,7 @@ jobs:
116117
cache-name: compiled-deps
117118
with:
118119
path: ${{ steps.HaskEnvSetup.outputs.cabal-store }}
119-
key: ${{ env.cache-name }}-${{ runner.os }}-${{ matrix.ghc }}-${{ env.INDEX_STATE }}-${{ steps.compute-cache-key.outputs.value }}
120+
key: ${{ env.cache-name }}-${{ runner.os }}-${{ matrix.ghc }}-${{ env.INDEX_STATE }}-${{ hashFiles('cabal.project.freeze') }}
120121
restore-keys: |
121122
${{ env.cache-name }}-${{ runner.os }}-${{ matrix.ghc }}-${{ env.INDEX_STATE }}-
122123
${{ env.cache-name }}-${{ runner.os }}-${{ matrix.ghc }}-

Diff for: .github/workflows/caching.yml

+17-16
Original file line numberDiff line numberDiff line change
@@ -142,26 +142,13 @@ 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-
148-
- name: Form the package list ('cabal.project.freeze')
149-
id: compute-cache-key
150-
run: |
151-
cabal v2-freeze && \
152-
echo "" && \
153-
echo 'Output:' && \
154-
echo "" && \
155-
cat 'cabal.project.freeze' && \
156-
echo '' || \
157-
echo 'WARNING: Could not produce the `freeze`.'
158-
echo ::set-output name=value::${{ hashFiles('cabal.project.freeze') }}
159-
160145
# 2021-12-02: NOTE: Cabal Hackage source tree storage does not depend on OS or GHC really,
161146
# but can depend on `base`.
162147
# But this caching is happens only inside `master` for `master` purposes of compiling the deps
163148
# so having a shared pool here that depends only on Hackage pin & does not depend on `base` is "good enough"
164149
# & used such because it preserves 10% of a global cache storage pool.
150+
# We have to restore package sources before `cabal update`
151+
# cause it overwrites the hackage index with the cached one
165152
- name: Hackage sources cache
166153
uses: actions/cache@v2
167154
env:
@@ -171,14 +158,28 @@ jobs:
171158
key: ${{ env.cache-name }}-${{ env.INDEX_STATE }}
172159
restore-keys: ${{ env.cache-name }}-
173160

161+
# To ensure we get the lastest hackage index and not relying on haskell action logic
162+
# It has to be done before `cabal freeze` to make it aware of the new index
163+
- run: cabal update
164+
165+
- name: Form the package list ('cabal.project.freeze')
166+
run: |
167+
cabal v2-freeze && \
168+
echo "" && \
169+
echo 'Output:' && \
170+
echo "" && \
171+
cat 'cabal.project.freeze' && \
172+
echo '' || \
173+
echo 'WARNING: Could not produce the `freeze`.'
174+
174175
- name: Compiled deps cache
175176
id: compiled-deps
176177
uses: actions/cache@v2
177178
env:
178179
cache-name: compiled-deps
179180
with:
180181
path: ${{ steps.HaskEnvSetup.outputs.cabal-store }}
181-
key: ${{ env.cache-name }}-${{ runner.os }}-${{ matrix.ghc }}-${{ env.INDEX_STATE }}-${{ steps.compute-cache-key.outputs.value }}
182+
key: ${{ env.cache-name }}-${{ runner.os }}-${{ matrix.ghc }}-${{ env.INDEX_STATE }}-${{ hashFiles('cabal.project.freeze') }}
182183
restore-keys: |
183184
${{ env.cache-name }}-${{ runner.os }}-${{ matrix.ghc }}-${{ env.INDEX_STATE }}-
184185
${{ env.cache-name }}-${{ runner.os }}-${{ matrix.ghc }}-

Diff for: .github/workflows/flags.yml

+18-15
Original file line numberDiff line numberDiff line change
@@ -85,31 +85,30 @@ jobs:
8585
INDEX_STATE1=$(echo "$INDEX_STATE_ENTRY" | cut -d' ' -f2 | tr ':' '-')
8686
echo "INDEX_STATE=$INDEX_STATE1" >> $GITHUB_ENV
8787
88+
# We have to restore package sources before `cabal update`
89+
# cause it overwrites the hackage index with the cached one
90+
- name: Hackage sources cache
91+
uses: actions/cache@v2
92+
env:
93+
cache-name: hackage-sources
94+
with:
95+
path: ${{ env.CABAL_PKGS_DIR }}
96+
key: ${{ env.cache-name }}-${{ env.INDEX_STATE }}
97+
restore-keys: ${{ env.cache-name }}-
98+
8899
# To ensure we get the lastest hackage index and not relying on haskell action logic
100+
# It has to be done before `cabal freeze` to make it aware of the new index
89101
- run: cabal update
90102

91103
- name: Form the package list ('cabal.project.freeze')
92-
id: compute-cache-key
93104
run: |
94105
cabal v2-freeze && \
95106
echo "" && \
96107
echo 'Output:' && \
97108
echo "" && \
98109
cat 'cabal.project.freeze' && \
99-
echo "" || \
110+
echo '' || \
100111
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
104-
105-
- name: Hackage sources cache
106-
uses: actions/cache@v2
107-
env:
108-
cache-name: hackage-sources
109-
with:
110-
path: ${{ env.CABAL_PKGS_DIR }}
111-
key: ${{ env.cache-name }}-${{ env.INDEX_STATE }}
112-
restore-keys: ${{ env.cache-name }}-
113112
114113
- name: Compiled deps cache
115114
id: compiled-deps
@@ -118,12 +117,16 @@ jobs:
118117
cache-name: compiled-deps
119118
with:
120119
path: ${{ steps.HaskEnvSetup.outputs.cabal-store }}
121-
key: ${{ env.cache-name }}-${{ runner.os }}-${{ matrix.ghc }}-${{ env.INDEX_STATE }}-${{ steps.compute-cache-key.outputs.value }}
120+
key: ${{ env.cache-name }}-${{ runner.os }}-${{ matrix.ghc }}-${{ env.INDEX_STATE }}-${{ hashFiles('cabal.project.freeze') }}
122121
restore-keys: |
123122
${{ env.cache-name }}-${{ runner.os }}-${{ matrix.ghc }}-${{ env.INDEX_STATE }}-
124123
${{ env.cache-name }}-${{ runner.os }}-${{ matrix.ghc }}-
125124
${{ env.cache-name }}-${{ runner.os }}-
126125
126+
# Removing freeze file cause it breaks builds with alternative flags
127+
- name: Remove freeze file
128+
run: rm -f cabal.project.freeze
129+
127130
- name: Build `hls-graph` with flags
128131
run: cabal v2-build hls-graph --flags="pedantic embed-files stm-stats"
129132

Diff for: .github/workflows/hackage.yml

+18-5
Original file line numberDiff line numberDiff line change
@@ -78,16 +78,32 @@ jobs:
7878
cache-name: hackage-sources
7979
with:
8080
path: ${{ env.CABAL_PKGS_DIR }}
81-
key: ${{ env.cache-name }}-${{ env.INDEX_STATE }}
81+
key: ${{ env.cache-name }}-${{ env.INDEX_STATE }}
8282
restore-keys: ${{ env.cache-name }}-
8383

84+
# To ensure we get the lastest hackage index and not relying on haskell action logic
85+
# It has to be done before `cabal freeze` to make it aware of the new index
86+
- name: "Ensure we will use hackage head"
87+
run: cabal update
88+
89+
- name: Form the package list ('cabal.project.freeze')
90+
run: |
91+
cabal v2-freeze && \
92+
echo "" && \
93+
echo 'Output:' && \
94+
echo "" && \
95+
cat 'cabal.project.freeze' && \
96+
echo '' || \
97+
echo 'WARNING: Could not produce the `freeze`.'
98+
8499
- name: Compiled deps cache
100+
id: compiled-deps
85101
uses: actions/cache@v2
86102
env:
87103
cache-name: compiled-deps
88104
with:
89105
path: ${{ steps.HaskEnvSetup.outputs.cabal-store }}
90-
key: ${{ env.cache-name }}-${{ runner.os }}-${{ matrix.ghc }}-${{ env.INDEX_STATE }}-${{ hashFiles('cabal.project') }}
106+
key: ${{ env.cache-name }}-${{ runner.os }}-${{ matrix.ghc }}-${{ env.INDEX_STATE }}-${{ hashFiles('cabal.project.freeze') }}
91107
restore-keys: |
92108
${{ env.cache-name }}-${{ runner.os }}-${{ matrix.ghc }}-${{ env.INDEX_STATE }}-
93109
${{ env.cache-name }}-${{ runner.os }}-${{ matrix.ghc }}-
@@ -116,9 +132,6 @@ jobs:
116132
- name: "Unpack package source in an isolated location"
117133
run: cabal unpack ${{ steps.generate-dist-tarball.outputs.path }} --destdir=./incoming
118134

119-
- name: "Ensure we will use hackage head"
120-
run: cabal update
121-
122135
- name: "Try to get the current hackage version"
123136
id: get-hackage-version
124137
run: |

Diff for: .github/workflows/test.yml

+14-13
Original file line numberDiff line numberDiff line change
@@ -146,11 +146,22 @@ jobs:
146146
INDEX_STATE1=$(echo "$INDEX_STATE_ENTRY" | cut -d' ' -f2 | tr ':' '-')
147147
echo "INDEX_STATE=$INDEX_STATE1" >> $GITHUB_ENV
148148
149+
# We have to restore package sources before `cabal update`
150+
# cause it overwrites the hackage index with the cached one
151+
- name: Hackage sources cache
152+
uses: actions/cache@v2
153+
env:
154+
cache-name: hackage-sources
155+
with:
156+
path: ${{ env.CABAL_PKGS_DIR }}
157+
key: ${{ env.cache-name }}-${{ env.INDEX_STATE }}
158+
restore-keys: ${{ env.cache-name }}-
159+
149160
# To ensure we get the lastest hackage index and not relying on haskell action logic
161+
# It has to be done before `cabal freeze` to make it aware of the new index
150162
- run: cabal update
151163

152-
- name: Compute the cache key
153-
id: compute-cache-key
164+
- name: Form the package list ('cabal.project.freeze')
154165
run: |
155166
cabal v2-freeze && \
156167
echo "" && \
@@ -159,16 +170,6 @@ jobs:
159170
cat 'cabal.project.freeze' && \
160171
echo '' || \
161172
echo 'WARNING: Could not produce the `freeze`.'
162-
echo ::set-output name=value::${{ hashFiles('cabal.project.freeze') }}
163-
164-
- name: Hackage sources cache
165-
uses: actions/cache@v2
166-
env:
167-
cache-name: hackage-sources
168-
with:
169-
path: ${{ env.CABAL_PKGS_DIR }}
170-
key: ${{ env.cache-name }}-${{ env.INDEX_STATE }}
171-
restore-keys: ${{ env.cache-name }}-
172173
173174
- name: Compiled deps cache
174175
id: compiled-deps
@@ -177,7 +178,7 @@ jobs:
177178
cache-name: compiled-deps
178179
with:
179180
path: ${{ steps.HaskEnvSetup.outputs.cabal-store }}
180-
key: ${{ env.cache-name }}-${{ runner.os }}-${{ matrix.ghc }}-${{ env.INDEX_STATE }}-${{ steps.compute-cache-key.outputs.value }}
181+
key: ${{ env.cache-name }}-${{ runner.os }}-${{ matrix.ghc }}-${{ env.INDEX_STATE }}-${{ hashFiles('cabal.project.freeze') }}
181182
restore-keys: |
182183
${{ env.cache-name }}-${{ runner.os }}-${{ matrix.ghc }}-${{ env.INDEX_STATE }}-
183184
${{ env.cache-name }}-${{ runner.os }}-${{ matrix.ghc }}-

0 commit comments

Comments
 (0)