Skip to content

Commit a74d9d9

Browse files
author
Gaël Deest
authored
Merge pull request #1402 from haskell-servant/fix-ci
Basic GitHub actions-based CI
2 parents 27173c9 + 507990c commit a74d9d9

File tree

9 files changed

+168
-488
lines changed

9 files changed

+168
-488
lines changed

.github/workflows/main.yml

Lines changed: 152 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,152 @@
1+
name: CI
2+
3+
# Trigger the workflow on push or pull request, but only for the master branch
4+
on:
5+
pull_request:
6+
push:
7+
branches: [master]
8+
9+
jobs:
10+
cabal:
11+
name: ${{ matrix.os }} / ghc ${{ matrix.ghc }}
12+
runs-on: ${{ matrix.os }}
13+
strategy:
14+
matrix:
15+
os: [ubuntu-latest]
16+
cabal: ["3.2"]
17+
ghc:
18+
- "8.0.2"
19+
- "8.2.2"
20+
- "8.4.4"
21+
- "8.6.5"
22+
- "8.8.4"
23+
- "8.10.2"
24+
25+
steps:
26+
- uses: actions/checkout@v2
27+
28+
- uses: haskell/actions/setup@v1
29+
id: setup-haskell-cabal
30+
name: Setup Haskell
31+
with:
32+
ghc-version: ${{ matrix.ghc }}
33+
cabal-version: ${{ matrix.cabal }}
34+
35+
- name: Configure
36+
run: |
37+
cabal configure --enable-tests --enable-benchmarks --test-show-details=direct
38+
cabal install --ignore-project -j2 doctest --constraint='doctest ^>=0.17'
39+
40+
- name: Freeze
41+
run: |
42+
cabal freeze
43+
44+
- uses: actions/[email protected]
45+
name: Cache ~/.cabal/store
46+
with:
47+
path: ${{ steps.setup-haskell-cabal.outputs.cabal-store }}
48+
key: ${{ runner.os }}-${{ matrix.ghc }}-${{ hashFiles('cabal.project.freeze') }}
49+
50+
- name: Build
51+
run: |
52+
cabal build all
53+
54+
- name: Test
55+
run: |
56+
cabal test all
57+
58+
- name: Run doctests
59+
run: |
60+
# Necessary for doctest to be found in $PATH
61+
export PATH="$HOME/.cabal/bin:$PATH"
62+
63+
# Filter out base-compat-batteries from .ghc.environment.*, as its modules
64+
# conflict with those of base-compat.
65+
#
66+
# FIXME: This is an ugly hack. Ultimately, we'll want to use cabal-doctest
67+
# (or cabal v2-doctest, if it ever lands) to provide a clean GHC environment.
68+
# This might allow running doctests in GHCJS build as well.
69+
perl -i -e 'while (<ARGV>) { print unless /package-id\s+(base-compat-batteries)-\d+(\.\d+)*/; }' .ghc.environment.*
70+
71+
(cd servant && doctest src)
72+
(cd servant-client && doctest src)
73+
(cd servant-client-core && doctest src)
74+
(cd servant-http-streams && doctest src)
75+
(cd servant-docs && doctest src)
76+
(cd servant-foreign && doctest src)
77+
(cd servant-server && doctest src)
78+
(cd servant-machines && doctest src)
79+
(cd servant-conduit && doctest src)
80+
(cd servant-pipes && doctest src)
81+
82+
stack:
83+
name: stack / ghc ${{ matrix.ghc }}
84+
runs-on: ubuntu-latest
85+
strategy:
86+
matrix:
87+
stack: ["2.3.1"]
88+
ghc: ["8.8.4"]
89+
90+
steps:
91+
- uses: actions/checkout@v2
92+
93+
- uses: haskell/actions/setup@v1
94+
name: Setup Haskell Stack
95+
with:
96+
ghc-version: ${{ matrix.ghc }}
97+
stack-version: ${{ matrix.stack }}
98+
99+
- uses: actions/[email protected]
100+
name: Cache ~/.stack
101+
with:
102+
path: ~/.stack
103+
key: ${{ runner.os }}-${{ matrix.ghc }}-stack
104+
105+
- name: Install dependencies
106+
run: |
107+
stack build --system-ghc --test --bench --no-run-tests --no-run-benchmarks --only-dependencies
108+
109+
- name: Build
110+
run: |
111+
stack build --system-ghc --test --bench --no-run-tests --no-run-benchmarks
112+
113+
- name: Test
114+
run: |
115+
stack test --system-ghc
116+
117+
ghcjs:
118+
name: cabal / ghcjs 8.4
119+
runs-on: "ubuntu-18.04"
120+
121+
steps:
122+
- uses: actions/checkout@v2
123+
- name: "Setup PATH"
124+
run: |
125+
echo "PATH=$HOME/.cabal/bin:$PATH" >> $GITHUB_ENV
126+
127+
- name: Install tools
128+
run: |
129+
sudo add-apt-repository ppa:hvr/ghcjs
130+
sudo apt-get update -y
131+
sudo apt-get install ghcjs-8.4
132+
sudo apt-get install cabal-install
133+
134+
# Override cabal.project with the lightweight GHCJS one
135+
cp cabal.ghcjs.project cabal.project
136+
cat cabal.project
137+
138+
cabal v2-update
139+
cabal v2-install -w /opt/ghc/8.4.4/bin/ghc --ignore-project cabal-plan --constraint='cabal-plan ^>=0.6.0.0' --constraint='cabal-plan +exe'
140+
cabal v2-install -w /opt/ghc/8.4.4/bin/ghc --ignore-project hspec-discover
141+
142+
- name: Build
143+
run: |
144+
cabal v2-build --ghcjs -w /opt/ghcjs/8.4/bin/ghcjs --enable-tests --enable-benchmarks all
145+
146+
- name: Run tests
147+
run: |
148+
# cabal v2-test does not work with GHCJS
149+
# See: https://github.com/haskell/cabal/issues/6175
150+
#
151+
# This invokes cabal-plan to figure out test binaries, and invokes them with node.
152+
cabal-plan list-bins '*:test:*' | while read -r line; do testpkg=$(echo "$line" | perl -pe 's/:.*//'); testexe=$(echo "$line" | awk '{ print $2 }'); echo "testing $textexe in package $textpkg"; (cd "$(pkgdir $testpkg)" && nodejs "$testexe".jsexe/all.js); done

0 commit comments

Comments
 (0)