|
1 | 1 | name: Haskell CI
|
2 |
| - |
3 | 2 | on:
|
4 | 3 | push:
|
5 |
| - branches: [ master ] |
| 4 | + branches: [main, master] |
6 | 5 | pull_request:
|
7 |
| - branches: [ master ] |
| 6 | + branches: [main, master] |
| 7 | + |
| 8 | +permissions: |
| 9 | + contents: read |
8 | 10 |
|
9 | 11 | jobs:
|
10 | 12 | build:
|
11 |
| - |
12 |
| - runs-on: ubuntu-latest |
| 13 | + name: GHC ${{ matrix.ghc-version }} on ${{ matrix.os }} |
| 14 | + runs-on: ${{ matrix.os }} |
13 | 15 | strategy:
|
| 16 | + fail-fast: false |
14 | 17 | matrix:
|
15 |
| - cabal: |
16 |
| - [ "3.4" |
17 |
| - , "3.6" |
18 |
| - , "3.8" |
19 |
| - ] |
20 |
| - ghc: |
| 18 | + os: [ubuntu-latest] |
| 19 | + ghc-version: |
21 | 20 | [ "8.8"
|
22 | 21 | , "8.10"
|
23 | 22 | , "9.0"
|
24 | 23 | , "9.2"
|
25 | 24 | , "9.4"
|
26 | 25 | ]
|
27 |
| - exclude: |
28 |
| - - cabal: "3.4" |
29 |
| - ghc: "9.2" |
30 |
| - - cabal: "3.4" |
31 |
| - ghc: "9.4" |
32 |
| - - cabal: "3.6" |
33 |
| - ghc: "9.4" |
| 26 | + |
34 | 27 | steps:
|
35 |
| - - uses: actions/checkout@v3 |
36 |
| - with: |
37 |
| - submodules: 'recursive' |
38 |
| - - uses: haskell/actions/setup@v2 |
39 |
| - with: |
40 |
| - ghc-version: ${{ matrix.ghc }} |
41 |
| - cabal-version: ${{ matrix.cabal }} |
| 28 | + - uses: actions/checkout@v3 |
| 29 | + with: |
| 30 | + submodules: 'recursive' |
| 31 | + |
| 32 | + - name: Set up GHC ${{ matrix.ghc-version }} |
| 33 | + uses: haskell/actions/setup@v2 |
| 34 | + id: setup |
| 35 | + with: |
| 36 | + ghc-version: ${{ matrix.ghc-version }} |
| 37 | + # Defaults, added for clarity: |
| 38 | + cabal-version: 'latest' |
| 39 | + cabal-update: true |
| 40 | + |
| 41 | + - name: Check cabal file |
| 42 | + run: cabal check |
| 43 | + |
| 44 | + - name: Configure the build |
| 45 | + run: | |
| 46 | + cabal configure --enable-tests --enable-benchmarks --disable-documentation --flag=pedantic |
| 47 | + cabal build --dry-run |
| 48 | + # The last step generates dist-newstyle/cache/plan.json for the cache key. |
| 49 | + |
| 50 | + - name: Restore cached dependencies |
| 51 | + uses: actions/cache/restore@v3 |
| 52 | + id: cache |
| 53 | + env: |
| 54 | + key: ${{ runner.os }}-ghc-${{ steps.setup.outputs.ghc-version }}-cabal-${{ steps.setup.outputs.cabal-version }} |
| 55 | + with: |
| 56 | + path: ${{ steps.setup.outputs.cabal-store }} |
| 57 | + key: ${{ env.key }}-plan-${{ hashFiles('**/plan.json') }} |
| 58 | + restore-keys: ${{ env.key }}- |
| 59 | + |
| 60 | + - name: Install dependencies |
| 61 | + run: cabal build all --only-dependencies |
| 62 | + |
| 63 | + # Cache dependencies already here, so that we do not have to rebuild them should the subsequent steps fail. |
| 64 | + - name: Save cached dependencies |
| 65 | + uses: actions/cache/save@v3 |
| 66 | + # Caches are immutable, trying to save with the same key would error. |
| 67 | + if: ${{ steps.cache.outputs.cache-primary-key != steps.cache.outputs.cache-matched-key }} |
| 68 | + with: |
| 69 | + path: ${{ steps.setup.outputs.cabal-store }} |
| 70 | + key: ${{ steps.cache.outputs.cache-primary-key }} |
42 | 71 |
|
43 |
| - - name: Cache |
44 |
| - uses: actions/cache@v3 |
45 |
| - env: |
46 |
| - cache-name: cache-cabal |
47 |
| - with: |
48 |
| - path: ~/.cabal |
49 |
| - key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/*.cabal') }}-${{ hashFiles('**/cabal.project') }} |
50 |
| - restore-keys: | |
51 |
| - ${{ runner.os }}-build-${{ env.cache-name }}- |
52 |
| - ${{ runner.os }}-build- |
53 |
| - ${{ runner.os }}- |
| 72 | + - name: Build |
| 73 | + run: cabal build all |
54 | 74 |
|
55 |
| - - name: Configure |
56 |
| - run: | |
57 |
| - cabal update |
58 |
| - cabal configure --enable-tests --enable-benchmarks --flag=pedantic |
59 |
| - - name: Install dependencies |
60 |
| - run: | |
61 |
| - cabal build --only-dependencies |
62 |
| - - name: Build |
63 |
| - run: cabal build |
64 |
| - - name: Run spec test |
65 |
| - run: cabal test --test-option=--color --test-show-details=streaming spec |
| 75 | + - name: Run tests |
| 76 | + run: cabal test all --test-option=--color --test-show-details=streaming |
0 commit comments