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
15 changes: 9 additions & 6 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,7 +118,8 @@ jobs:
${{ env.cache-name }}-${{ runner.os }}-${{ matrix.ghc }}-
${{ env.cache-name }}-${{ runner.os }}-

- run: cabal update
- run: |
cabal v2-update

# max-backjumps is increased as a temporary solution
# for dependency resolution failure
Expand Down
44 changes: 28 additions & 16 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 @@ -182,25 +184,35 @@ jobs:

- if: steps.compiled-deps.outputs.cache-hit != 'true'
run: |
cabal update
cabal v2-update

- 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 $cabalBuild --enable-benchmarks --only-download

- 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 --enable-tests --only-download

# 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
continue-on-error: true

- if: steps.compiled-deps.outputs.cache-hit != 'true' && runner.os == 'Linux' && matrix.ghc == '8.10.7'
name: (For Bench workflow) Build benchmark targets
# 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
15 changes: 9 additions & 6 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,7 +179,8 @@ jobs:
${{ env.cache-name }}-${{ runner.os }}-${{ matrix.ghc }}-
${{ env.cache-name }}-${{ runner.os }}-

- run: cabal v2-update
- run: |
cabal v2-update

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