Skip to content

Commit d1e6d3c

Browse files
Anton-Latukhajneiramergify[bot]
authored
CI: caching: add early termination & run check on schedule (#2506)
* CI: caching: add early termination * 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. Co-authored-by: Javier Neira <atreyu.bbb@gmail.com> Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
1 parent 070f16f commit d1e6d3c

File tree

1 file changed

+20
-3
lines changed

1 file changed

+20
-3
lines changed

.github/workflows/caching.yml

+20-3
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,18 @@ on:
3030
push:
3131
branches:
3232
- master
33+
schedule:
34+
# Refresh snapshot every (02+8*x):25 UTC
35+
# When cache is present it is a light check workflow with early termination.
36+
# When primary cache is not hit - runs the cache generation.
37+
# Why: GitHub repo has 10G pool & on overflow GitHub removes caches in FIFO manner.
38+
# When internal branche PRs save into the same pool -
39+
# their cache is accessible only inside of the scope of the PR.
40+
# If main cache is forced out - there are no cache shared between PRs,
41+
# which implies all PRs would start to create & save their cache.
42+
# Reinstitution of the main chache puts it back into FIFO
43+
# & so it gets shared across all PRs.
44+
- cron: "25 2/8 * * *"
3345

3446
env:
3547
cabalBuild: "v2-build all --enable-tests --enable-benchmarks"
@@ -130,6 +142,7 @@ jobs:
130142
restore-keys: ${{ env.cache-name }}-
131143

132144
- name: Compiled deps cache
145+
id: compiled-deps
133146
uses: actions/cache@v2
134147
env:
135148
cache-name: compiled-deps
@@ -141,9 +154,12 @@ jobs:
141154
${{ env.cache-name }}-${{ runner.os }}-${{ matrix.ghc }}-
142155
${{ env.cache-name }}-${{ runner.os }}-
143156
144-
- run: cabal update
157+
- if: (! steps.compiled-deps.outputs.cache-hit)
158+
run: |
159+
cabal update
145160
146-
- name: Download all sources
161+
- if: (! steps.compiled-deps.outputs.cache-hit)
162+
name: Download all sources
147163
run: |
148164
cabal $cabalBuild --only-download
149165
@@ -152,7 +168,8 @@ jobs:
152168
# but to cache what can be cached, so step is fault tolerant & would always succseed.
153169
# 2021-12-11: NOTE: Building all targets, since
154170
# current Cabal does not allow `all --enable-tests --enable-benchmarks --only-dependencies`
155-
- name: Build all targets; try 3 times
171+
- if: (! steps.compiled-deps.outputs.cache-hit)
172+
name: Build all targets; try 3 times
156173
continue-on-error: true
157174
run: |
158175
cabal $cabalBuild || cabal $cabalBuild || cabal $cabalBuild

0 commit comments

Comments
 (0)