on master help sign in
Update CI test matrix requirements and the script

Also, fix a few test issues to make the CIs work.

commitf5470713c202b316f02e9a44c0e27c41c2b385c2 authorHarendra Kumar <harendra@composewell.com> dateMon 21 Jun 2021, 22:20 (5 years ago) parenteaa837d
9 files changed+248−90
.packcheck.ignore+3−1 bin/run-ci.sh+147−71 bin/test.sh+7 cabal.project.O0+19 cabal.project.Werror-nocode+13 cabal.project.coverage+1−4 cabal.project.doctest+11 dev/ci-tests.md+46−14 test/Streamly/Test/FileSystem/Handle.hs+1
.packcheck.ignore+3−1
@@ -1,9 +1,11 @@
11.packcheck.ignore
22cabal.project
3−cabal.project.ci
43cabal.project.coverage
54cabal.project.doctest
65cabal.project.ghc-head
76cabal.project.hpc-coveralls
7+cabal.project.O0
8+cabal.project.Werror
9+cabal.project.Werror-nocode
810hie.yaml
911stack.yaml
bin/run-ci.sh+147−71
@@ -1,5 +1,7 @@
11#!/usr/bin/env bash
22
3+# See dev/ci-tests.md
4+
35# TODO: (1) Detect if nix is available otherwise run with plain cabal,
46# (2) Detect the platform and run tests applicable to the platform, (3)
57# add a test for windows/msys
@@ -8,86 +10,122 @@ SCRIPT_DIR=$(cd `dirname $0`; pwd)
810source $SCRIPT_DIR/build-lib.sh
911
1012#------------------------------------------------------------------------------
11−# GHC 8.10
13+# Prime version (GHC 8.10)
1214#------------------------------------------------------------------------------
1315
16+GHC_PRIME=ghc8104
17+GHC_PRIME_VER="8.10"
18+
19+ghc_prime_dist () {
20+ nix-shell \
21+ --argstr compiler "$GHC_PRIME" \
22+ --run "\
23+ packcheck.sh cabal-v2 \
24+ GHCVER=$GHC_PRIME_VER \
25+ CABAL_DISABLE_DEPS=y \
26+ CABAL_CHECK_RELAX=y"
27+}
28+
1429# build-all, Werror, test, inspection, fusion-plugin. Note, inspection
1530# requires fusion-plugin.
1631
17−basic () {
32+PERF_FLAGS="--flag inspection --flag fusion-plugin"
33+
34+ghc_prime_perf () {
1835 nix-shell \
19− --argstr compiler "ghc8101" \
36+ --argstr compiler "$GHC_PRIME" \
2037 --argstr c2nix "--flag inspection" \
2138 --run "\
22− packcheck cabal-v2 \
23− GHCVER=8.10.1 \
24− CABAL_DISABLE_DEPS=y \
25− CABAL_CHECK_RELAX=y \
26− DISABLE_SDIST_BUILD=y \
27− CABAL_PROJECT=cabal.project.ci \
28− CABAL_BUILD_OPTIONS=\"--flag inspection --flag fusion-plugin\""
29−# chart deps do not build with ghc-8.10 on nix
30−# nix-shell \
31−# --argstr compiler "ghc8101" \
32−# --argstr c2nix "--flag dev" \
33−# --run "cabal build chart --flag dev"
34−# nix-shell \
35−# --argstr compiler "ghc8101" \
36−# --argstr c2nix "--flag inspection" \
37−# --run "\
38−# bin/bench.sh \
39−# --quick \
40−# --cabal-build-options \"--cabal-project cabal.project.ci --flag inspection --flag fusion-plugin\""
41− }
39+ bin/bench.sh --cabal-build-options \
40+ \"--project-file cabal.project.Werror $PERF_FLAGS\" --quick --raw;\
41+ bin/test.sh --cabal-build-options \
42+ \"--project-file cabal.project.Werror $PERF_FLAGS\";"
43+}
44+
45+ghc_prime_O0 () {
46+ nix-shell \
47+ --argstr compiler "$GHC_PRIME" \
48+ --run "\
49+ bin/test.sh --cabal-build-options \
50+ \"--project-file cabal.project.O0\""
51+}
4252
4353#------------------------------------------------------------------------------
44−# hlint
54+# Check warnings, docs
4555#------------------------------------------------------------------------------
4656
4757# XXX avoid rebuilding if nothing has changed in the source
4858# XXX run hlint only on changed files
49−hlint () {
59+lint () {
5060 packcheck cabal \
5161 HLINT_OPTIONS="lint --cpp-include=src --cpp-include=test" \
5262 HLINT_TARGETS="src test benchmark"
5363}
5464
65+Werror () {
66+ nix-shell \
67+ --argstr compiler "$GHC_PRIME" \
68+ --run "cabal build --project-file cabal.project.Werror-nocode all"
69+}
70+
71+ghc_prime_werror () {
72+ nix-shell \
73+ --argstr compiler "$GHC_PRIME" \
74+ --run "cabal build --project-file cabal.project.Werror all"
75+}
76+
77+ghc_prime_doctests () {
78+ nix-shell \
79+ --argstr compiler "$GHC_PRIME" \
80+ --run "cabal build --project-file cabal.project.doctest all"
81+ cabal-docspec --timeout 60
82+}
83+
5584#------------------------------------------------------------------------------
5685# coverage
5786#------------------------------------------------------------------------------
5887
59−coverage () {
88+# To upload the results to coveralls.io using hpc-coveralls
89+# hpc-coveralls --repo-token="$REPO_TOKEN" --coverage-mode=StrictlyFullLines
90+
91+ghc_prime_coverage () {
6092 nix-shell \
61− --argstr compiler "ghc8101" \
93+ --argstr compiler "$GHC_PRIME" \
6294 --run "bin/test.sh --coverage"
6395}
6496
65−# To upload the results to coveralls.io using hpc-coveralls
66−# hpc-coveralls --repo-token="$REPO_TOKEN" --coverage-mode=StrictlyFullLines
67−
6897#------------------------------------------------------------------------------
69−# GHC 8.8
98+# Flags
7099#------------------------------------------------------------------------------
71100
72−# chart builds from the nix cache for 8.8, 8.10 requires building
73−# XXX Use a separate build-dir for this
74−# build-all only, throw in most flags except fusion-plugin, inspection, opt
75−flags () {
101+ghc_prime_dev () {
76102 nix-shell \
77− --argstr compiler "ghc883" \
78− --argstr c2nix "--flag dev" \
79− --run "\
80− packcheck cabal-v2 \
81− GHCVER=8.8.3 \
82− CABAL_DISABLE_DEPS=y \
83− CABAL_CHECK_RELAX=y \
84− DISABLE_SDIST_BUILD=y \
85− DISABLE_TEST=y \
86− DISABLE_DOCS=y \
87− DISABLE_BENCH=y \
88− CABAL_BUILD_OPTIONS=\"--flag streamk --flag debug --flag use-c-malloc --flag dev\""
103+ --argstr compiler "$GHC_PRIME" \
104+ --run "bin/test.sh --cabal-build-options \"--flag dev\""
89105}
90106
107+ghc_prime_c_malloc () {
108+ nix-shell \
109+ --argstr compiler "$GHC_PRIME" \
110+ --run "bin/test.sh --cabal-build-options \"--flag use-c-malloc\""
111+}
112+
113+ghc_prime_debug () {
114+ nix-shell \
115+ --argstr compiler "$GHC_PRIME" \
116+ --run "bin/test.sh --cabal-build-options \"--flag debug\""
117+}
118+
119+ghc_prime_streamk () {
120+ nix-shell \
121+ --argstr compiler "$GHC_PRIME" \
122+ --run "bin/test.sh --cabal-build-options \"--flag streamk\""
123+}
124+
125+#------------------------------------------------------------------------------
126+# Other GHC versions
127+#------------------------------------------------------------------------------
128+
91129# build-all only
92130# $1 883
93131# $2 8.8.3
@@ -95,43 +133,72 @@ ghc () {
95133 nix-shell \
96134 --argstr compiler "ghc$1" \
97135 --run "\
98− packcheck cabal-v2 \
136+ packcheck.sh cabal-v2 \
99137 GHCVER=$2 \
100138 CABAL_DISABLE_DEPS=y \
101139 CABAL_CHECK_RELAX=y \
102140 DISABLE_SDIST_BUILD=y \
103141 DISABLE_TEST=y \
104− DISABLE_DOCS=y "
142+ DISABLE_DOCS=y"
105143}
106144
107−ghc883 () { ghc 883 8.8.3; }
108−ghc865 () { ghc 865 8.6.5; }
109−ghc844 () { ghc 865 8.4.4; }
145+ghc901 () { ghc 901 9.0.1; }
146+ghc884 () { ghc 884 8.8.4; }
147+
148+#------------------------------------------------------------------------------
149+# GHC Head
150+#------------------------------------------------------------------------------
151+
152+ghcHEAD () {
153+ nix-shell \
154+ --argstr compiler "ghcHEAD" \
155+ --run "\
156+ packcheck.sh cabal-v2 \
157+ GHCVER=9.3 \
158+ CABAL_CHECK_RELAX=y \
159+ DISABLE_SDIST_BUILD=y \
160+ CABAL_BUILD_OPTIONS=\"--allow-newer --project-file cabal.project.ghc-head"
161+}
110162
111163#------------------------------------------------------------------------------
112164# ghcjs
113165#------------------------------------------------------------------------------
114166
115−#nix-shell \
116−# --argstr compiler "ghcjs" \
117−# --run "\
118−# packcheck cabal-v2 \
119−# GHCVER=8.6.0 \
120−# CABAL_DISABLE_DEPS=y \
121−# CABAL_CHECK_RELAX=y \
122−# DISABLE_SDIST_BUILD=y \
123−# DISABLE_TEST=y \
124−# DISABLE_DOCS=y \
125−# ENABLE_GHCJS=y " || exit 1
167+ghcjs () {
168+ export PATH=~/.local/bin:/opt/ghc/bin:/opt/ghcjs/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:$PATH
169+ packcheck.sh cabal-v2 \
170+ GHCVER=8.4.0 \
171+ CABAL_CHECK_RELAX=y \
172+ DISABLE_SDIST_BUILD=y \
173+ DISABLE_TEST=y \
174+ DISABLE_DOCS=y \
175+ ENABLE_GHCJS=y
176+}
126177
127178#-----------------------------------------------------------------------------
128179# Read command line
129180#-----------------------------------------------------------------------------
130181
131−ALL_TARGETS="all basic hlint coverage flags ghc883 ghc864 ghc844"
182+ALL_TARGETS="\
183+ghc_prime_dist \
184+ghc_prime_perf \
185+ghc_prime_O0 \
186+ghc_prime_Werror \
187+ghc_prime_doctests \
188+ghc_prime_coverage \
189+ghc_prime_dev \
190+ghc_prime_c_malloc \
191+ghc_prime_debug \
192+ghc_prime_streamk \
193+ghc901 \
194+ghc884 \
195+ghcHEAD \
196+ghcjs \
197+lint \
198+Werror"
132199
133200print_targets () {
134− echo "Available targets: $ALL_TARGETS"
201+ echo "Available targets: all $ALL_TARGETS"
135202}
136203
137204print_help () {
@@ -152,22 +219,31 @@ do
152219 esac
153220done
154221
222+if test -z "$TARGETS"
223+then
224+ print_help
225+fi
226+
227+for i in "$TARGETS"
228+do
229+ if test "$(has_item "$ALL_TARGETS" $i)" != "$i"
230+ then
231+ echo "Unrecognized target: $i"
232+ print_help
233+ fi
234+done
235+
155236if test "$(has_item "$TARGETS" help)" = "help"
156237then
157238 print_targets
158239 exit
159240fi
160241
161−if test "$(has_item "$TARGETS" help)" = "all"
242+if test "$(has_item "$TARGETS" all)" = "all"
162243then
163244 TARGETS="$ALL_TARGETS"
164245fi
165246
166−if test -z "$TARGETS"
167−then
168− print_help
169−fi
170−
171247for i in $TARGETS
172248do
173249 $i || { echo "$i failed."; exit 1; }
bin/test.sh+7
@@ -98,6 +98,13 @@ echo "Using targets [$TARGETS]"
9898
9999test_exe_rts_opts () {
100100 case "$1" in
101+ # XXX Data.Array.* heap requirement increased for GHC-8.10
102+ Data.Array.Foreign) echo -n "-M128M" ;;
103+ Data.Array.Prim) echo -n "-M128M" ;;
104+ Data.Array.Prim.Pinned) echo -n "-M128M" ;;
105+ # For -O0 case writeChunks test fails, maybe we should have a separate flag
106+ # for O0 case?
107+ FileSystem.Handle) echo -n "-K16M" ;;
101108 *) if test "$COVERAGE" -eq "1"
102109 then
103110 echo -n "-K8M -M1024M"
cabal.project.O0new file+19
@@ -0,0 +1,19 @@
1+packages:
2+ ./
3+ test
4+ benchmark
5+
6+-- Keep the flags same as cabal.project.doctest because we utilize the
7+-- same build for doctests in CI.
8+
9+package streamly
10+ flags: -opt
11+ ghc-options: -O0 -Werror
12+
13+package streamly-tests
14+ flags: -opt
15+ ghc-options: -O0 -Werror
16+
17+package streamly-benchmarks
18+ flags: -opt
19+ ghc-options: -O0 -Werror
cabal.project.Werror-nocodenew file+13
@@ -0,0 +1,13 @@
1+packages:
2+ ./
3+ benchmark
4+ test
5+
6+package streamly
7+ ghc-options: -Werror -fno-code
8+
9+package streamly-benchmarks
10+ ghc-options: -Werror -fno-code
11+
12+package streamly-tests
13+ ghc-options: -Werror -fno-code
cabal.project.coverage+1−4
@@ -3,11 +3,8 @@ packages:
33 test
44
55package streamly
6− ghc-options: -Werror
7− flag: inspection
86 coverage: true
97
10−package streamly-tests
11− ghc-options: -Werror
8+-- package streamly-tests
129 -- A few percent lesss coverage for some build speedup
1310 -- -DCOVERAGE_BUILD
cabal.project.doctest+11
@@ -1,2 +1,13 @@
11packages: streamly.cabal
22 , docs/streamly-docs.cabal
3+
4+-- Keep the flags same as cabal.project.O0 because we utilize the same build
5+-- for doctest in CI.
6+
7+package streamly
8+ flags: -opt
9+ ghc-options: -O0 -Werror
10+
11+package streamly-docs
12+ flags: -opt
13+ ghc-options: -O0 -Werror
dev/ci-tests.md+46−14
@@ -1,22 +1,54 @@
1+# Continuous integration tests
2+
13This file documents the required CI test matrix so that we do not accidentally
24remove or miss any tests when making changes to CI configs:
35
4−* Last three major versions of GHC (build lib, test, bench, docs), run
5− tests, on Linux platform, using cabal build
6−* Only for prime GHC version:
7− * Run on Windows and MacOS platforms too
8− * stack build
9− * Run `bench.sh --quick`
6+## For prime GHC version:
7+
8+Distribution:
9+ * build from source distribution WITHOUT a cabal.project file
10+
11+Performance:
12+ * `--flag inspection` + `--flag fusion-plugin`
13+ * Run `bin/bench.sh --quick --raw`
14+ * Run `bin/test.sh`
1015 * -Werror (for lib, test, bench)
11− * `coverage` build
12− * build from source distribution
16+
17+Lint:
18+ * -Werror (for lib, test, bench) (Need a Werror with default flags)
1319 * hlint
14− * `inspection` flag + `fusion-plugin` flag
15− * --flag streamk
20+
21+Doctests:
22+ * Run cabal-docspec
23+
24+Coverage:
25+ * `coverage` build
26+
27+Debug:
1628 * --flag debug
17− * --flag doctests
18−* ghc head version - run inspection-testing + fusion-plugin tests to catch any
19− issues early. Ideally we should also be running perf tests and compare
20− against the prime version.
2129
30+StreamK:
31+ * --flag streamk
32+
33+Windows:
34+ * Windows + stack
35+
36+MacOS:
37+ * MacOS + stack
38+
39+## Other GHC versions
40+
41+GHC head:
42+ * `--flag inspection` + `--flag fusion-plugin` tests to catch any
43+ issues early.
44+ * Ideally we should also be running perf tests and compare
45+ against the prime version.
46+
47+Other GHC versions:
48+* build lib, test, bench, docs, run tests, on Linux platform, using
49+ cabal build
50+
51+## GHCJS
52+
53+GHCJS:
2254* Latest version ghcjs build (lib, test, bench), run tests
test/Streamly/Test/FileSystem/Handle.hs+1
@@ -169,4 +169,5 @@ main =
169169 describe "Write To Handle" $ do
170170 prop "write" $ testWrite Handle.write
171171 prop "writeWithBufferOf" $ testWrite $ Handle.writeWithBufferOf 1024
172+ -- XXX This test needs a lot of stack when built with -O0
172173 prop "writeChunks" testWriteWithChunk