on master help sign in
Merge pull request #1263 from haskell-servant/build-type-simple
831f46aOleg Grenrus
.travis.yml+25−28
@@ -4,7 +4,7 @@
4#
4#
5# For more information, see https://github.com/haskell-CI/haskell-ci
5# For more information, see https://github.com/haskell-CI/haskell-ci
6#
6#
7−# version: 0.9.20191209
7+# version: 0.9.20200110
8#
8#
9version: ~> 1.0
9version: ~> 1.0
10language: c
10language: c
@@ -73,26 +73,8 @@ before_install:
73 - TOP=$(pwd)
73 - TOP=$(pwd)
74 - "HCNUMVER=$(${HC} --numeric-version|perl -ne '/^(\\d+)\\.(\\d+)\\.(\\d+)(\\.(\\d+))?$/; print(10000 * $1 + 100 * $2 + ($3 == 0 ? $5 != 1 : $3))')"
74 - "HCNUMVER=$(${HC} --numeric-version|perl -ne '/^(\\d+)\\.(\\d+)\\.(\\d+)(\\.(\\d+))?$/; print(10000 * $1 + 100 * $2 + ($3 == 0 ? $5 != 1 : $3))')"
75 - echo $HCNUMVER
75 - echo $HCNUMVER
76− - CABAL="$CABAL -vnormal+nowrap+markoutput"
76+ - CABAL="$CABAL -vnormal+nowrap"
77 - set -o pipefail
77 - set -o pipefail
78− - |
79− echo 'function blue(s) { printf "\033[0;34m" s "\033[0m " }' >> .colorful.awk
80− echo 'BEGIN { state = "output"; }' >> .colorful.awk
81− echo '/^-----BEGIN CABAL OUTPUT-----$/ { state = "cabal" }' >> .colorful.awk
82− echo '/^-----END CABAL OUTPUT-----$/ { state = "output" }' >> .colorful.awk
83− echo '!/^(-----BEGIN CABAL OUTPUT-----|-----END CABAL OUTPUT-----)/ {' >> .colorful.awk
84− echo ' if (state == "cabal") {' >> .colorful.awk
85− echo ' print blue($0)' >> .colorful.awk
86− echo ' } else {' >> .colorful.awk
87− echo ' print $0' >> .colorful.awk
88− echo ' }' >> .colorful.awk
89− echo '}' >> .colorful.awk
90− - cat .colorful.awk
91− - |
92− color_cabal_output () {
93− awk -f $TOP/.colorful.awk
94− }
95− - echo text | color_cabal_output
96install:
78install:
97 - ${CABAL} --version
79 - ${CABAL} --version
98 - echo "$(${HC} --version) [$(${HC} --print-project-git-commit-id 2> /dev/null || echo '?')]"
80 - echo "$(${HC} --version) [$(${HC} --print-project-git-commit-id 2> /dev/null || echo '?')]"
@@ -133,8 +115,9 @@ install:
133 - cat $CABALHOME/config
115 - cat $CABALHOME/config
134 - rm -fv cabal.project cabal.project.local cabal.project.freeze
116 - rm -fv cabal.project cabal.project.local cabal.project.freeze
135 - travis_retry ${CABAL} v2-update -v
117 - travis_retry ${CABAL} v2-update -v
118+ - if ! $GHCJS ; then (cd /tmp && ${CABAL} v2-install $WITHCOMPILER -j2 doctest --constraint='doctest ==0.16.2.*') ; fi
136− - if $GHCJS ; then (cd /tmp && ${CABAL} v2-install -w ghc-8.4.4 cabal-plan --constraint='cabal-plan ^>=0.6.0.0' --constraint='cabal-plan +exe' | color_cabal_output) ; fi
119+ - if $GHCJS ; then (cd /tmp && ${CABAL} v2-install -w ghc-8.4.4 cabal-plan --constraint='cabal-plan ^>=0.6.0.0' --constraint='cabal-plan +exe') ; fi
137− - if $GHCJS ; then (cd /tmp && ${CABAL} v2-install -w ghc-8.4.4 hspec-discover | color_cabal_output) ; fi
120+ - if $GHCJS ; then (cd /tmp && ${CABAL} v2-install -w ghc-8.4.4 hspec-discover) ; fi
138 # Generate cabal.project
121 # Generate cabal.project
139 - rm -rf cabal.project cabal.project.local cabal.project.freeze
122 - rm -rf cabal.project cabal.project.local cabal.project.freeze
140 - touch cabal.project
123 - touch cabal.project
@@ -212,14 +195,14 @@ install:
212 - if [ -f "doc/cookbook/structuring-apis/configure.ac" ]; then (cd "doc/cookbook/structuring-apis" && autoreconf -i); fi
195 - if [ -f "doc/cookbook/structuring-apis/configure.ac" ]; then (cd "doc/cookbook/structuring-apis" && autoreconf -i); fi
213 - if [ -f "doc/cookbook/using-custom-monad/configure.ac" ]; then (cd "doc/cookbook/using-custom-monad" && autoreconf -i); fi
196 - if [ -f "doc/cookbook/using-custom-monad/configure.ac" ]; then (cd "doc/cookbook/using-custom-monad" && autoreconf -i); fi
214 - if [ -f "doc/cookbook/using-free-client/configure.ac" ]; then (cd "doc/cookbook/using-free-client" && autoreconf -i); fi
197 - if [ -f "doc/cookbook/using-free-client/configure.ac" ]; then (cd "doc/cookbook/using-free-client" && autoreconf -i); fi
215− - ${CABAL} v2-freeze $WITHCOMPILER ${TEST} ${BENCH} | color_cabal_output
198+ - ${CABAL} v2-freeze $WITHCOMPILER ${TEST} ${BENCH}
216 - "cat cabal.project.freeze | sed -E 's/^(constraints: *| *)//' | sed 's/any.//'"
199 - "cat cabal.project.freeze | sed -E 's/^(constraints: *| *)//' | sed 's/any.//'"
217 - rm cabal.project.freeze
200 - rm cabal.project.freeze
218script:
201script:
219 - DISTDIR=$(mktemp -d /tmp/dist-test.XXXX)
202 - DISTDIR=$(mktemp -d /tmp/dist-test.XXXX)
220 # Packaging...
203 # Packaging...
221 - echo 'Packaging...' && echo -en 'travis_fold:start:sdist\\r'
204 - echo 'Packaging...' && echo -en 'travis_fold:start:sdist\\r'
222− - ${CABAL} v2-sdist all | color_cabal_output
205+ - ${CABAL} v2-sdist all
223 - echo -en 'travis_fold:end:sdist\\r'
206 - echo -en 'travis_fold:end:sdist\\r'
224 # Unpacking...
207 # Unpacking...
225 - echo 'Unpacking...' && echo -en 'travis_fold:start:unpack\\r'
208 - echo 'Unpacking...' && echo -en 'travis_fold:start:unpack\\r'
@@ -335,15 +318,29 @@ script:
335 # Building with tests and benchmarks...
318 # Building with tests and benchmarks...
336 - echo 'Building with tests and benchmarks...' && echo -en 'travis_fold:start:build-everything\\r'
319 - echo 'Building with tests and benchmarks...' && echo -en 'travis_fold:start:build-everything\\r'
337 # build & run tests, build benchmarks
320 # build & run tests, build benchmarks
338− - ${CABAL} v2-build $WITHCOMPILER ${TEST} ${BENCH} all | color_cabal_output
321+ - ${CABAL} v2-build $WITHCOMPILER ${TEST} ${BENCH} all
339 - echo -en 'travis_fold:end:build-everything\\r'
322 - echo -en 'travis_fold:end:build-everything\\r'
340 # Testing...
323 # Testing...
341− - if ! $GHCJS ; then ${CABAL} v2-test $WITHCOMPILER ${TEST} ${BENCH} all | color_cabal_output ; fi
324+ - if ! $GHCJS ; then ${CABAL} v2-test $WITHCOMPILER ${TEST} ${BENCH} all ; fi
342 - if $GHCJS ; then 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 ; fi
325 - if $GHCJS ; then 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 ; fi
326+ # Doctest...
327+ - echo 'Doctest...' && echo -en 'travis_fold:start:doctest\\r'
328+ - perl -i -e 'while (<ARGV>) { print unless /package-id\s+(base-compat-batteries)-\d+(\.\d+)*/; }' .ghc.environment.*
329+ - if ! $GHCJS ; then (cd ${PKGDIR_servant} && doctest src) ; fi
330+ - if ! $GHCJS ; then (cd ${PKGDIR_servant_client} && doctest src) ; fi
331+ - if ! $GHCJS ; then (cd ${PKGDIR_servant_client_core} && doctest src) ; fi
332+ - if ! $GHCJS ; then (cd ${PKGDIR_servant_http_streams} && doctest src) ; fi
333+ - if ! $GHCJS ; then (cd ${PKGDIR_servant_docs} && doctest src) ; fi
334+ - if ! $GHCJS ; then (cd ${PKGDIR_servant_foreign} && doctest src) ; fi
335+ - if ! $GHCJS ; then (cd ${PKGDIR_servant_server} && doctest src) ; fi
336+ - if ! $GHCJS ; then (cd ${PKGDIR_servant_machines} && doctest src) ; fi
337+ - if ! $GHCJS ; then (cd ${PKGDIR_servant_conduit} && doctest src) ; fi
338+ - if ! $GHCJS ; then (cd ${PKGDIR_servant_pipes} && doctest src) ; fi
339+ - echo -en 'travis_fold:end:doctest\\r'
343 # haddock...
340 # haddock...
344 - echo 'haddock...' && echo -en 'travis_fold:start:haddock\\r'
341 - echo 'haddock...' && echo -en 'travis_fold:start:haddock\\r'
345− - if ! $GHCJS ; then ${CABAL} v2-haddock $WITHCOMPILER --with-haddock $HADDOCK ${TEST} ${BENCH} all | color_cabal_output ; fi
342+ - if ! $GHCJS ; then ${CABAL} v2-haddock $WITHCOMPILER --with-haddock $HADDOCK ${TEST} ${BENCH} all ; fi
346 - echo -en 'travis_fold:end:haddock\\r'
343 - echo -en 'travis_fold:end:haddock\\r'
347
344
348−# REGENDATA ("0.9.20191209",["--config=cabal.haskell-ci","--output=.travis.yml","cabal.project"])
345+# REGENDATA ("0.9.20200110",["--config=cabal.haskell-ci","--output=.travis.yml","cabal.project"])
349# EOF
346# EOF
Makefile+10
@@ -20,3 +20,13 @@ build-ghcjs :
20
20
21packdeps :
21packdeps :
22 packdeps */*.cabal
22 packdeps */*.cabal
23+
24+doctest : doctest-servant doctest-servant-server
25+ perl -i -e 'while (<ARGV>) { print unless /package-id\s+base-compat-\d+(\.\d+)*/; }' .ghc.environment.*
26+
27+doctest-servant :
28+ (cd servant && doctest src)
29+ (cd servant && doctest test/Servant/LinksSpec.hs)
30+
31+doctest-servant-server :
32+ (cd servant-server && doctest src)
cabal.haskell-ci+3
@@ -4,6 +4,9 @@ branches: master
4jobs-selection: any
4jobs-selection: any
5google-chrome: True
5google-chrome: True
6ghcjs-tests: True
6ghcjs-tests: True
7+doctest: True
8+doctest-filter-packages: base-compat-batteries
9+doctest-skip: tutorial
7
10
8-- https://github.com/haskell/cabal/issues/6176
11-- https://github.com/haskell/cabal/issues/6176
9ghcjs-tools: hspec-discover
12ghcjs-tools: hspec-discover
cabal.project+3
@@ -76,3 +76,6 @@ allow-newer: jsaddle-dom-0.9.3.2:lens
76allow-newer: jsaddle-warp-0.9.6.0:time
76allow-newer: jsaddle-warp-0.9.6.0:time
77
77
78constraints: base-compat ^>=0.11
78constraints: base-compat ^>=0.11
79+
80+-- needed for doctests
81+write-ghc-environment-files: always
changelog.d/pr1249+2−1
@@ -1,6 +1,7 @@
1synopsis: use queryString to parse QueryParam, QueryParams and QueryFlag
1synopsis: use queryString to parse QueryParam, QueryParams and QueryFlag
2packages: servant-server
2packages: servant-server
3−prs: #1249
3+prs: #1249 #1262
4+significance: significant
4description: {
5description: {
5
6
6Some APIs need query parameters rewriting, e.g. in order to support
7Some APIs need query parameters rewriting, e.g. in order to support
changelog.d/pr1263new file+11
@@ -0,0 +1,11 @@
1+synopsis: Make packages `build-type: Simple`
2+packages: servant servant-server
3+prs: #1263
4+significance: significant
5+description: {
6+
7+We used `build-type: Custom`, but it's problematic e.g.
8+for cross-compiling. The benefit is small, as the doctests
9+can be run other ways too (though not so conviniently).
10+
11+}
doc/tutorial/test/Spec.hs+11−1
@@ -1 +1,11 @@
1−{-# OPTIONS_GHC -F -pgmF hspec-discover #-}
1+module Main where
2+
3+import qualified JavascriptSpec
4+
5+import Test.Hspec (Spec, hspec, describe)
6+
7+main :: IO ()
8+main = hspec spec
9+
10+spec :: Spec
11+spec = describe "Javascript" JavascriptSpec.spec
doc/tutorial/tutorial.cabal−2
@@ -83,8 +83,6 @@ test-suite spec
83 hs-source-dirs: test
83 hs-source-dirs: test
84 main-is: Spec.hs
84 main-is: Spec.hs
85 other-modules: JavascriptSpec
85 other-modules: JavascriptSpec
86− build-tool-depends:
87− hspec-discover:hspec-discover
88 build-depends: base
86 build-depends: base
89 , tutorial
87 , tutorial
90 , hspec
88 , hspec
servant-server/Setup.hs+1−32
@@ -1,33 +1,2 @@
1−{-# LANGUAGE CPP #-}
2−{-# OPTIONS_GHC -Wall #-}
3−module Main (main) where
4−
5−#ifndef MIN_VERSION_cabal_doctest
6−#define MIN_VERSION_cabal_doctest(x,y,z) 0
7−#endif
8−
9−#if MIN_VERSION_cabal_doctest(1,0,0)
10−
11−import Distribution.Extra.Doctest ( defaultMainWithDoctests )
12−main :: IO ()
13−main = defaultMainWithDoctests "doctests"
14−
15−#else
16−
17−#ifdef MIN_VERSION_Cabal
18−-- If the macro is defined, we have new cabal-install,
19−-- but for some reason we don't have cabal-doctest in package-db
20−--
21−-- Probably we are running cabal sdist, when otherwise using new-build
22−-- workflow
23−#warning You are configuring this package without cabal-doctest installed. \
24− The doctests test-suite will not work as a result. \
25− To fix this, install cabal-doctest before configuring.
26−#endif
27−
28−import Distribution.Simple
1+import Distribution.Simple
29−
30−main :: IO ()
31main = defaultMain
2main = defaultMain
32−
33−#endif
servant-server/servant-server.cabal+1−20
@@ -22,7 +22,7 @@ license-file: LICENSE
22author: Servant Contributors
22author: Servant Contributors
23maintainer: haskell-servant-maintainers@googlegroups.com
23maintainer: haskell-servant-maintainers@googlegroups.com
24copyright: 2014-2016 Zalora South East Asia Pte Ltd, 2016-2019 Servant Contributors
24copyright: 2014-2016 Zalora South East Asia Pte Ltd, 2016-2019 Servant Contributors
25−build-type: Custom
25+build-type: Simple
26tested-with:
26tested-with:
27 GHC ==8.0.2
27 GHC ==8.0.2
28 || ==8.2.2
28 || ==8.2.2
@@ -38,12 +38,6 @@ source-repository head
38 type: git
38 type: git
39 location: http://github.com/haskell-servant/servant.git
39 location: http://github.com/haskell-servant/servant.git
40
40
41−custom-setup
42− setup-depends:
43− base >= 4 && <5,
44− Cabal,
45− cabal-doctest >= 1.0.6 && <1.1
46−
47library
41library
48 exposed-modules:
42 exposed-modules:
49 Servant
43 Servant
@@ -173,16 +167,3 @@ test-suite spec
173
167
174 build-tool-depends:
168 build-tool-depends:
175 hspec-discover:hspec-discover >= 2.6.0 && <2.8
169 hspec-discover:hspec-discover >= 2.6.0 && <2.8
176−
177−test-suite doctests
178− build-depends:
179− base
180− , servant-server
181− , doctest >= 0.16.0 && <0.17
182− type: exitcode-stdio-1.0
183− main-is: test/doctests.hs
184− buildable: True
185− default-language: Haskell2010
186− ghc-options: -Wall -threaded
187− if impl(ghc >= 8.2)
188− x-doctest-options: -fdiagnostics-color=never
servant-server/test/doctests.hsdeleted−27
@@ -1,27 +0,0 @@
1−-----------------------------------------------------------------------------
2−-- |
3−-- Module : Main (doctests)
4−-- Copyright : (C) 2012-14 Edward Kmett
5−-- License : BSD-style (see the file LICENSE)
6−-- Maintainer : Edward Kmett <ekmett@gmail.com>
7−-- Stability : provisional
8−-- Portability : portable
9−--
10−-- This module provides doctests for a project based on the actual versions
11−-- of the packages it was built with. It requires a corresponding Setup.lhs
12−-- to be added to the project
13−-----------------------------------------------------------------------------
14−module Main where
15−
16−import Build_doctests
17− (flags, module_sources, pkgs)
18−import Data.Foldable
19− (traverse_)
20−import Test.DocTest
21−
22−main :: IO ()
23−main = do
24− traverse_ putStrLn args
25− doctest args
26− where
27− args = flags ++ pkgs ++ module_sources
servant/Setup.hs+1−32
@@ -1,33 +1,2 @@
1−{-# LANGUAGE CPP #-}
2−{-# OPTIONS_GHC -Wall #-}
3−module Main (main) where
4−
5−#ifndef MIN_VERSION_cabal_doctest
6−#define MIN_VERSION_cabal_doctest(x,y,z) 0
7−#endif
8−
9−#if MIN_VERSION_cabal_doctest(1,0,0)
10−
11−import Distribution.Extra.Doctest ( defaultMainWithDoctests )
12−main :: IO ()
13−main = defaultMainWithDoctests "doctests"
14−
15−#else
16−
17−#ifdef MIN_VERSION_Cabal
18−-- If the macro is defined, we have new cabal-install,
19−-- but for some reason we don't have cabal-doctest in package-db
20−--
21−-- Probably we are running cabal sdist, when otherwise using new-build
22−-- workflow
23−#warning You are configuring this package without cabal-doctest installed. \
24− The doctests test-suite will not work as a result. \
25− To fix this, install cabal-doctest before configuring.
26−#endif
27−
28−import Distribution.Simple
1+import Distribution.Simple
29−
30−main :: IO ()
31main = defaultMain
2main = defaultMain
32−
33−#endif
servant/servant.cabal+1−30
@@ -18,7 +18,7 @@ license-file: LICENSE
18author: Servant Contributors
18author: Servant Contributors
19maintainer: haskell-servant-maintainers@googlegroups.com
19maintainer: haskell-servant-maintainers@googlegroups.com
20copyright: 2014-2016 Zalora South East Asia Pte Ltd, 2016-2019 Servant Contributors
20copyright: 2014-2016 Zalora South East Asia Pte Ltd, 2016-2019 Servant Contributors
21−build-type: Custom
21+build-type: Simple
22
22
23tested-with:
23tested-with:
24 GHC ==8.0.2
24 GHC ==8.0.2
@@ -35,12 +35,6 @@ source-repository head
35 type: git
35 type: git
36 location: http://github.com/haskell-servant/servant.git
36 location: http://github.com/haskell-servant/servant.git
37
37
38−custom-setup
39− setup-depends:
40− base >= 4 && <5,
41− Cabal,
42− cabal-doctest >= 1.0.6 && <1.1
43−
44library
38library
45 exposed-modules:
39 exposed-modules:
46 Servant.API
40 Servant.API
@@ -176,26 +170,3 @@ test-suite spec
176
170
177 build-tool-depends:
171 build-tool-depends:
178 hspec-discover:hspec-discover >= 2.6.0 && < 2.8
172 hspec-discover:hspec-discover >= 2.6.0 && < 2.8
179−
180−test-suite doctests
181− if impl(ghcjs)
182− buildable: False
183−
184− build-depends:
185− base
186− , servant
187− , doctest >= 0.16.0 && <0.17
188−
189− -- We test Links failure with doctest, so we need extra dependencies
190− build-depends:
191− hspec >= 2.6.0 && < 2.8
192−
193− type: exitcode-stdio-1.0
194− main-is: test/doctests.hs
195− buildable: True
196− default-language: Haskell2010
197− ghc-options: -Wall -threaded
198− if impl(ghc >= 8.2)
199− x-doctest-options: -fdiagnostics-color=never
200− x-doctest-source-dirs: test
201− x-doctest-modules: Servant.LinksSpec
servant/test/Servant/LinksSpec.hs+3
@@ -92,6 +92,9 @@ spec = describe "Servant.Links" $ do
92 let firstLink :<|> _ = allLinks comprehensiveAPIWithoutRaw
92 let firstLink :<|> _ = allLinks comprehensiveAPIWithoutRaw
93 firstLink `shouldBeLink` ""
93 firstLink `shouldBeLink` ""
94
94
95+-- The doctests below aren't run on CI, setting that up is tricky.
96+-- They are run by makefile rule, however.
97+
95-- |
98-- |
96-- Before https://github.com/CRogers/should-not-typecheck/issues/5 is fixed,
99-- Before https://github.com/CRogers/should-not-typecheck/issues/5 is fixed,
97-- we'll just use doctest
100-- we'll just use doctest
servant/test/doctests.hsdeleted−27
@@ -1,27 +0,0 @@
1−-----------------------------------------------------------------------------
2−-- |
3−-- Module : Main (doctests)
4−-- Copyright : (C) 2012-14 Edward Kmett
5−-- License : BSD-style (see the file LICENSE)
6−-- Maintainer : Edward Kmett <ekmett@gmail.com>
7−-- Stability : provisional
8−-- Portability : portable
9−--
10−-- This module provides doctests for a project based on the actual versions
11−-- of the packages it was built with. It requires a corresponding Setup.lhs
12−-- to be added to the project
13−-----------------------------------------------------------------------------
14−module Main where
15−
16−import Build_doctests
17− (flags, module_sources, pkgs)
18−import Data.Foldable
19− (traverse_)
20−import Test.DocTest
21−
22−main :: IO ()
23−main = do
24− traverse_ putStrLn args
25− doctest args
26− where
27− args = flags ++ pkgs ++ module_sources