servant/.github/workflows/master.yml

176 lines
5.2 KiB
YAML
Raw Normal View History

name: CI
2021-03-17 21:32:04 +01:00
# Trigger the workflow on push or pull request, but only for the master branch
on:
pull_request:
push:
branches: [master]
jobs:
cabal:
name: ${{ matrix.os }} / ghc ${{ matrix.ghc }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
2021-03-16 10:23:23 +01:00
os: [ubuntu-latest]
cabal: ["3.2"]
ghc:
2021-03-16 18:32:21 +01:00
- "8.0.2"
- "8.2.2"
- "8.4.4"
- "8.6.5"
- "8.8.4"
- "8.10.2"
steps:
- uses: actions/checkout@v2
- uses: haskell/actions/setup@v1
id: setup-haskell-cabal
name: Setup Haskell
with:
ghc-version: ${{ matrix.ghc }}
cabal-version: ${{ matrix.cabal }}
- name: Freeze
run: |
2021-03-18 11:41:18 +01:00
cabal configure --enable-tests --enable-benchmarks --test-show-details=direct
cabal freeze
- uses: actions/cache@v2.1.3
2021-03-18 11:41:18 +01:00
name: Cache ~/.cabal/store and dist-newstyle
with:
2021-03-18 11:41:18 +01:00
path: |
${{ steps.setup-haskell-cabal.outputs.cabal-store }}
dist-newstyle
key: ${{ runner.os }}-${{ matrix.ghc }}-${{ hashFiles('cabal.project.freeze') }}
2021-03-18 11:41:18 +01:00
restore-keys: |
${{ runner.os }}-${{ matrix.ghc }}-
- name: Configure
run: |
cabal install --ignore-project -j2 doctest --constraint='doctest ^>=0.17'
- name: Build
run: |
cabal build all
- name: Test
run: |
cabal test all
2021-03-16 10:23:23 +01:00
- name: Run doctests
run: |
# Necessary for doctest to be found in $PATH
export PATH="$HOME/.cabal/bin:$PATH"
# Filter out base-compat-batteries from .ghc.environment.*, as its modules
# conflict with those of base-compat.
#
# FIXME: This is an ugly hack. Ultimately, we'll want to use cabal-doctest
# (or cabal v2-doctest, if it ever lands) to provide a clean GHC environment.
# This might allow running doctests in GHCJS build as well.
perl -i -e 'while (<ARGV>) { print unless /package-id\s+(base-compat-batteries)-\d+(\.\d+)*/; }' .ghc.environment.*
(cd servant && doctest src)
(cd servant-client && doctest src)
(cd servant-client-core && doctest src)
(cd servant-http-streams && doctest src)
(cd servant-docs && doctest src)
(cd servant-foreign && doctest src)
(cd servant-server && doctest src)
(cd servant-machines && doctest src)
(cd servant-conduit && doctest src)
(cd servant-pipes && doctest src)
stack:
name: stack / ghc ${{ matrix.ghc }}
runs-on: ubuntu-latest
strategy:
matrix:
stack: ["2.3.1"]
ghc: ["8.8.4"]
steps:
- uses: actions/checkout@v2
- uses: haskell/actions/setup@v1
name: Setup Haskell Stack
with:
ghc-version: ${{ matrix.ghc }}
stack-version: ${{ matrix.stack }}
- uses: actions/cache@v2.1.3
name: Cache ~/.stack
with:
path: ~/.stack
key: ${{ runner.os }}-${{ matrix.ghc }}-stack
- name: Install dependencies
run: |
stack build --system-ghc --test --bench --no-run-tests --no-run-benchmarks --only-dependencies
- name: Build
run: |
stack build --system-ghc --test --bench --no-run-tests --no-run-benchmarks
- name: Test
run: |
stack test --system-ghc
2021-03-17 10:28:04 +01:00
ghcjs:
2021-03-18 11:41:18 +01:00
name: ubuntu-18.04 / ghcjs 8.4
2021-03-17 10:28:04 +01:00
runs-on: "ubuntu-18.04"
steps:
- uses: actions/checkout@v2
2021-03-18 11:41:18 +01:00
2021-03-17 21:32:04 +01:00
- name: "Setup PATH"
run: |
2021-03-18 11:41:18 +01:00
echo "PATH=$HOME/.cabal/bin:/opt/ghcjs/8.4/bin:$PATH" >> $GITHUB_ENV
2021-03-17 10:28:04 +01:00
2021-03-18 11:41:18 +01:00
- name: Install ghcjs and cabal
2021-03-17 10:28:04 +01:00
run: |
# Default GitHub image dropped ppa:hvr/ghc, so we add it ourselves
sudo add-apt-repository ppa:hvr/ghc
2021-03-17 10:28:04 +01:00
sudo add-apt-repository ppa:hvr/ghcjs
sudo apt-get update -y
sudo apt-get install ghcjs-8.4
2021-03-17 12:11:03 +01:00
sudo apt-get install cabal-install
2021-03-17 21:32:04 +01:00
2021-03-17 12:11:03 +01:00
# Override cabal.project with the lightweight GHCJS one
cp cabal.ghcjs.project cabal.project
cat cabal.project
2021-03-18 11:41:18 +01:00
- name: Cabal update and freeze
run: |
2021-03-17 12:11:03 +01:00
cabal v2-update
2021-03-18 11:41:18 +01:00
cabal v2-freeze
- uses: actions/cache@v2.1.3
name: Cache ~/.cabal/store and dist-newstyle
with:
path: |
~/.cabal/store
dist-newstyle
key: ubuntu-18.04-ghcjs8.4-${{ hashFiles('cabal.project.freeze') }}
restore-keys: |
ubuntu-18.04-ghcjs8.4-
- name: Install cabal-plan and hspec-discover
run: |
2021-03-17 12:11:03 +01:00
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'
cabal v2-install -w /opt/ghc/8.4.4/bin/ghc --ignore-project hspec-discover
- name: Build
run: |
cabal v2-build --ghcjs -w /opt/ghcjs/8.4/bin/ghcjs --enable-tests --enable-benchmarks all
- name: Run tests
run: |
2021-03-17 21:32:04 +01:00
# cabal v2-test does not work with GHCJS
# See: https://github.com/haskell/cabal/issues/6175
#
# This invokes cabal-plan to figure out test binaries, and invokes them with node.
2021-03-17 12:11:03 +01:00
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