@@ -14,30 +14,44 @@ jobs:
14
14
name : GHC ${{ matrix.ghc }} on ${{ matrix.os }}
15
15
steps :
16
16
17
- - uses : actions/checkout@v3
17
+ - uses : actions/checkout@v4
18
18
19
- - uses : haskell/actions/setup@v2
19
+ - name : Set up GHC ${{ matrix.ghc-version }}
20
+ uses : haskell-actions/setup@v2
21
+ id : setup
20
22
with :
21
23
ghc-version : ${{ matrix.ghc }}
22
24
cabal-version : ' 3.10.3.0'
23
25
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
26
35
env :
27
- cache-name : cache- cabal
36
+ key : ${{ runner.os }}-ghc-${{ steps.setup.outputs.ghc-version }}- cabal-${{ steps.setup.outputs.cabal-version }}
28
37
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 }}-
36
41
37
42
- 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 }}
41
55
42
56
- name : Build
43
57
run : cabal build --enable-tests --enable-benchmarks all
46
60
# 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.
47
61
run : cabal test --enable-tests -f-hlint all
48
62
49
- - if : matrix.ghc != '8.4.4'
63
+ # - name: Check cabal file
64
+ # run: cabal check
65
+
66
+ - name : Build documentation
50
67
# 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