Skip to content

Commit 6eef243

Browse files
committed
Added cache to github actions
1 parent 8f57a07 commit 6eef243

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

.github/workflows/haskell.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,9 @@ jobs:
1313
os: [ubuntu-latest, macos-latest, windows-latest]
1414

1515
steps:
16+
- name: Set cache version
17+
run: echo "CACHE_VERSION=pu4Aevoo" >> $GITHUB_ENV
18+
1619
- name: "Setup haskell"
1720
uses: haskell/actions/setup@v1
1821
id: setup-haskell
@@ -27,6 +30,29 @@ jobs:
2730
cat ./.github/workflows/cabal.project.local > ./cabal.project.local
2831
cat ./cabal.project.local
2932
33+
- name: Record dependencies
34+
id: record-deps
35+
run: |
36+
cabal build all --dry-run
37+
cat dist-newstyle/cache/plan.json | jq -r '."install-plan"[].id' | sort | uniq > dependencies.txt
38+
echo "::set-output name=weeknum::$(/bin/date -u "+%W")"
39+
40+
- uses: actions/cache@v3
41+
name: "Cache `cabal store`"
42+
with:
43+
path: ${{ runner.os == 'Windows' && steps.win-setup-haskell.outputs.cabal-store || steps.setup-haskell.outputs.cabal-store }}
44+
key: cache-dependencies-${{ env.CACHE_VERSION }}-${{ runner.os }}-${{ matrix.ghc }}-${{ hashFiles('dependencies.txt') }}
45+
restore-keys: cache-dependencies-${{ env.CACHE_VERSION }}-${{ runner.os }}-${{ matrix.ghc }}
46+
47+
- uses: actions/cache@v3
48+
name: "Cache `dist-newstyle`"
49+
with:
50+
path: |
51+
dist-newstyle
52+
!dist-newstyle/**/.git
53+
key: cache-dist-${{ env.CACHE_VERSION }}-${{ runner.os }}-${{ matrix.ghc }}-${{ steps.record-deps.outputs.weeknum }}
54+
restore-keys: cache-dist-${{ env.CACHE_VERSION }}-${{ runner.os }}-${{ matrix.ghc }}
55+
3056
- name: Build dependencies
3157
run: cabal build --only-dependencies all
3258

0 commit comments

Comments
 (0)