Skip to content

CI: caching: closer match work/CI guarantees #2536

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 9 commits into from
Dec 27, 2021
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