|
7 | 7 | pull_request: |
8 | 8 |
|
9 | 9 | jobs: |
| 10 | + # Broadly copied from https://github.com/haskell/actions/tree/main/setup |
10 | 11 | build: |
11 | 12 |
|
12 | 13 | runs-on: ${{ matrix.os }} |
13 | | - |
14 | 14 | strategy: |
15 | 15 | fail-fast: false |
16 | 16 | matrix: |
17 | | - ghc: ['9.6', '9.4', '9.2', '9.0', '8.10'] |
| 17 | + ghc-version: ['9.6', '9.4', '9.2', '9.0', '8.10'] |
18 | 18 | # Unlikely that we'll succeed on windows and fail on macos, |
19 | 19 | # including it is just burning CI time. But windows could have |
20 | 20 | # path or IO issues, so worth including |
21 | 21 | os: [ubuntu-latest, windows-latest] |
22 | 22 |
|
23 | 23 | steps: |
24 | | - - uses: actions/checkout@v3 |
25 | | - - uses: haskell/actions/setup@v2 |
26 | | - with: |
27 | | - ghc-version: ${{ matrix.ghc }} |
28 | | - |
29 | | - - name: Cabal cache |
30 | | - uses: actions/cache@v3 |
31 | | - env: |
32 | | - cache-name: cache-cabal |
33 | | - with: |
34 | | - path: ~/.cabal |
35 | | - key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/*.cabal') }}-${{ hashFiles('**/cabal.project') }} |
36 | | - restore-keys: | |
37 | | - ${{ runner.os }}-build-${{ env.cache-name }}- |
38 | | -
|
39 | | - - name: Cabal update |
40 | | - run: cabal update |
41 | | - - name: Build using cabal |
42 | | - run: cabal build all |
43 | | - - name: Test |
44 | | - run: cabal test all |
| 24 | + - uses: actions/checkout@v3 |
| 25 | + |
| 26 | + - name: Set up Haskell toolchain |
| 27 | + uses: haskell/actions/setup@v2 |
| 28 | + id: setup |
| 29 | + with: |
| 30 | + ghc-version: ${{ matrix.ghc-version }} |
| 31 | + |
| 32 | + - name: Configure the build |
| 33 | + run: | |
| 34 | + cabal build all --dry-run |
| 35 | + # The last step generates dist-newstyle/cache/plan.json for the cache key. |
| 36 | + |
| 37 | + - name: Restore cached dependencies |
| 38 | + uses: actions/cache/restore@v3 |
| 39 | + id: cache |
| 40 | + env: |
| 41 | + key: ${{ runner.os }}-ghc-${{ steps.setup.outputs.ghc-version }}-cabal-${{ steps.setup.outputs.cabal-version }} |
| 42 | + with: |
| 43 | + path: ${{ steps.setup.outputs.cabal-store }} |
| 44 | + key: ${{ env.key }}-plan-${{ hashFiles('**/plan.json') }} |
| 45 | + restore-keys: ${{ env.key }}- |
| 46 | + |
| 47 | + - name: Install dependencies |
| 48 | + run: cabal build all --only-dependencies |
| 49 | + |
| 50 | + # Cache dependencies already here, so that we do not have to rebuild them should the subsequent steps fail. |
| 51 | + - name: Save cached dependencies |
| 52 | + uses: actions/cache/save@v3 |
| 53 | + # Caches are immutable, trying to save with the same key would error. |
| 54 | + if: ${{ steps.cache.outputs.cache-primary-key != steps.cache.outputs.cache-matched-key }} |
| 55 | + with: |
| 56 | + path: ${{ steps.setup.outputs.cabal-store }} |
| 57 | + key: ${{ steps.cache.outputs.cache-primary-key }} |
| 58 | + |
| 59 | + - name: Build |
| 60 | + run: cabal build all |
| 61 | + |
| 62 | + - name: Run tests |
| 63 | + run: cabal test all |
45 | 64 |
|
46 | 65 | haskell_post_job: |
47 | 66 | runs-on: ubuntu-latest |
|
0 commit comments