|
1 |
| -name: Cabal CI |
2 |
| - |
| 1 | +name: build |
3 | 2 | on:
|
4 | 3 | push:
|
5 |
| - branches: |
6 |
| - - master |
| 4 | + branches: [main, master] |
7 | 5 | pull_request:
|
| 6 | + branches: [main, master] |
| 7 | + |
| 8 | +# INFO: The following configuration block ensures that only one build runs per branch, |
| 9 | +# which may be desirable for projects with a costly build process. |
| 10 | +# Remove this block from the CI workflow to let each CI job run to completion. |
| 11 | +concurrency: |
| 12 | + group: build-${{ github.ref }} |
| 13 | + cancel-in-progress: true |
8 | 14 |
|
9 | 15 | jobs:
|
10 | 16 | build:
|
11 |
| - name: cabal-${{ matrix.cabal}} ${{ matrix.ghc }} ${{ matrix.os }} |
| 17 | + name: GHC ${{ matrix.ghc-version }} on ${{ matrix.os }} |
| 18 | + runs-on: ${{ matrix.os }} |
12 | 19 | strategy:
|
| 20 | + fail-fast: false |
13 | 21 | matrix:
|
14 |
| - os: [ubuntu-latest, macOS-latest] |
15 |
| - ghc: ["8.10.1", "8.8.1", "8.6.5", "8.6.4", "8.6.3", "8.6.2"] |
16 |
| - cabal: ["3.0", "3.2"] |
| 22 | + os: [ubuntu-latest] |
| 23 | + ghc-version: ['9.8', '9.6'] |
17 | 24 |
|
18 |
| - runs-on: ${{ matrix.os }} |
19 | 25 | steps:
|
20 |
| - - uses: actions/checkout@v1 |
21 |
| - - uses: actions/setup-haskell@v1 |
22 |
| - name: Setup Haskell |
23 |
| - with: |
24 |
| - ghc-version: ${{ matrix.ghc }} |
25 |
| - cabal-version: ${{ matrix.cabal }} |
26 |
| - |
27 |
| - - uses: actions/cache@v1 |
28 |
| - name: Cache ~/.cabal/packages |
29 |
| - with: |
30 |
| - path: ~/.cabal/packages |
31 |
| - key: cabal-packages-${{ matrix.ghc }} |
32 |
| - |
33 |
| - - uses: actions/cache@v1 |
34 |
| - name: Cache ~/.cabal/store |
35 |
| - with: |
36 |
| - path: ~/.cabal/store |
37 |
| - key: cabal-store-${{ matrix.ghc }} |
38 |
| - |
39 |
| - - uses: actions/cache@v1 |
40 |
| - name: Cache dist-newstyle |
41 |
| - with: |
42 |
| - path: dist-newstyle |
43 |
| - key: dist-newstyle-${{ matrix.ghc }} |
44 |
| - |
45 |
| - - name: Install dependencies |
46 |
| - run: | |
47 |
| - cabal update |
48 |
| - - name: Build |
49 |
| - run: | |
50 |
| - cabal new-install tasty-discover |
51 |
| - cabal new-build |
| 26 | + - uses: actions/checkout@v4 |
| 27 | + |
| 28 | + - name: Set up GHC ${{ matrix.ghc-version }} |
| 29 | + uses: haskell-actions/setup@v2 |
| 30 | + id: setup |
| 31 | + with: |
| 32 | + ghc-version: ${{ matrix.ghc-version }} |
| 33 | + # Defaults, added for clarity: |
| 34 | + cabal-version: 'latest' |
| 35 | + cabal-update: true |
| 36 | + |
| 37 | + - name: Configure the build |
| 38 | + run: | |
| 39 | + cabal configure --enable-tests --enable-benchmarks --disable-documentation |
| 40 | + cabal build all --dry-run |
| 41 | + # The last step generates dist-newstyle/cache/plan.json for the cache key. |
| 42 | + |
| 43 | + - name: Restore cached dependencies |
| 44 | + uses: actions/cache/restore@v3 |
| 45 | + id: cache |
| 46 | + env: |
| 47 | + key: ${{ runner.os }}-ghc-${{ steps.setup.outputs.ghc-version }}-cabal-${{ steps.setup.outputs.cabal-version }} |
| 48 | + with: |
| 49 | + path: ${{ steps.setup.outputs.cabal-store }} |
| 50 | + key: ${{ env.key }}-plan-${{ hashFiles('**/plan.json') }} |
| 51 | + restore-keys: ${{ env.key }}- |
| 52 | + |
| 53 | + - name: Install dependencies |
| 54 | + # If we had an exact cache hit, the dependencies will be up to date. |
| 55 | + if: steps.cache.outputs.cache-hit != 'true' |
| 56 | + run: cabal build all --only-dependencies |
| 57 | + |
| 58 | + # Cache dependencies already here, so that we do not have to rebuild them should the subsequent steps fail. |
| 59 | + - name: Save cached dependencies |
| 60 | + uses: actions/cache/save@v3 |
| 61 | + # If we had an exact cache hit, trying to save the cache would error because of key clash. |
| 62 | + if: steps.cache.outputs.cache-hit != 'true' |
| 63 | + with: |
| 64 | + path: ${{ steps.setup.outputs.cabal-store }} |
| 65 | + key: ${{ steps.cache.outputs.cache-primary-key }} |
| 66 | + |
| 67 | + - name: Build |
| 68 | + run: cabal build all |
| 69 | + |
| 70 | + - name: Test |
| 71 | + run: cabal test all |
0 commit comments