Skip to content

Commit 13ede6d

Browse files
committed
Update CI to use GitHub Actions
1 parent 59eb3e4 commit 13ede6d

File tree

5 files changed

+111
-43
lines changed

5 files changed

+111
-43
lines changed

.github/workflows/tests.yml

Lines changed: 99 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -3,47 +3,114 @@ name: Tests
33
on:
44
pull_request:
55
push:
6-
branches:
7-
- master
6+
branches:
7+
- '**'
88

99
jobs:
1010
build:
11-
name: CI
11+
name: GHC ${{ matrix.ghc-version }} on ${{ matrix.os }}
1212
runs-on: ${{ matrix.os }}
1313
strategy:
1414
fail-fast: false
1515
matrix:
1616
os: [ubuntu-latest, macos-latest, windows-latest]
17-
args:
18-
- "--resolver ghc-9.8.1"
19-
- "--resolver ghc-9.6.3"
20-
- "--resolver ghc-9.4.7"
21-
- "--resolver ghc-9.2.8"
22-
- "--resolver ghc-9.0.1"
23-
- "--resolver ghc-8.10.4"
24-
- "--resolver ghc-8.8.4"
25-
- "--resolver ghc-8.6.5"
26-
- "--resolver ghc-8.4.4"
27-
- "--resolver ghc-8.2.2"
17+
ghc-version:
18+
- 'latest'
19+
- '9.8'
20+
- '9.6'
21+
- '9.4'
22+
- '9.2'
23+
- '9.0'
24+
- '8.10'
25+
- '8.8'
26+
- '8.6'
27+
- '8.4'
28+
- '8.2'
29+
30+
exclude:
31+
# Exclude GHC 8.2 on Windows (GHC bug: undefined reference to `__stdio_common_vswprintf_s')
32+
- os: windows-latest
33+
ghc-version: '8.2'
2834

2935
steps:
30-
- name: Clone project
31-
uses: actions/checkout@v4
36+
- uses: actions/checkout@v4
37+
38+
- name: Set up GHC ${{ matrix.ghc-version }}
39+
uses: haskell-actions/setup@v2
40+
id: setup
41+
with:
42+
ghc-version: ${{ matrix.ghc-version }}
43+
# Defaults, added for clarity:
44+
cabal-version: 'latest'
45+
cabal-update: true
46+
47+
- name: Set up autotools (Windows)
48+
if: ${{ runner.os == 'Windows' }}
49+
uses: msys2/setup-msys2@v2
50+
with:
51+
update: true
52+
install: >-
53+
autotools
54+
55+
- name: Run autoreconf (Windows)
56+
if: ${{ runner.os == 'Windows' }}
57+
run: autoreconf -i
58+
shell: "msys2 {0}"
3259

33-
- name: Build and run tests
34-
shell: bash
60+
- name: Run autoreconf (Linux & Mac)
61+
if: ${{ runner.os != 'Windows' }}
62+
run: autoreconf -i
63+
64+
- name: Configure the build
3565
run: |
36-
set -ex
37-
stack upgrade
38-
stack --version
39-
if [[ "${{ runner.os }}" = 'Windows' ]]
40-
then
41-
# Looks like a bug in Stack, this shouldn't break things
42-
ls C:/ProgramData/Chocolatey/bin/
43-
rm -rf C:/ProgramData/Chocolatey/bin/ghc*
44-
stack ${{ matrix.args }} exec pacman -- --sync --refresh --noconfirm autoconf
45-
fi
46-
stack build
47-
stack sdist --test-tarball
48-
cd test
49-
stack test --bench --no-run-benchmarks --haddock --no-terminal ${{ matrix.args }}
66+
cabal configure --enable-tests --enable-benchmarks --disable-documentation
67+
cabal build all --dry-run
68+
# The last step generates dist-newstyle/cache/plan.json for the cache key.
69+
70+
- name: Restore cached dependencies
71+
uses: actions/cache/restore@v3
72+
id: cache
73+
env:
74+
key: ${{ runner.os }}-ghc-${{ steps.setup.outputs.ghc-version }}-cabal-${{ steps.setup.outputs.cabal-version }}
75+
with:
76+
path: ${{ steps.setup.outputs.cabal-store }}
77+
key: ${{ env.key }}-plan-${{ hashFiles('**/plan.json') }}
78+
restore-keys: ${{ env.key }}-
79+
80+
- name: Install dependencies
81+
# If we had an exact cache hit, the dependencies will be up to date.
82+
if: steps.cache.outputs.cache-hit != 'true'
83+
run: cabal build process --only-dependencies
84+
85+
# Cache dependencies already here, so that we do not have to rebuild them should the subsequent steps fail.
86+
- name: Save cached dependencies
87+
uses: actions/cache/save@v3
88+
# If we had an exact cache hit, trying to save the cache would error because of key clash.
89+
if: steps.cache.outputs.cache-hit != 'true'
90+
with:
91+
path: ${{ steps.setup.outputs.cabal-store }}
92+
key: ${{ steps.cache.outputs.cache-primary-key }}
93+
94+
- name: Build
95+
run: cabal build process
96+
97+
- name: Run tests
98+
run: cabal run process-tests:test
99+
100+
# On Windows and with GHC >= 9.0, re-run the test-suite using WinIO.
101+
- name: Re-run tests with WinIO (Windows && GHC >= 9.0)
102+
if: ${{ runner.os == 'Windows' && matrix.ghc-version >= '9.0' }}
103+
run: cabal run process-tests:test -- +RTS --io-manager=native -RTS
104+
105+
- name: Source dist
106+
run: cabal sdist all --ignore-project
107+
108+
- name: Build documentation
109+
run: cabal haddock process
110+
111+
- name: Check process.cabal
112+
run: cabal check
113+
114+
- name: Check process-tests.cabal
115+
working-directory: ./test
116+
run: cabal check

cabal.project

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
packages: ., test

stack.yaml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,12 @@
11
resolver: ghc-9.2.3
2+
3+
packages:
4+
- .
5+
- test
6+
7+
extra-deps:
8+
- Cabal-3.6.3.0
9+
10+
allow-newer: True
11+
allow-newer-deps:
12+
- Cabal

test/process-tests.cabal

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@ test-suite test
2121
hs-source-dirs: .
2222
main-is: main.hs
2323
type: exitcode-stdio-1.0
24-
-- Add otherwise redundant bounds on base since GHC's build system runs
25-
-- `cabal check`, which mandates bounds on base.
2624
build-depends: base >= 4 && < 5
2725
, bytestring
2826
, deepseq

test/stack.yaml

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

0 commit comments

Comments
 (0)