Skip to content

Commit 757c1e0

Browse files
Anton-Latukhajneira
authored andcommitted
CI: caching: closer match work/CI guarantees (#2536)
* CI: caching: do `bench` & `test` separately `cabal v2-build all --enable-tests --enable-benchmarks` inferres 1 version per dep keeping all targets. People (frequently) & CI do `test` & `bench` separately. So `all tests` & `all bench` deps may not end up. Even current code does not match the CI guarantees, as all plugins get `test` separately, so their deps can not match-up. `caching` should not assume guarantees bigger then provided. * CI: caching: rm workaround This workaround was not addressing the CI behaviour. * CI: {caching, test, bench}: output `freeze` or warning * CI: {caching, test, bench}: m v2-update unification * CI: caching: do bench caching only for what gets used Efficient use of available space. * CI: caching: fx benchmark caching step Co-authored-by: Javier Neira <[email protected]> * CI: {caching, test, bench}: `haskell/actions/setup` does the update * CI: caching: m fx Co-authored-by: Javier Neira <[email protected]>
1 parent 41c58f8 commit 757c1e0

File tree

3 files changed

+42
-33
lines changed

3 files changed

+42
-33
lines changed

.github/workflows/bench.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -88,11 +88,13 @@ jobs:
8888
- name: Form the package list ('cabal.project.freeze')
8989
continue-on-error: true
9090
run: |
91-
cabal v2-freeze
92-
echo ''
93-
echo 'Output:'
94-
echo ''
95-
cat 'cabal.project.freeze'
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`.
9698
9799
- name: Hackage sources cache
98100
uses: actions/cache@v2
@@ -116,8 +118,6 @@ jobs:
116118
${{ env.cache-name }}-${{ runner.os }}-${{ matrix.ghc }}-
117119
${{ env.cache-name }}-${{ runner.os }}-
118120
119-
- run: cabal update
120-
121121
# max-backjumps is increased as a temporary solution
122122
# for dependency resolution failure
123123
- run: cabal configure --enable-benchmarks --max-backjumps 12000

.github/workflows/caching.yml

Lines changed: 28 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ on:
4545
- cron: "25 2/8 * * *"
4646

4747
env:
48-
cabalBuild: "v2-build all --enable-tests --enable-benchmarks --keep-going"
48+
cabalBuild: "v2-build all --keep-going"
4949

5050
jobs:
5151

@@ -145,11 +145,13 @@ jobs:
145145
- name: Form the package list ('cabal.project.freeze')
146146
continue-on-error: true
147147
run: |
148-
cabal v2-freeze
149-
echo ''
150-
echo 'Output:'
151-
echo ''
152-
cat 'cabal.project.freeze'
148+
cabal v2-freeze && \
149+
echo '' && \
150+
echo 'Output:' && \
151+
echo '' && \
152+
cat 'cabal.project.freeze' && \
153+
echo '' || \
154+
echo 'WARNING: Could not produce the `freeze`.
153155
154156
# 2021-12-02: NOTE: Cabal Hackage source tree storage does not depend on OS or GHC really,
155157
# but can depend on `base`.
@@ -180,27 +182,34 @@ jobs:
180182
${{ env.cache-name }}-${{ runner.os }}-${{ matrix.ghc }}-
181183
${{ env.cache-name }}-${{ runner.os }}-
182184
183-
- if: steps.compiled-deps.outputs.cache-hit != 'true'
185+
- if: steps.compiled-deps.outputs.cache-hit != 'true' && runner.os == 'Linux' && matrix.ghc == '8.10.7'
186+
name: Download sources for bench
187+
# Downloaded separately, to match the tested work/PR workflow guarantees
184188
run: |
185-
cabal update
189+
cabal $cabalBuild --only-download --enable-benchmarks
186190
187191
- if: steps.compiled-deps.outputs.cache-hit != 'true'
188-
name: Download all sources
192+
name: Download the rest of the sources
193+
# Downloaded separately, to match the tested work/PR workflow guarantees
189194
run: |
190-
cabal $cabalBuild --only-download
195+
cabal $cabalBuild --only-download --enable-tests
191196
192197
# repeating builds to workaround segfaults in windows and ghc-8.8.4
193198
# This build agenda in not to have successful code,
194-
# but to cache what can be cached, so step is fault tolerant & would always succseed.
195-
# 2021-12-11: NOTE: Building all targets, since
196-
# current Cabal does not allow `all --enable-tests --enable-benchmarks --only-dependencies`
197-
- if: steps.compiled-deps.outputs.cache-hit != 'true'
198-
name: Build all targets; try 3 times
199+
# but to cache what can be cached, so step is fault tolerant & would always succeed.
200+
# 2021-12-11: NOTE: Need to building all targets (build the project also), since
201+
# current Cabal does not allow `all --enable-tests --enable-benchmarks --only-dependencies` combination
202+
203+
- if: steps.compiled-deps.outputs.cache-hit != 'true' && runner.os == 'Linux' && matrix.ghc == '8.10.7'
204+
name: (For Bench workflow) Build benchmark targets
199205
continue-on-error: true
206+
# Downloaded separately, to match the tested work/PR workflow guarantees
200207
run: |
201-
cabal $cabalBuild || cabal $cabalBuild || cabal $cabalBuild
208+
cabal $cabalBuild --enable-benchmarks || cabal $cabalBuild --enable-benchmarks || cabal $cabalBuild --enable-benchmarks
202209
203-
# Despite the `continue-on-error: true` directive - CI does not ignore the return code of the last step
204-
- name: Workaround to CI platform
210+
- if: steps.compiled-deps.outputs.cache-hit != 'true'
211+
name: Build targets; try 3 times
212+
continue-on-error: true
213+
# Done separately, matching the tested work/PR workflow guarantees
205214
run: |
206-
true
215+
cabal $cabalBuild --enable-test || cabal $cabalBuild --enable-test || cabal $cabalBuild --enable-test

.github/workflows/test.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -149,11 +149,13 @@ jobs:
149149
- name: Form the package list ('cabal.project.freeze')
150150
continue-on-error: true
151151
run: |
152-
cabal v2-freeze
153-
echo ''
154-
echo 'Output:'
155-
echo ''
156-
cat 'cabal.project.freeze'
152+
cabal v2-freeze && \
153+
echo '' && \
154+
echo 'Output:' && \
155+
echo '' && \
156+
cat 'cabal.project.freeze' && \
157+
echo '' || \
158+
echo 'WARNING: Could not produce the `freeze`.
157159
158160
- name: Hackage sources cache
159161
uses: actions/cache@v2
@@ -177,8 +179,6 @@ jobs:
177179
${{ env.cache-name }}-${{ runner.os }}-${{ matrix.ghc }}-
178180
${{ env.cache-name }}-${{ runner.os }}-
179181
180-
- run: cabal v2-update
181-
182182
# repeating builds to workaround segfaults in windows and ghc-8.8.4
183183
- name: Build
184184
run: cabal build || cabal build || cabal build

0 commit comments

Comments
 (0)