Update CI test matrix requirements and the script

Also, fix a few test issues to make the CIs work.
This commit is contained in:
Harendra Kumar 2021-06-21 22:20:42 +05:30
parent eaa837d57c
commit f5470713c2
9 changed files with 252 additions and 94 deletions

View File

@ -1,9 +1,11 @@
.packcheck.ignore
cabal.project
cabal.project.ci
cabal.project.coverage
cabal.project.doctest
cabal.project.ghc-head
cabal.project.hpc-coveralls
cabal.project.O0
cabal.project.Werror
cabal.project.Werror-nocode
hie.yaml
stack.yaml

View File

@ -1,5 +1,7 @@
#!/usr/bin/env bash
# See dev/ci-tests.md
# TODO: (1) Detect if nix is available otherwise run with plain cabal,
# (2) Detect the platform and run tests applicable to the platform, (3)
# add a test for windows/msys
@ -8,86 +10,122 @@ SCRIPT_DIR=$(cd `dirname $0`; pwd)
source $SCRIPT_DIR/build-lib.sh
#------------------------------------------------------------------------------
# GHC 8.10
# Prime version (GHC 8.10)
#------------------------------------------------------------------------------
GHC_PRIME=ghc8104
GHC_PRIME_VER="8.10"
ghc_prime_dist () {
nix-shell \
--argstr compiler "$GHC_PRIME" \
--run "\
packcheck.sh cabal-v2 \
GHCVER=$GHC_PRIME_VER \
CABAL_DISABLE_DEPS=y \
CABAL_CHECK_RELAX=y"
}
# build-all, Werror, test, inspection, fusion-plugin. Note, inspection
# requires fusion-plugin.
basic () {
PERF_FLAGS="--flag inspection --flag fusion-plugin"
ghc_prime_perf () {
nix-shell \
--argstr compiler "ghc8101" \
--argstr compiler "$GHC_PRIME" \
--argstr c2nix "--flag inspection" \
--run "\
packcheck cabal-v2 \
GHCVER=8.10.1 \
CABAL_DISABLE_DEPS=y \
CABAL_CHECK_RELAX=y \
DISABLE_SDIST_BUILD=y \
CABAL_PROJECT=cabal.project.ci \
CABAL_BUILD_OPTIONS=\"--flag inspection --flag fusion-plugin\""
# chart deps do not build with ghc-8.10 on nix
# nix-shell \
# --argstr compiler "ghc8101" \
# --argstr c2nix "--flag dev" \
# --run "cabal build chart --flag dev"
# nix-shell \
# --argstr compiler "ghc8101" \
# --argstr c2nix "--flag inspection" \
# --run "\
# bin/bench.sh \
# --quick \
# --cabal-build-options \"--cabal-project cabal.project.ci --flag inspection --flag fusion-plugin\""
}
bin/bench.sh --cabal-build-options \
\"--project-file cabal.project.Werror $PERF_FLAGS\" --quick --raw;\
bin/test.sh --cabal-build-options \
\"--project-file cabal.project.Werror $PERF_FLAGS\";"
}
ghc_prime_O0 () {
nix-shell \
--argstr compiler "$GHC_PRIME" \
--run "\
bin/test.sh --cabal-build-options \
\"--project-file cabal.project.O0\""
}
#------------------------------------------------------------------------------
# hlint
# Check warnings, docs
#------------------------------------------------------------------------------
# XXX avoid rebuilding if nothing has changed in the source
# XXX run hlint only on changed files
hlint () {
lint () {
packcheck cabal \
HLINT_OPTIONS="lint --cpp-include=src --cpp-include=test" \
HLINT_TARGETS="src test benchmark"
}
Werror () {
nix-shell \
--argstr compiler "$GHC_PRIME" \
--run "cabal build --project-file cabal.project.Werror-nocode all"
}
ghc_prime_werror () {
nix-shell \
--argstr compiler "$GHC_PRIME" \
--run "cabal build --project-file cabal.project.Werror all"
}
ghc_prime_doctests () {
nix-shell \
--argstr compiler "$GHC_PRIME" \
--run "cabal build --project-file cabal.project.doctest all"
cabal-docspec --timeout 60
}
#------------------------------------------------------------------------------
# coverage
#------------------------------------------------------------------------------
coverage () {
nix-shell \
--argstr compiler "ghc8101" \
--run "bin/test.sh --coverage"
}
# To upload the results to coveralls.io using hpc-coveralls
# hpc-coveralls --repo-token="$REPO_TOKEN" --coverage-mode=StrictlyFullLines
ghc_prime_coverage () {
nix-shell \
--argstr compiler "$GHC_PRIME" \
--run "bin/test.sh --coverage"
}
#------------------------------------------------------------------------------
# GHC 8.8
# Flags
#------------------------------------------------------------------------------
# chart builds from the nix cache for 8.8, 8.10 requires building
# XXX Use a separate build-dir for this
# build-all only, throw in most flags except fusion-plugin, inspection, opt
flags () {
ghc_prime_dev () {
nix-shell \
--argstr compiler "ghc883" \
--argstr c2nix "--flag dev" \
--run "\
packcheck cabal-v2 \
GHCVER=8.8.3 \
CABAL_DISABLE_DEPS=y \
CABAL_CHECK_RELAX=y \
DISABLE_SDIST_BUILD=y \
DISABLE_TEST=y \
DISABLE_DOCS=y \
DISABLE_BENCH=y \
CABAL_BUILD_OPTIONS=\"--flag streamk --flag debug --flag use-c-malloc --flag dev\""
--argstr compiler "$GHC_PRIME" \
--run "bin/test.sh --cabal-build-options \"--flag dev\""
}
ghc_prime_c_malloc () {
nix-shell \
--argstr compiler "$GHC_PRIME" \
--run "bin/test.sh --cabal-build-options \"--flag use-c-malloc\""
}
ghc_prime_debug () {
nix-shell \
--argstr compiler "$GHC_PRIME" \
--run "bin/test.sh --cabal-build-options \"--flag debug\""
}
ghc_prime_streamk () {
nix-shell \
--argstr compiler "$GHC_PRIME" \
--run "bin/test.sh --cabal-build-options \"--flag streamk\""
}
#------------------------------------------------------------------------------
# Other GHC versions
#------------------------------------------------------------------------------
# build-all only
# $1 883
# $2 8.8.3
@ -95,43 +133,72 @@ ghc () {
nix-shell \
--argstr compiler "ghc$1" \
--run "\
packcheck cabal-v2 \
packcheck.sh cabal-v2 \
GHCVER=$2 \
CABAL_DISABLE_DEPS=y \
CABAL_CHECK_RELAX=y \
DISABLE_SDIST_BUILD=y \
DISABLE_TEST=y \
DISABLE_DOCS=y "
DISABLE_DOCS=y"
}
ghc883 () { ghc 883 8.8.3; }
ghc865 () { ghc 865 8.6.5; }
ghc844 () { ghc 865 8.4.4; }
ghc901 () { ghc 901 9.0.1; }
ghc884 () { ghc 884 8.8.4; }
#------------------------------------------------------------------------------
# GHC Head
#------------------------------------------------------------------------------
ghcHEAD () {
nix-shell \
--argstr compiler "ghcHEAD" \
--run "\
packcheck.sh cabal-v2 \
GHCVER=9.3 \
CABAL_CHECK_RELAX=y \
DISABLE_SDIST_BUILD=y \
CABAL_BUILD_OPTIONS=\"--allow-newer --project-file cabal.project.ghc-head"
}
#------------------------------------------------------------------------------
# ghcjs
#------------------------------------------------------------------------------
#nix-shell \
# --argstr compiler "ghcjs" \
# --run "\
# packcheck cabal-v2 \
# GHCVER=8.6.0 \
# CABAL_DISABLE_DEPS=y \
# CABAL_CHECK_RELAX=y \
# DISABLE_SDIST_BUILD=y \
# DISABLE_TEST=y \
# DISABLE_DOCS=y \
# ENABLE_GHCJS=y " || exit 1
ghcjs () {
export PATH=~/.local/bin:/opt/ghc/bin:/opt/ghcjs/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:$PATH
packcheck.sh cabal-v2 \
GHCVER=8.4.0 \
CABAL_CHECK_RELAX=y \
DISABLE_SDIST_BUILD=y \
DISABLE_TEST=y \
DISABLE_DOCS=y \
ENABLE_GHCJS=y
}
#-----------------------------------------------------------------------------
# Read command line
#-----------------------------------------------------------------------------
ALL_TARGETS="all basic hlint coverage flags ghc883 ghc864 ghc844"
ALL_TARGETS="\
ghc_prime_dist \
ghc_prime_perf \
ghc_prime_O0 \
ghc_prime_Werror \
ghc_prime_doctests \
ghc_prime_coverage \
ghc_prime_dev \
ghc_prime_c_malloc \
ghc_prime_debug \
ghc_prime_streamk \
ghc901 \
ghc884 \
ghcHEAD \
ghcjs \
lint \
Werror"
print_targets () {
echo "Available targets: $ALL_TARGETS"
echo "Available targets: all $ALL_TARGETS"
}
print_help () {
@ -152,22 +219,31 @@ do
esac
done
if test -z "$TARGETS"
then
print_help
fi
for i in "$TARGETS"
do
if test "$(has_item "$ALL_TARGETS" $i)" != "$i"
then
echo "Unrecognized target: $i"
print_help
fi
done
if test "$(has_item "$TARGETS" help)" = "help"
then
print_targets
exit
fi
if test "$(has_item "$TARGETS" help)" = "all"
if test "$(has_item "$TARGETS" all)" = "all"
then
TARGETS="$ALL_TARGETS"
fi
if test -z "$TARGETS"
then
print_help
fi
for i in $TARGETS
do
$i || { echo "$i failed."; exit 1; }

View File

@ -98,6 +98,13 @@ echo "Using targets [$TARGETS]"
test_exe_rts_opts () {
case "$1" in
# XXX Data.Array.* heap requirement increased for GHC-8.10
Data.Array.Foreign) echo -n "-M128M" ;;
Data.Array.Prim) echo -n "-M128M" ;;
Data.Array.Prim.Pinned) echo -n "-M128M" ;;
# For -O0 case writeChunks test fails, maybe we should have a separate flag
# for O0 case?
FileSystem.Handle) echo -n "-K16M" ;;
*) if test "$COVERAGE" -eq "1"
then
echo -n "-K8M -M1024M"

19
cabal.project.O0 Normal file
View File

@ -0,0 +1,19 @@
packages:
./
test
benchmark
-- Keep the flags same as cabal.project.doctest because we utilize the
-- same build for doctests in CI.
package streamly
flags: -opt
ghc-options: -O0 -Werror
package streamly-tests
flags: -opt
ghc-options: -O0 -Werror
package streamly-benchmarks
flags: -opt
ghc-options: -O0 -Werror

View File

@ -0,0 +1,13 @@
packages:
./
benchmark
test
package streamly
ghc-options: -Werror -fno-code
package streamly-benchmarks
ghc-options: -Werror -fno-code
package streamly-tests
ghc-options: -Werror -fno-code

View File

@ -3,11 +3,8 @@ packages:
test
package streamly
ghc-options: -Werror
flag: inspection
coverage: true
package streamly-tests
ghc-options: -Werror
-- package streamly-tests
-- A few percent lesss coverage for some build speedup
-- -DCOVERAGE_BUILD

View File

@ -1,2 +1,13 @@
packages: streamly.cabal
, docs/streamly-docs.cabal
-- Keep the flags same as cabal.project.O0 because we utilize the same build
-- for doctest in CI.
package streamly
flags: -opt
ghc-options: -O0 -Werror
package streamly-docs
flags: -opt
ghc-options: -O0 -Werror

View File

@ -1,22 +1,54 @@
# Continuous integration tests
This file documents the required CI test matrix so that we do not accidentally
remove or miss any tests when making changes to CI configs:
* Last three major versions of GHC (build lib, test, bench, docs), run
tests, on Linux platform, using cabal build
* Only for prime GHC version:
* Run on Windows and MacOS platforms too
* stack build
* Run `bench.sh --quick`
* -Werror (for lib, test, bench)
* `coverage` build
* build from source distribution
* hlint
* `inspection` flag + `fusion-plugin` flag
* --flag streamk
* --flag debug
* --flag doctests
* ghc head version - run inspection-testing + fusion-plugin tests to catch any
issues early. Ideally we should also be running perf tests and compare
against the prime version.
## For prime GHC version:
Distribution:
* build from source distribution WITHOUT a cabal.project file
Performance:
* `--flag inspection` + `--flag fusion-plugin`
* Run `bin/bench.sh --quick --raw`
* Run `bin/test.sh`
* -Werror (for lib, test, bench)
Lint:
* -Werror (for lib, test, bench) (Need a Werror with default flags)
* hlint
Doctests:
* Run cabal-docspec
Coverage:
* `coverage` build
Debug:
* --flag debug
StreamK:
* --flag streamk
Windows:
* Windows + stack
MacOS:
* MacOS + stack
## Other GHC versions
GHC head:
* `--flag inspection` + `--flag fusion-plugin` tests to catch any
issues early.
* Ideally we should also be running perf tests and compare
against the prime version.
Other GHC versions:
* build lib, test, bench, docs, run tests, on Linux platform, using
cabal build
## GHCJS
GHCJS:
* Latest version ghcjs build (lib, test, bench), run tests

View File

@ -169,4 +169,5 @@ main =
describe "Write To Handle" $ do
prop "write" $ testWrite Handle.write
prop "writeWithBufferOf" $ testWrite $ Handle.writeWithBufferOf 1024
-- XXX This test needs a lot of stack when built with -O0
prop "writeChunks" testWriteWithChunk