Skip to content

Commit

Permalink
[ jaspervdj#12 ] cabal test-suite to run goldplate's own tests
Browse files Browse the repository at this point in the history
  • Loading branch information
andreasabel committed May 29, 2021
1 parent 91748fa commit f76914d
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 18 deletions.
45 changes: 27 additions & 18 deletions .github/workflows/haskell-ci.yml
Original file line number Diff line number Diff line change
@@ -1,40 +1,40 @@
# This GitHub workflow config has been generated by a script via
#
# haskell-ci 'github' '--no-cabal-check' 'goldplate.cabal'
# haskell-ci 'github' 'goldplate.cabal'
#
# To regenerate the script (for example after adjusting tested-with) run
#
# haskell-ci regenerate
#
# For more information, see https://github.com/haskell-CI/haskell-ci
#
# version: 0.11.20210222
# version: 0.13.20210526
#
# REGENDATA ("0.11.20210222",["github","--no-cabal-check","goldplate.cabal"])
# REGENDATA ("0.13.20210526",["github","goldplate.cabal"])
#
name: Haskell-CI
on:
- push
- pull_request
jobs:
linux:
name: Haskell-CI - Linux - GHC ${{ matrix.ghc }}
name: Haskell-CI - Linux - ${{ matrix.compiler }}
runs-on: ubuntu-18.04
container:
image: buildpack-deps:bionic
continue-on-error: ${{ matrix.allow-failure }}
strategy:
matrix:
include:
- ghc: 9.0.1
- compiler: ghc-9.0.1
allow-failure: false
- ghc: 8.10.4
- compiler: ghc-8.10.4
allow-failure: false
- ghc: 8.8.4
- compiler: ghc-8.8.4
allow-failure: false
- ghc: 8.6.5
- compiler: ghc-8.6.5
allow-failure: false
- ghc: 8.4.4
- compiler: ghc-8.4.4
allow-failure: false
fail-fast: false
steps:
Expand All @@ -44,29 +44,31 @@ jobs:
apt-get install -y --no-install-recommends gnupg ca-certificates dirmngr curl git software-properties-common
apt-add-repository -y 'ppa:hvr/ghc'
apt-get update
apt-get install -y ghc-$GHC_VERSION cabal-install-3.4
apt-get install -y $CC cabal-install-3.4
env:
GHC_VERSION: ${{ matrix.ghc }}
CC: ${{ matrix.compiler }}
- name: Set PATH and environment variables
run: |
echo "$HOME/.cabal/bin" >> $GITHUB_PATH
echo "LANG=C.UTF-8" >> $GITHUB_ENV
echo "CABAL_DIR=$HOME/.cabal" >> $GITHUB_ENV
echo "CABAL_CONFIG=$HOME/.cabal/config" >> $GITHUB_ENV
HC=/opt/ghc/$GHC_VERSION/bin/ghc
HCDIR=$(echo "/opt/$CC" | sed 's/-/\//')
HCNAME=ghc
HC=$HCDIR/bin/$HCNAME
echo "HC=$HC" >> $GITHUB_ENV
echo "HCPKG=/opt/ghc/$GHC_VERSION/bin/ghc-pkg" >> $GITHUB_ENV
echo "HADDOCK=/opt/ghc/$GHC_VERSION/bin/haddock" >> $GITHUB_ENV
echo "HCPKG=$HCDIR/bin/$HCNAME-pkg" >> $GITHUB_ENV
echo "HADDOCK=$HCDIR/bin/haddock" >> $GITHUB_ENV
echo "CABAL=/opt/cabal/3.4/bin/cabal -vnormal+nowrap" >> $GITHUB_ENV
HCNUMVER=$(${HC} --numeric-version|perl -ne '/^(\d+)\.(\d+)\.(\d+)(\.(\d+))?$/; print(10000 * $1 + 100 * $2 + ($3 == 0 ? $5 != 1 : $3))')
echo "HCNUMVER=$HCNUMVER" >> $GITHUB_ENV
echo "ARG_TESTS=--enable-tests" >> $GITHUB_ENV
echo "ARG_BENCH=--enable-benchmarks" >> $GITHUB_ENV
echo "HEADHACKAGE=false" >> $GITHUB_ENV
echo "ARG_COMPILER=--ghc --with-compiler=$HC" >> $GITHUB_ENV
echo "ARG_COMPILER=--$HCNAME --with-compiler=$HC" >> $GITHUB_ENV
echo "GHCJSARITH=0" >> $GITHUB_ENV
env:
GHC_VERSION: ${{ matrix.ghc }}
CC: ${{ matrix.compiler }}
- name: env
run: |
env
Expand Down Expand Up @@ -145,9 +147,9 @@ jobs:
- name: cache
uses: actions/cache@v2
with:
key: ${{ runner.os }}-${{ matrix.ghc }}-${{ github.sha }}
key: ${{ runner.os }}-${{ matrix.compiler }}-${{ github.sha }}
path: ~/.cabal/store
restore-keys: ${{ runner.os }}-${{ matrix.ghc }}-
restore-keys: ${{ runner.os }}-${{ matrix.compiler }}-
- name: install dependencies
run: |
$CABAL v2-build $ARG_COMPILER --disable-tests --disable-benchmarks --dependencies-only -j2 all
Expand All @@ -158,6 +160,13 @@ jobs:
- name: build
run: |
$CABAL v2-build $ARG_COMPILER $ARG_TESTS $ARG_BENCH all --write-ghc-environment-files=always
- name: tests
run: |
$CABAL v2-test $ARG_COMPILER $ARG_TESTS $ARG_BENCH all --test-show-details=direct
- name: cabal check
run: |
cd ${PKGDIR_goldplate} || false
${CABAL} -vnormal check
- name: unconstrained build
run: |
rm -f cabal.project.local
Expand Down
8 changes: 8 additions & 0 deletions goldplate.cabal
Original file line number Diff line number Diff line change
Expand Up @@ -59,3 +59,11 @@ Executable goldplate
regex-pcre-builtin >= 0.95.1.3 && < 0.96,
text >= 1.2 && < 1.3,
unordered-containers >= 0.2 && < 0.3

Test-suite tests
Default-language: Haskell2010
Type: exitcode-stdio-1.0
Ghc-options: -threaded
Main-is: Tests.hs
Build-depends: base, process
Hs-source-dirs: tests
5 changes: 5 additions & 0 deletions tests/Tests.hs
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import System.Exit ( exitWith )
import System.Process ( system )

main :: IO ()
main = exitWith =<< system "cabal run -- goldplate tests"

0 comments on commit f76914d

Please sign in to comment.