From 05f73ba6b678302b070b914258b1d3e18c49e1e1 Mon Sep 17 00:00:00 2001 From: Anton-Latukha Date: Sun, 19 Dec 2021 14:15:24 +0200 Subject: [PATCH 1/2] CI: caching: add early termination --- .github/workflows/caching.yml | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/.github/workflows/caching.yml b/.github/workflows/caching.yml index b1a57c1906..ebecde0701 100644 --- a/.github/workflows/caching.yml +++ b/.github/workflows/caching.yml @@ -130,6 +130,7 @@ jobs: restore-keys: ${{ env.cache-name }}- - name: Compiled deps cache + id: compiled-deps uses: actions/cache@v2 env: cache-name: compiled-deps @@ -141,9 +142,12 @@ jobs: ${{ env.cache-name }}-${{ runner.os }}-${{ matrix.ghc }}- ${{ env.cache-name }}-${{ runner.os }}- - - run: cabal update + - if: (! steps.compiled-deps.outputs.cache-hit) + run: | + cabal update - - name: Download all sources + - if: (! steps.compiled-deps.outputs.cache-hit) + name: Download all sources run: | cabal $cabalBuild --only-download @@ -152,7 +156,8 @@ jobs: # 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` - - name: Build all targets; try 3 times + - if: (! steps.compiled-deps.outputs.cache-hit) + name: Build all targets; try 3 times continue-on-error: true run: | cabal $cabalBuild || cabal $cabalBuild || cabal $cabalBuild From bab815712383793923fbb36af94ce756fae80716 Mon Sep 17 00:00:00 2001 From: Anton-Latukha Date: Sat, 18 Dec 2021 22:25:30 +0200 Subject: [PATCH 2/2] CI: caching: run cache check 3 times a day Recently there is a lot of PRs/builds from internal repo branches. Repo cache has 10G pool limit & PR caches are not shared between PRs, but main branch cache is. Checking & when missing rebuilding it ensures that if internal branch PRs pushed main state out of the pool - it gets reinstituted. *afaik* there is no way to prioritize main branch cache better, since GitHub CI FIFO caches out of the pool by build time. --- .github/workflows/caching.yml | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/.github/workflows/caching.yml b/.github/workflows/caching.yml index ebecde0701..7fc49fda55 100644 --- a/.github/workflows/caching.yml +++ b/.github/workflows/caching.yml @@ -30,6 +30,18 @@ on: push: branches: - master + schedule: + # Refresh snapshot every (02+8*x):25 UTC + # When cache is present it is a light check workflow with early termination. + # When primary cache is not hit - runs the cache generation. + # Why: GitHub repo has 10G pool & on overflow GitHub removes caches in FIFO manner. + # When internal branche PRs save into the same pool - + # their cache is accessible only inside of the scope of the PR. + # If main cache is forced out - there are no cache shared between PRs, + # which implies all PRs would start to create & save their cache. + # Reinstitution of the main chache puts it back into FIFO + # & so it gets shared across all PRs. + - cron: "25 2/8 * * *" env: cabalBuild: "v2-build all --enable-tests --enable-benchmarks"