@@ -13,32 +13,52 @@ jobs:
13
13
14
14
name : GHC ${{ matrix.ghc }} on ${{ matrix.os }}
15
15
steps :
16
- - uses : actions/checkout@v3
17
- - uses : haskell/actions/setup@v2
16
+ - uses : actions/checkout@v4
17
+
18
+ - name : Set up GHC ${{ matrix.ghc-version }}
19
+ uses : haskell-actions/setup@v2
20
+ id : setup
18
21
with :
19
22
ghc-version : ${{ matrix.ghc }}
20
- cabal-version : ' 3.10.1.0'
21
- - name : Cache
22
- uses : actions/cache@v3
23
+
24
+ - name : Configure the build
25
+ run : |
26
+ cabal configure --enable-tests --enable-benchmarks --enable-documentation
27
+ cabal build all --dry-run
28
+ # The last step generates dist-newstyle/cache/plan.json for the cache key.
29
+
30
+ - name : Restore cached dependencies
31
+ uses : actions/cache/restore@v4
32
+ id : cache
23
33
env :
24
- cache-name : cache- cabal
34
+ key : ${{ runner.os }}-ghc-${{ steps.setup.outputs.ghc-version }}- cabal-${{ steps.setup.outputs.cabal-version }}
25
35
with :
26
- path : ~/.cabal
27
- key : ${{ runner.os }}-${{ matrix.ghc }}-build-${{ env.cache-name }}-${{ hashFiles('**/*.cabal') }}-${{ hashFiles('**/cabal.project') }}
28
- restore-keys : |
29
- ${{ runner.os }}-${{ matrix.ghc }}-build-${{ env.cache-name }}-
30
- ${{ runner.os }}-${{ matrix.ghc }}-build-
31
- ${{ runner.os }}-${{ matrix.ghc }}-
32
- ${{ runner.os }}
36
+ path : ${{ steps.setup.outputs.cabal-store }}
37
+ key : ${{ env.key }}-plan-${{ hashFiles('**/plan.json') }}
38
+ restore-keys : ${{ env.key }}-
33
39
34
40
- name : Install dependencies
35
- run : cabal build --only-dependencies --enable-tests --enable-benchmarks
41
+ # If we had an exact cache hit, the dependencies will be up to date.
42
+ if : steps.cache.outputs.cache-hit != 'true'
43
+ run : cabal build all --only-dependencies
44
+
45
+ # Cache dependencies already here, so that we do not have to rebuild them should the subsequent steps fail.
46
+ - name : Save cached dependencies
47
+ uses : actions/cache/save@v4
48
+ # If we had an exact cache hit, trying to save the cache would error because of key clash.
49
+ if : steps.cache.outputs.cache-hit != 'true'
50
+ with :
51
+ path : ${{ steps.setup.outputs.cabal-store }}
52
+ key : ${{ steps.cache.outputs.cache-primary-key }}
53
+
36
54
- name : Build
37
- run : cabal build --enable-tests --enable-benchmarks all
55
+ run : cabal build all
56
+
38
57
- name : Run tests
39
- # 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.
40
- run : cabal test --enable-tests -f-hlint all
41
- - if : matrix.ghc != '8.4.4'
42
- # docs aren't built on ghc 8.4.4 because some dependency docs don't build on older GHCs
43
- name : Build Docs
44
- run : cabal haddock
58
+ run : cabal test all
59
+
60
+ - name : Check cabal file
61
+ run : cabal check
62
+
63
+ - name : Build documentation
64
+ run : cabal haddock all
0 commit comments