Skip to content

Commit 5020c3a

Browse files
committed
CI: caching: dodge all && test && benchmark dep inconsistencies
`test` workflow does essentially `cabal v2-build --enable-tests` by target. `bench` workflow does essentiall `cabal v2-build --enable-benchmarks` by target. Using `all --enable-tests --enable-benchmarks` requires total consistency These changes are to make `caching` able to work when `test` & `bench` deps versions are inconsistent (which is how CI & people use them - separately). Or to be able to cache inside WIP PRs. For example look inside the CI thread inside the #2503
1 parent 2aaa5b8 commit 5020c3a

File tree

1 file changed

+9
-13
lines changed

1 file changed

+9
-13
lines changed

.github/workflows/caching.yml

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -128,11 +128,8 @@ jobs:
128128
- name: Form the package list ('cabal.project.freeze')
129129
continue-on-error: true
130130
run: |
131-
cabal v2-freeze
132-
echo ''
133-
echo 'Output:'
134-
echo ''
135-
cat 'cabal.project.freeze'
131+
cabal v2-freeze && echo '' && echo 'Output:' && echo '' && cat 'cabal.project.freeze' && echo '' || echo 'WARNING: Could not produce the `freeze`.
132+
true
136133
137134
# 2021-12-02: NOTE: Cabal Hackage source tree storage does not depend on OS or GHC really,
138135
# but can depend on `base`.
@@ -165,25 +162,24 @@ jobs:
165162
166163
- if: steps.compiled-deps.outputs.cache-hit != 'true'
167164
run: |
168-
cabal update
165+
cabal v2-update
169166
170167
- if: steps.compiled-deps.outputs.cache-hit != 'true'
171168
name: Download all sources
172169
run: |
173-
cabal $cabalBuild --only-download
170+
cabal $cabalBuild --only-download || cabal v2-build all --enable-tests --only-download || cabal v2-build all --enable-benchmarks --only-download || cabal v2-build all || cabal v2-build --enable-tests --enable-benchmarks || cabal v2-build --enable-tests
174171
175172
# repeating builds to workaround segfaults in windows and ghc-8.8.4
176173
# This build agenda in not to have successful code,
177174
# but to cache what can be cached, so step is fault tolerant & would always succseed.
178175
# 2021-12-11: NOTE: Building all targets, since
179176
# current Cabal does not allow `all --enable-tests --enable-benchmarks --only-dependencies`
177+
#
178+
# Additional commands are: to caching anything possible when `tests` deeps do not match with `benchmarks`
179+
# or when manually run inside inconsistent dep conf PRs to return a positive error code eventually.
180+
# Reminder: the `||` work analog to `<|>`, running comments from the left.
180181
- if: steps.compiled-deps.outputs.cache-hit != 'true'
181182
name: Build all targets; try 3 times
182183
continue-on-error: true
183184
run: |
184-
cabal $cabalBuild || cabal $cabalBuild || cabal $cabalBuild
185-
186-
# Despite the `continue-on-error: true` directive - CI does not ignore the return code of the last step
187-
- name: Workaround to CI platform
188-
run: |
189-
true
185+
cabal $cabalBuild || cabal $cabalBuild || cabal $cabalBuild || cabal v2-build all --enable-tests --keep-going || cabal v2-build all --enable-benchmarks --keep-going || cabal v2-build all --keep-going || cabal v2-build --enable-tests --enable-benchmarks --keep-going || cabal v2-build --enable-tests --keep-going || cabal v2-build --keep-going

0 commit comments

Comments
 (0)