Skip to content

Commit 86eba78

Browse files
committed
Add new workflow with automatic GHC matrix generation
1 parent 0311a30 commit 86eba78

File tree

1 file changed

+72
-0
lines changed

1 file changed

+72
-0
lines changed

.github/workflows/main.yml

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
name: CI
2+
on:
3+
pull_request:
4+
branches:
5+
- master
6+
push:
7+
branches:
8+
- master
9+
10+
concurrency:
11+
group: build-${{ github.ref }}
12+
cancel-in-progress: true
13+
14+
jobs:
15+
generate-ghc-matrix:
16+
name: "Generate GHC matrix from .cabal file"
17+
outputs:
18+
matrix: ${{ steps.set-matrix.outputs.matrix }}
19+
runs-on: ubuntu-latest
20+
steps:
21+
- name: Extract the tested-with GHC versions
22+
id: set-matrix
23+
uses: kleidukos/[email protected]
24+
with:
25+
cabal-file: cassava-megaparsec.cabal
26+
ubuntu: true
27+
version: 0.1.6.0
28+
29+
build:
30+
name: GHC ${{ matrix.ghc }} on ${{ matrix.os }}
31+
needs: generate-ghc-matrix
32+
runs-on: ${{ matrix.os }}
33+
strategy:
34+
matrix: ${{ fromJSON(needs.generate-ghc-matrix.outputs.matrix) }}
35+
steps:
36+
- name: Checkout code
37+
uses: actions/checkout@v4
38+
- name: Setup Haskell tools
39+
uses: haskell-actions/setup@v2
40+
id: setup
41+
with:
42+
ghc-version: ${{ matrix.ghc }}
43+
cabal-version: 'latest'
44+
cabal-update: true
45+
- name: Configure the build
46+
run: |
47+
cabal configure --enable-tests --disable-documentation
48+
cabal build all --dry-run
49+
- name: Restore cached dependencies
50+
uses: actions/cache/restore@v4
51+
id: cache
52+
env:
53+
key: ${{ runner.os }}-ghc-${{ steps.setup.outputs.ghc-version }}-cabal-${{ steps.setup.outputs.cabal-version }}
54+
with:
55+
path: ${{ steps.setup.outputs.cabal-store }}
56+
key: ${{ env.key }}-plan-${{ hashFiles('**/plan.json') }}
57+
restore-keys: ${{ env.key }}-
58+
- name: Install dependencies
59+
if: steps.cache.outputs.cache-hit != 'true'
60+
run: cabal build all --only-dependencies
61+
- name: Save cached dependencies
62+
uses: actions/cache/save@v4
63+
if: steps.cache.outputs.cache-hit != 'true'
64+
with:
65+
path: ${{ steps.setup.outputs.cabal-store }}
66+
key: ${{ steps.cache.outputs.cache-primary-key }}
67+
- name: Build
68+
run: cabal build all
69+
- name: Run tests
70+
run: cabal test all
71+
env:
72+
ROLLBAR_TOKEN: ${{ secrets.ROLLBAR_TOKEN }}

0 commit comments

Comments
 (0)