@@ -15,7 +15,7 @@ For all other versions, this action utilizes [`ppa:hvr/ghc`](https://launchpad.n
1515
1616See [ action.yml] ( action.yml )
1717
18- Minimal:
18+ ### Minimal
1919
2020``` yaml
2121on : [push]
3030 - run : runhaskell Hello.hs
3131` ` `
3232
33- Basic:
33+ ### Basic
3434
3535` ` ` yaml
3636on : [push]
4848 - run : runhaskell Hello.hs
4949` ` `
5050
51- Basic with Stack:
51+ ### Basic with Stack
5252
5353` ` ` yaml
5454on : [push]
6868 - run : runhaskell Hello.hs
6969` ` `
7070
71- Matrix Testing:
71+ ### Matrix Testing
7272
7373` ` ` yaml
7474on : [push]
9696 - run : runhaskell Hello.hs
9797` ` `
9898
99+ ### Model cabal workflow with caching
100+
101+ ` ` ` yaml
102+ name : build
103+ on :
104+ push :
105+ branches : [main, master]
106+ pull_request :
107+ branches : [main, master]
108+
109+ permissions :
110+ contents : read
111+
112+ jobs :
113+ build :
114+ name : GHC ${{ matrix.ghc-version }} on ${{ matrix.os }}
115+ runs-on : ${{ matrix.os }}
116+ strategy :
117+ fail-fast : false
118+ matrix :
119+ os : [ubuntu-latest]
120+ ghc-version : ['9.4', '9.2', '9.0', '8.10']
121+
122+ include :
123+ - os : windows-latest
124+ ghc-version : ' 9.4'
125+ - os : macos-latest
126+ ghc-version : ' 9.4'
127+
128+ steps :
129+ - uses : actions/checkout@v3
130+
131+ - name : Set up GHC ${{ matrix.ghc-version }}
132+ uses : haskell/actions/setup@v2
133+ id : setup
134+ with :
135+ ghc-version : ${{ matrix.ghc-version }}
136+ # Defaults, added for clarity:
137+ cabal-version : ' latest'
138+ cabal-update : true
139+
140+ - name : Installed minor versions of GHC and Cabal
141+ shell : bash
142+ run : |
143+ GHC_VERSION=$(ghc --numeric-version)
144+ CABAL_VERSION=$(cabal --numeric-version)
145+ echo "GHC_VERSION=${GHC_VERSION}" >> "${GITHUB_ENV}"
146+ echo "CABAL_VERSION=${CABAL_VERSION}" >> "${GITHUB_ENV}"
147+
148+ - name : Configure the build
149+ run : |
150+ cabal configure --enable-tests --enable-benchmarks
151+ cabal build --dry-run
152+ # The last step generates dist-newstyle/cache/plan.json for the cache key.
153+
154+ - name : Restore cached dependencies
155+ uses : actions/cache/restore@v3
156+ id : cache
157+ with :
158+ path : ${{ steps.setup.outputs.cabal-store }}
159+ key : ${{ runner.os }}-ghc-${{ env.GHC_VERSION }}-cabal-${{ env.CABAL_VERSION }}-plan-${{ hashFiles('**/plan.json') }}
160+ restore-keys : |
161+ ${{ runner.os }}-ghc-${{ env.GHC_VERSION }}-cabal-${{ env.CABAL_VERSION }}-
162+
163+ - name : Install dependencies
164+ run : cabal build all --only-dependencies
165+
166+ # Cache dependencies already here, so that we do not have to rebuild them should the subsequent steps fail.
167+ - name : Save cached dependencies
168+ uses : actions/cache/save@v3
169+ # Caches are immutable, trying to save with the same key would error.
170+ if : ${{ !steps.cache.outputs.cache-hit
171+ || steps.cache.outputs.cache-primary-key != steps.cache.outputs.cache-matched-key }}
172+ with :
173+ path : ${{ steps.setup.outputs.cabal-store }}
174+ key : ${{ steps.cache.outputs.cache-primary-key }}
175+
176+ - name : Build
177+ run : cabal build all
178+
179+ - name : Run tests
180+ run : cabal test all
181+
182+ - name : Check cabal file
183+ run : cabal check
184+
185+ - name : Build documentation
186+ run : cabal haddock all
187+ ` ` `
188+
99189## Inputs
100190
101191| Name | Description | Type | Default |
0 commit comments