Skip to content

Commit 92e2caa

Browse files
committed
Build and test with cabal, not stack
1 parent 3d329a2 commit 92e2caa

File tree

2 files changed

+129
-44
lines changed

2 files changed

+129
-44
lines changed

.github/workflows/cabal.yaml

Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
name: CI
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches: [ master ]
7+
8+
# Cancel any in-progress run on the same branch/PR when new commits arrive
9+
concurrency:
10+
group: ${{ github.workflow }}-${{ github.head_ref || github.ref }}
11+
cancel-in-progress: true
12+
13+
jobs:
14+
cabal:
15+
strategy:
16+
fail-fast: false
17+
matrix:
18+
ghc: ['9.8','9.6','9.4','9.2','8.8']
19+
# Base set of OSes
20+
os: [ubuntu-latest, macos-13, windows-latest]
21+
# Also build on Apple Silicon where supported (GHC >= 9.2)
22+
include:
23+
- os: macos-latest
24+
ghc: '9.8'
25+
- os: macos-latest
26+
ghc: '9.6'
27+
- os: macos-latest
28+
ghc: '9.4'
29+
- os: macos-latest
30+
ghc: '9.2'
31+
runs-on: ${{ matrix.os }}
32+
33+
steps:
34+
- uses: actions/checkout@v4
35+
36+
- name: Setup Haskell
37+
id: setup
38+
uses: haskell-actions/[email protected]
39+
with:
40+
ghc-version: ${{ matrix.ghc }}
41+
cabal-version: latest
42+
43+
# Cache Cabal store (from setup output) + dist-newstyle, cross-platform
44+
- name: Cache Cabal store and dist
45+
uses: actions/cache@v4
46+
with:
47+
path: |
48+
${{ steps.setup.outputs.cabal-store }}
49+
dist-newstyle
50+
key: ${{ runner.os }}-ghc-${{ matrix.ghc }}-cabal-${{ hashFiles('**/*.cabal','**/cabal.project*') }}
51+
restore-keys: |
52+
${{ runner.os }}-ghc-${{ matrix.ghc }}-cabal-
53+
54+
- name: cabal update
55+
run: cabal update
56+
57+
# Ensure solver includes tests/benches in all runs (fixes GHC 8.8 behaviour)
58+
- name: Enable tests/benchmarks
59+
shell: bash
60+
run: |
61+
echo "tests: True" >> cabal.project.local
62+
echo "benchmarks: True" >> cabal.project.local
63+
64+
- name: Build (deps)
65+
run: cabal build --only-dependencies --enable-tests --enable-benchmarks -j
66+
67+
- name: Build
68+
run: cabal build all --enable-tests --enable-benchmarks -j
69+
70+
- name: Test
71+
run: cabal test all --enable-tests --test-show-details=direct
72+
73+
- name: Package checks
74+
run: cabal check
75+
76+
- name: Make sdist
77+
run: cabal sdist
78+
79+
- name: Upload sdist artifact
80+
uses: actions/upload-artifact@v4
81+
with:
82+
name: sdist-${{ matrix.os }}-ghc-${{ matrix.ghc }}
83+
path: dist-newstyle/sdist/*.tar.gz
84+
if-no-files-found: error
85+
86+
# Build the produced sdist in a clean workspace to ensure the release tarball compiles
87+
sdist-build:
88+
needs: cabal
89+
strategy:
90+
fail-fast: false
91+
matrix:
92+
ghc: ['9.8','9.6','9.4','9.2','8.8']
93+
runs-on: ubuntu-latest
94+
95+
steps:
96+
- name: Setup Haskell
97+
id: setup
98+
uses: haskell-actions/[email protected]
99+
with:
100+
ghc-version: ${{ matrix.ghc }}
101+
cabal-version: latest
102+
103+
- name: Cache Cabal store (read-only for speed)
104+
uses: actions/cache@v4
105+
with:
106+
path: ${{ steps.setup.outputs.cabal-store }}
107+
key: ${{ runner.os }}-ghc-${{ matrix.ghc }}-cabal-${{ hashFiles('**/*.cabal','**/cabal.project*') }}
108+
restore-keys: |
109+
${{ runner.os }}-ghc-${{ matrix.ghc }}-cabal-
110+
111+
- name: Download sdist (from Linux job)
112+
uses: actions/download-artifact@v4
113+
with:
114+
name: sdist-ubuntu-latest-ghc-${{ matrix.ghc }}
115+
116+
- name: Build sdist in clean dir
117+
shell: bash
118+
run: |
119+
set -euo pipefail
120+
TARBALL="$(ls ./*.tar.gz | head -n1)"
121+
BASENAME="$(basename "$TARBALL" .tar.gz)"
122+
mkdir -p work
123+
tar -xzf "$TARBALL" -C work
124+
cd "work/$BASENAME"
125+
echo "tests: True" >> cabal.project.local
126+
echo "benchmarks: True" >> cabal.project.local
127+
cabal update
128+
cabal build all --enable-tests -j
129+
cabal test all --enable-tests --test-show-details=direct

.github/workflows/tests.yml

Lines changed: 0 additions & 44 deletions
This file was deleted.

0 commit comments

Comments
 (0)