Skip to content

Commit c3bd8c2

Browse files
committed
Fix ci update hackage index
1 parent aea3ef8 commit c3bd8c2

File tree

5 files changed

+72
-46
lines changed

5 files changed

+72
-46
lines changed

.github/workflows/bench.yml

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,19 @@ 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')
@@ -100,15 +112,6 @@ jobs:
100112
echo 'WARNING: Could not produce the `freeze`.'
101113
echo ::set-output name=value::${{ hashFiles('cabal.project.freeze') }}
102114
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 }}-
111-
112115
- name: Compiled deps cache
113116
uses: actions/cache@v2
114117
env:

.github/workflows/caching.yml

Lines changed: 17 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,24 @@ jobs:
149149
INDEX_STATE1=$(echo "$INDEX_STATE_ENTRY" | cut -d' ' -f2 | tr ':' '-')
150150
echo "INDEX_STATE=$INDEX_STATE1" >> $GITHUB_ENV
151151
152+
# 2021-12-02: NOTE: Cabal Hackage source tree storage does not depend on OS or GHC really,
153+
# but can depend on `base`.
154+
# But this caching is happens only inside `master` for `master` purposes of compiling the deps
155+
# so having a shared pool here that depends only on Hackage pin & does not depend on `base` is "good enough"
156+
# & used such because it preserves 10% of a global cache storage pool.
157+
# We have to restore package sources before `cabal update`
158+
# cause it overwrites the hackage index with the cached one
159+
- name: Hackage sources cache
160+
uses: actions/cache@v2
161+
env:
162+
cache-name: hackage-sources
163+
with:
164+
path: ${{ env.CABAL_PKGS_DIR }}
165+
key: ${{ env.cache-name }}-${{ env.INDEX_STATE }}
166+
restore-keys: ${{ env.cache-name }}-
167+
152168
# To ensure we get the lastest hackage index and not relying on haskell action logic
169+
# It has to be done before `cabal freeze` to make it aware of the new index
153170
- run: cabal update
154171

155172
- name: Form the package list ('cabal.project.freeze')
@@ -164,20 +181,6 @@ jobs:
164181
echo 'WARNING: Could not produce the `freeze`.'
165182
echo ::set-output name=value::${{ hashFiles('cabal.project.freeze') }}
166183
167-
# 2021-12-02: NOTE: Cabal Hackage source tree storage does not depend on OS or GHC really,
168-
# but can depend on `base`.
169-
# But this caching is happens only inside `master` for `master` purposes of compiling the deps
170-
# so having a shared pool here that depends only on Hackage pin & does not depend on `base` is "good enough"
171-
# & used such because it preserves 10% of a global cache storage pool.
172-
- name: Hackage sources cache
173-
uses: actions/cache@v2
174-
env:
175-
cache-name: hackage-sources
176-
with:
177-
path: ${{ env.CABAL_PKGS_DIR }}
178-
key: ${{ env.cache-name }}-${{ env.INDEX_STATE }}
179-
restore-keys: ${{ env.cache-name }}-
180-
181184
- name: Compiled deps cache
182185
id: compiled-deps
183186
uses: actions/cache@v2

.github/workflows/flags.yml

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,19 @@ 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')
@@ -102,15 +114,6 @@ jobs:
102114
# Removing freeze file as it breaks builds with alternative flags
103115
rm -rf cabal.project.freeze
104116
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 }}-
113-
114117
- name: Compiled deps cache
115118
id: compiled-deps
116119
uses: actions/cache@v2

.github/workflows/hackage.yml

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -78,16 +78,33 @@ 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: Compute the cache key
90+
id: compute-cache-key
91+
run: |
92+
cabal v2-freeze && \
93+
echo "" && \
94+
echo 'Output:' && \
95+
echo "" && \
96+
cat 'cabal.project.freeze' && \
97+
echo '' || \
98+
echo 'WARNING: Could not produce the `freeze`.'
99+
echo ::set-output name=value::${{ hashFiles('cabal.project.freeze') }}
100+
84101
- name: Compiled deps cache
85102
uses: actions/cache@v2
86103
env:
87104
cache-name: compiled-deps
88105
with:
89106
path: ${{ steps.HaskEnvSetup.outputs.cabal-store }}
90-
key: ${{ env.cache-name }}-${{ runner.os }}-${{ matrix.ghc }}-${{ env.INDEX_STATE }}-${{ hashFiles('cabal.project') }}
107+
key: ${{ env.cache-name }}-${{ runner.os }}-${{ matrix.ghc }}-${{ env.INDEX_STATE }}-${{ steps.compute-cache-key.outputs.value }}
91108
restore-keys: |
92109
${{ env.cache-name }}-${{ runner.os }}-${{ matrix.ghc }}-${{ env.INDEX_STATE }}-
93110
${{ env.cache-name }}-${{ runner.os }}-${{ matrix.ghc }}-
@@ -116,9 +133,6 @@ jobs:
116133
- name: "Unpack package source in an isolated location"
117134
run: cabal unpack ${{ steps.generate-dist-tarball.outputs.path }} --destdir=./incoming
118135

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

.github/workflows/test.yml

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,19 @@ jobs:
154154
INDEX_STATE1=$(echo "$INDEX_STATE_ENTRY" | cut -d' ' -f2 | tr ':' '-')
155155
echo "INDEX_STATE=$INDEX_STATE1" >> $GITHUB_ENV
156156
157+
# We have to restore package sources before `cabal update`
158+
# cause it overwrites the hackage index with the cached one
159+
- name: Hackage sources cache
160+
uses: actions/cache@v2
161+
env:
162+
cache-name: hackage-sources
163+
with:
164+
path: ${{ env.CABAL_PKGS_DIR }}
165+
key: ${{ env.cache-name }}-${{ env.INDEX_STATE }}
166+
restore-keys: ${{ env.cache-name }}-
167+
157168
# To ensure we get the lastest hackage index and not relying on haskell action logic
169+
# It has to be done before `cabal freeze` to make it aware of the new index
158170
- run: cabal update
159171

160172
- name: Compute the cache key
@@ -169,15 +181,6 @@ jobs:
169181
echo 'WARNING: Could not produce the `freeze`.'
170182
echo ::set-output name=value::${{ hashFiles('cabal.project.freeze') }}
171183
172-
- name: Hackage sources cache
173-
uses: actions/cache@v2
174-
env:
175-
cache-name: hackage-sources
176-
with:
177-
path: ${{ env.CABAL_PKGS_DIR }}
178-
key: ${{ env.cache-name }}-${{ env.INDEX_STATE }}
179-
restore-keys: ${{ env.cache-name }}-
180-
181184
- name: Compiled deps cache
182185
uses: actions/cache@v2
183186
env:

0 commit comments

Comments
 (0)