@@ -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; }