@@ -14,30 +14,44 @@ jobs:
1414 name : GHC ${{ matrix.ghc }} on ${{ matrix.os }}
1515 steps :
1616
17- - uses : actions/checkout@v3
17+ - uses : actions/checkout@v4
1818
19- - uses : haskell/actions/setup@v2
19+ - name : Set up GHC ${{ matrix.ghc-version }}
20+ uses : haskell-actions/setup@v2
21+ id : setup
2022 with :
2123 ghc-version : ${{ matrix.ghc }}
2224 cabal-version : ' 3.10.3.0'
2325
24- - name : Cache
25- uses : actions/cache@v3
26+ - name : Configure the build
27+ run : |
28+ cabal configure --enable-tests --enable-benchmarks --disable-documentation
29+ cabal build all --dry-run
30+ # The last step generates dist-newstyle/cache/plan.json for the cache key.
31+
32+ - name : Restore cached dependencies
33+ uses : actions/cache/restore@v4
34+ id : cache
2635 env :
27- cache-name : cache- cabal
36+ key : ${{ runner.os }}-ghc-${{ steps.setup.outputs.ghc-version }}- cabal-${{ steps.setup.outputs.cabal-version }}
2837 with :
29- path : ~/.cabal
30- key : ${{ runner.os }}-${{ matrix.ghc }}-build-${{ env.cache-name }}-${{ hashFiles('**/*.cabal') }}-${{ hashFiles('**/cabal.project') }}
31- restore-keys : |
32- ${{ runner.os }}-${{ matrix.ghc }}-build-${{ env.cache-name }}-
33- ${{ runner.os }}-${{ matrix.ghc }}-build-
34- ${{ runner.os }}-${{ matrix.ghc }}-
35- ${{ runner.os }}
38+ path : ${{ steps.setup.outputs.cabal-store }}
39+ key : ${{ env.key }}-plan-${{ hashFiles('**/plan.json') }}
40+ restore-keys : ${{ env.key }}-
3641
3742 - name : Install dependencies
38- run : |
39- cabal update
40- cabal build --only-dependencies --enable-tests --enable-benchmarks
43+ # If we had an exact cache hit, the dependencies will be up to date.
44+ if : steps.cache.outputs.cache-hit != 'true'
45+ run : cabal build --only-dependencies --enable-tests --enable-benchmarks
46+
47+ # Cache dependencies already here, so that we do not have to rebuild them should the subsequent steps fail.
48+ - name : Save cached dependencies
49+ uses : actions/cache/save@v4
50+ # If we had an exact cache hit, trying to save the cache would error because of key clash.
51+ if : steps.cache.outputs.cache-hit != 'true'
52+ with :
53+ path : ${{ steps.setup.outputs.cabal-store }}
54+ key : ${{ steps.cache.outputs.cache-primary-key }}
4155
4256 - name : Build
4357 run : cabal build --enable-tests --enable-benchmarks all
4660 # We don't run hlint tests, because different versions of hlint have different suggestions, and we don't want to worry about satisfying them all.
4761 run : cabal test --enable-tests -f-hlint all
4862
49- - if : matrix.ghc != '8.4.4'
63+ # - name: Check cabal file
64+ # run: cabal check
65+
66+ - name : Build documentation
5067 # docs aren't built on ghc 8.4.4 because some dependency docs don't build on older GHCs
51- name : Build Docs
52- run : cabal haddock
68+ if : matrix.ghc != '8.4.4'
69+ run : cabal haddock all
0 commit comments