Skip to content

Commit

Permalink
CI: caching: closer match work/CI guarantees (#2536)
Browse files Browse the repository at this point in the history
* 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  <atreyu.bbb@gmail.com>

* CI: {caching, test, bench}: `haskell/actions/setup` does the update

* CI: caching: m fx

Co-authored-by: Javier Neira  <atreyu.bbb@gmail.com>
  • Loading branch information
Anton-Latukha and jneira committed Dec 27, 2021
1 parent 48c6eb1 commit f47bb47
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 33 deletions.
14 changes: 7 additions & 7 deletions .github/workflows/bench.yml
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,13 @@ jobs:
- name: Form the package list ('cabal.project.freeze')
continue-on-error: true
run: |
cabal v2-freeze
echo ''
echo 'Output:'
echo ''
cat 'cabal.project.freeze'
cabal v2-freeze && \
echo '' && \
echo 'Output:' && \
echo '' && \
cat 'cabal.project.freeze' && \
echo '' || \
echo 'WARNING: Could not produce the `freeze`.
- name: Hackage sources cache
uses: actions/cache@v2
Expand All @@ -116,8 +118,6 @@ jobs:
${{ env.cache-name }}-${{ runner.os }}-${{ matrix.ghc }}-
${{ env.cache-name }}-${{ runner.os }}-
- run: cabal update

# max-backjumps is increased as a temporary solution
# for dependency resolution failure
- run: cabal configure --enable-benchmarks --max-backjumps 12000
Expand Down
47 changes: 28 additions & 19 deletions .github/workflows/caching.yml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ on:
- cron: "25 2/8 * * *"

env:
cabalBuild: "v2-build all --enable-tests --enable-benchmarks --keep-going"
cabalBuild: "v2-build all --keep-going"

jobs:

Expand Down Expand Up @@ -145,11 +145,13 @@ jobs:
- name: Form the package list ('cabal.project.freeze')
continue-on-error: true
run: |
cabal v2-freeze
echo ''
echo 'Output:'
echo ''
cat 'cabal.project.freeze'
cabal v2-freeze && \
echo '' && \
echo 'Output:' && \
echo '' && \
cat 'cabal.project.freeze' && \
echo '' || \
echo 'WARNING: Could not produce the `freeze`.
# 2021-12-02: NOTE: Cabal Hackage source tree storage does not depend on OS or GHC really,
# but can depend on `base`.
Expand Down Expand Up @@ -180,27 +182,34 @@ jobs:
${{ env.cache-name }}-${{ runner.os }}-${{ matrix.ghc }}-
${{ env.cache-name }}-${{ runner.os }}-
- if: steps.compiled-deps.outputs.cache-hit != 'true'
- if: steps.compiled-deps.outputs.cache-hit != 'true' && runner.os == 'Linux' && matrix.ghc == '8.10.7'
name: Download sources for bench
# Downloaded separately, to match the tested work/PR workflow guarantees
run: |
cabal update
cabal $cabalBuild --only-download --enable-benchmarks
- if: steps.compiled-deps.outputs.cache-hit != 'true'
name: Download all sources
name: Download the rest of the sources
# Downloaded separately, to match the tested work/PR workflow guarantees
run: |
cabal $cabalBuild --only-download
cabal $cabalBuild --only-download --enable-tests
# repeating builds to workaround segfaults in windows and ghc-8.8.4
# This build agenda in not to have successful code,
# but to cache what can be cached, so step is fault tolerant & would always succseed.
# 2021-12-11: NOTE: Building all targets, since
# current Cabal does not allow `all --enable-tests --enable-benchmarks --only-dependencies`
- if: steps.compiled-deps.outputs.cache-hit != 'true'
name: Build all targets; try 3 times
# but to cache what can be cached, so step is fault tolerant & would always succeed.
# 2021-12-11: NOTE: Need to building all targets (build the project also), since
# current Cabal does not allow `all --enable-tests --enable-benchmarks --only-dependencies` combination

- if: steps.compiled-deps.outputs.cache-hit != 'true' && runner.os == 'Linux' && matrix.ghc == '8.10.7'
name: (For Bench workflow) Build benchmark targets
continue-on-error: true
# Downloaded separately, to match the tested work/PR workflow guarantees
run: |
cabal $cabalBuild || cabal $cabalBuild || cabal $cabalBuild
cabal $cabalBuild --enable-benchmarks || cabal $cabalBuild --enable-benchmarks || cabal $cabalBuild --enable-benchmarks
# Despite the `continue-on-error: true` directive - CI does not ignore the return code of the last step
- name: Workaround to CI platform
- if: steps.compiled-deps.outputs.cache-hit != 'true'
name: Build targets; try 3 times
continue-on-error: true
# Done separately, matching the tested work/PR workflow guarantees
run: |
true
cabal $cabalBuild --enable-test || cabal $cabalBuild --enable-test || cabal $cabalBuild --enable-test
14 changes: 7 additions & 7 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -149,11 +149,13 @@ jobs:
- name: Form the package list ('cabal.project.freeze')
continue-on-error: true
run: |
cabal v2-freeze
echo ''
echo 'Output:'
echo ''
cat 'cabal.project.freeze'
cabal v2-freeze && \
echo '' && \
echo 'Output:' && \
echo '' && \
cat 'cabal.project.freeze' && \
echo '' || \
echo 'WARNING: Could not produce the `freeze`.
- name: Hackage sources cache
uses: actions/cache@v2
Expand All @@ -177,8 +179,6 @@ jobs:
${{ env.cache-name }}-${{ runner.os }}-${{ matrix.ghc }}-
${{ env.cache-name }}-${{ runner.os }}-
- run: cabal v2-update

# repeating builds to workaround segfaults in windows and ghc-8.8.4
- name: Build
run: cabal build || cabal build || cabal build
Expand Down

0 comments on commit f47bb47

Please sign in to comment.