Skip to content

Commit a8f7893

Browse files
committed
1 parent e9a6368 commit a8f7893

File tree

1 file changed

+78
-0
lines changed

1 file changed

+78
-0
lines changed

.github/workflows/main.yml

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
name: build
2+
on:
3+
push:
4+
branches: [main, master]
5+
pull_request:
6+
branches: [main, master]
7+
8+
permissions:
9+
contents: read
10+
11+
jobs:
12+
build:
13+
name: GHC ${{ matrix.ghc-version }} on ${{ matrix.os }}
14+
runs-on: ${{ matrix.os }}
15+
strategy:
16+
fail-fast: false
17+
matrix:
18+
os: [ubuntu-latest]
19+
ghc-version: ['9.6', '9.4', '9.2', '9.0', '8.10']
20+
21+
include:
22+
- os: windows-latest
23+
ghc-version: '9.6'
24+
- os: macos-latest
25+
ghc-version: '9.6'
26+
27+
steps:
28+
- uses: actions/checkout@v3
29+
30+
- name: Set up GHC ${{ matrix.ghc-version }}
31+
uses: haskell/actions/setup@v2
32+
id: setup
33+
with:
34+
ghc-version: ${{ matrix.ghc-version }}
35+
# Defaults, added for clarity:
36+
cabal-version: 'latest'
37+
cabal-update: true
38+
39+
- name: Configure the build
40+
run: |
41+
cabal configure --enable-tests --enable-benchmarks --disable-documentation
42+
cabal build --dry-run
43+
# The last step generates dist-newstyle/cache/plan.json for the cache key.
44+
45+
- name: Restore cached dependencies
46+
uses: actions/cache/restore@v3
47+
id: cache
48+
env:
49+
key: ${{ runner.os }}-ghc-${{ steps.setup.outputs.ghc-version }}-cabal-${{ steps.setup.outputs.cabal-version }}
50+
with:
51+
path: ${{ steps.setup.outputs.cabal-store }}
52+
key: ${{ env.key }}-plan-${{ hashFiles('**/plan.json') }}
53+
restore-keys: ${{ env.key }}-
54+
55+
- name: Install dependencies
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+
# Caches are immutable, trying to save with the same key would error.
62+
if: ${{ steps.cache.outputs.cache-primary-key != steps.cache.outputs.cache-matched-key }}
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: Run tests
71+
run: cabal test all
72+
73+
- name: Check cabal file
74+
run: cabal check
75+
continue-on-error: true
76+
77+
- name: Build documentation
78+
run: cabal haddock all

0 commit comments

Comments
 (0)