Merge pull request #1263 from haskell-servant/build-type-simple

Change build-type: Simple; run doctests on CI via haskell-ci
This commit is contained in:
Oleg Grenrus 2020-01-10 01:18:39 +02:00 committed by GitHub
commit 831f46ab78
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
15 changed files with 72 additions and 200 deletions

View file

@ -4,7 +4,7 @@
# #
# For more information, see https://github.com/haskell-CI/haskell-ci # For more information, see https://github.com/haskell-CI/haskell-ci
# #
# version: 0.9.20191209 # version: 0.9.20200110
# #
version: ~> 1.0 version: ~> 1.0
language: c language: c
@ -73,26 +73,8 @@ before_install:
- TOP=$(pwd) - TOP=$(pwd)
- "HCNUMVER=$(${HC} --numeric-version|perl -ne '/^(\\d+)\\.(\\d+)\\.(\\d+)(\\.(\\d+))?$/; print(10000 * $1 + 100 * $2 + ($3 == 0 ? $5 != 1 : $3))')" - "HCNUMVER=$(${HC} --numeric-version|perl -ne '/^(\\d+)\\.(\\d+)\\.(\\d+)(\\.(\\d+))?$/; print(10000 * $1 + 100 * $2 + ($3 == 0 ? $5 != 1 : $3))')"
- echo $HCNUMVER - echo $HCNUMVER
- CABAL="$CABAL -vnormal+nowrap+markoutput" - CABAL="$CABAL -vnormal+nowrap"
- set -o pipefail - set -o pipefail
- |
echo 'function blue(s) { printf "\033[0;34m" s "\033[0m " }' >> .colorful.awk
echo 'BEGIN { state = "output"; }' >> .colorful.awk
echo '/^-----BEGIN CABAL OUTPUT-----$/ { state = "cabal" }' >> .colorful.awk
echo '/^-----END CABAL OUTPUT-----$/ { state = "output" }' >> .colorful.awk
echo '!/^(-----BEGIN CABAL OUTPUT-----|-----END CABAL OUTPUT-----)/ {' >> .colorful.awk
echo ' if (state == "cabal") {' >> .colorful.awk
echo ' print blue($0)' >> .colorful.awk
echo ' } else {' >> .colorful.awk
echo ' print $0' >> .colorful.awk
echo ' }' >> .colorful.awk
echo '}' >> .colorful.awk
- cat .colorful.awk
- |
color_cabal_output () {
awk -f $TOP/.colorful.awk
}
- echo text | color_cabal_output
install: install:
- ${CABAL} --version - ${CABAL} --version
- echo "$(${HC} --version) [$(${HC} --print-project-git-commit-id 2> /dev/null || echo '?')]" - echo "$(${HC} --version) [$(${HC} --print-project-git-commit-id 2> /dev/null || echo '?')]"
@ -133,8 +115,9 @@ install:
- cat $CABALHOME/config - cat $CABALHOME/config
- rm -fv cabal.project cabal.project.local cabal.project.freeze - rm -fv cabal.project cabal.project.local cabal.project.freeze
- travis_retry ${CABAL} v2-update -v - travis_retry ${CABAL} v2-update -v
- 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 - if ! $GHCJS ; then (cd /tmp && ${CABAL} v2-install $WITHCOMPILER -j2 doctest --constraint='doctest ==0.16.2.*') ; fi
- if $GHCJS ; then (cd /tmp && ${CABAL} v2-install -w ghc-8.4.4 hspec-discover | color_cabal_output) ; fi - 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
- if $GHCJS ; then (cd /tmp && ${CABAL} v2-install -w ghc-8.4.4 hspec-discover) ; fi
# Generate cabal.project # Generate cabal.project
- rm -rf cabal.project cabal.project.local cabal.project.freeze - rm -rf cabal.project cabal.project.local cabal.project.freeze
- touch cabal.project - touch cabal.project
@ -212,14 +195,14 @@ install:
- if [ -f "doc/cookbook/structuring-apis/configure.ac" ]; then (cd "doc/cookbook/structuring-apis" && autoreconf -i); fi - if [ -f "doc/cookbook/structuring-apis/configure.ac" ]; then (cd "doc/cookbook/structuring-apis" && autoreconf -i); fi
- if [ -f "doc/cookbook/using-custom-monad/configure.ac" ]; then (cd "doc/cookbook/using-custom-monad" && autoreconf -i); fi - if [ -f "doc/cookbook/using-custom-monad/configure.ac" ]; then (cd "doc/cookbook/using-custom-monad" && autoreconf -i); fi
- if [ -f "doc/cookbook/using-free-client/configure.ac" ]; then (cd "doc/cookbook/using-free-client" && autoreconf -i); fi - if [ -f "doc/cookbook/using-free-client/configure.ac" ]; then (cd "doc/cookbook/using-free-client" && autoreconf -i); fi
- ${CABAL} v2-freeze $WITHCOMPILER ${TEST} ${BENCH} | color_cabal_output - ${CABAL} v2-freeze $WITHCOMPILER ${TEST} ${BENCH}
- "cat cabal.project.freeze | sed -E 's/^(constraints: *| *)//' | sed 's/any.//'" - "cat cabal.project.freeze | sed -E 's/^(constraints: *| *)//' | sed 's/any.//'"
- rm cabal.project.freeze - rm cabal.project.freeze
script: script:
- DISTDIR=$(mktemp -d /tmp/dist-test.XXXX) - DISTDIR=$(mktemp -d /tmp/dist-test.XXXX)
# Packaging... # Packaging...
- echo 'Packaging...' && echo -en 'travis_fold:start:sdist\\r' - echo 'Packaging...' && echo -en 'travis_fold:start:sdist\\r'
- ${CABAL} v2-sdist all | color_cabal_output - ${CABAL} v2-sdist all
- echo -en 'travis_fold:end:sdist\\r' - echo -en 'travis_fold:end:sdist\\r'
# Unpacking... # Unpacking...
- echo 'Unpacking...' && echo -en 'travis_fold:start:unpack\\r' - echo 'Unpacking...' && echo -en 'travis_fold:start:unpack\\r'
@ -335,15 +318,29 @@ script:
# Building with tests and benchmarks... # Building with tests and benchmarks...
- echo 'Building with tests and benchmarks...' && echo -en 'travis_fold:start:build-everything\\r' - echo 'Building with tests and benchmarks...' && echo -en 'travis_fold:start:build-everything\\r'
# build & run tests, build benchmarks # build & run tests, build benchmarks
- ${CABAL} v2-build $WITHCOMPILER ${TEST} ${BENCH} all | color_cabal_output - ${CABAL} v2-build $WITHCOMPILER ${TEST} ${BENCH} all
- echo -en 'travis_fold:end:build-everything\\r' - echo -en 'travis_fold:end:build-everything\\r'
# Testing... # Testing...
- if ! $GHCJS ; then ${CABAL} v2-test $WITHCOMPILER ${TEST} ${BENCH} all | color_cabal_output ; fi - if ! $GHCJS ; then ${CABAL} v2-test $WITHCOMPILER ${TEST} ${BENCH} all ; fi
- 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 - 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
# Doctest...
- echo 'Doctest...' && echo -en 'travis_fold:start:doctest\\r'
- perl -i -e 'while (<ARGV>) { print unless /package-id\s+(base-compat-batteries)-\d+(\.\d+)*/; }' .ghc.environment.*
- if ! $GHCJS ; then (cd ${PKGDIR_servant} && doctest src) ; fi
- if ! $GHCJS ; then (cd ${PKGDIR_servant_client} && doctest src) ; fi
- if ! $GHCJS ; then (cd ${PKGDIR_servant_client_core} && doctest src) ; fi
- if ! $GHCJS ; then (cd ${PKGDIR_servant_http_streams} && doctest src) ; fi
- if ! $GHCJS ; then (cd ${PKGDIR_servant_docs} && doctest src) ; fi
- if ! $GHCJS ; then (cd ${PKGDIR_servant_foreign} && doctest src) ; fi
- if ! $GHCJS ; then (cd ${PKGDIR_servant_server} && doctest src) ; fi
- if ! $GHCJS ; then (cd ${PKGDIR_servant_machines} && doctest src) ; fi
- if ! $GHCJS ; then (cd ${PKGDIR_servant_conduit} && doctest src) ; fi
- if ! $GHCJS ; then (cd ${PKGDIR_servant_pipes} && doctest src) ; fi
- echo -en 'travis_fold:end:doctest\\r'
# haddock... # haddock...
- echo 'haddock...' && echo -en 'travis_fold:start:haddock\\r' - echo 'haddock...' && echo -en 'travis_fold:start:haddock\\r'
- if ! $GHCJS ; then ${CABAL} v2-haddock $WITHCOMPILER --with-haddock $HADDOCK ${TEST} ${BENCH} all | color_cabal_output ; fi - if ! $GHCJS ; then ${CABAL} v2-haddock $WITHCOMPILER --with-haddock $HADDOCK ${TEST} ${BENCH} all ; fi
- echo -en 'travis_fold:end:haddock\\r' - echo -en 'travis_fold:end:haddock\\r'
# REGENDATA ("0.9.20191209",["--config=cabal.haskell-ci","--output=.travis.yml","cabal.project"]) # REGENDATA ("0.9.20200110",["--config=cabal.haskell-ci","--output=.travis.yml","cabal.project"])
# EOF # EOF

View file

@ -20,3 +20,13 @@ build-ghcjs :
packdeps : packdeps :
packdeps */*.cabal packdeps */*.cabal
doctest : doctest-servant doctest-servant-server
perl -i -e 'while (<ARGV>) { print unless /package-id\s+base-compat-\d+(\.\d+)*/; }' .ghc.environment.*
doctest-servant :
(cd servant && doctest src)
(cd servant && doctest test/Servant/LinksSpec.hs)
doctest-servant-server :
(cd servant-server && doctest src)

View file

@ -4,6 +4,9 @@ branches: master
jobs-selection: any jobs-selection: any
google-chrome: True google-chrome: True
ghcjs-tests: True ghcjs-tests: True
doctest: True
doctest-filter-packages: base-compat-batteries
doctest-skip: tutorial
-- https://github.com/haskell/cabal/issues/6176 -- https://github.com/haskell/cabal/issues/6176
ghcjs-tools: hspec-discover ghcjs-tools: hspec-discover

View file

@ -76,3 +76,6 @@ allow-newer: jsaddle-dom-0.9.3.2:lens
allow-newer: jsaddle-warp-0.9.6.0:time allow-newer: jsaddle-warp-0.9.6.0:time
constraints: base-compat ^>=0.11 constraints: base-compat ^>=0.11
-- needed for doctests
write-ghc-environment-files: always

View file

@ -1,6 +1,7 @@
synopsis: use queryString to parse QueryParam, QueryParams and QueryFlag synopsis: use queryString to parse QueryParam, QueryParams and QueryFlag
packages: servant-server packages: servant-server
prs: #1249 prs: #1249 #1262
significance: significant
description: { description: {
Some APIs need query parameters rewriting, e.g. in order to support Some APIs need query parameters rewriting, e.g. in order to support

11
changelog.d/pr1263 Normal file
View file

@ -0,0 +1,11 @@
synopsis: Make packages `build-type: Simple`
packages: servant servant-server
prs: #1263
significance: significant
description: {
We used `build-type: Custom`, but it's problematic e.g.
for cross-compiling. The benefit is small, as the doctests
can be run other ways too (though not so conviniently).
}

View file

@ -1 +1,11 @@
{-# OPTIONS_GHC -F -pgmF hspec-discover #-} module Main where
import qualified JavascriptSpec
import Test.Hspec (Spec, hspec, describe)
main :: IO ()
main = hspec spec
spec :: Spec
spec = describe "Javascript" JavascriptSpec.spec

View file

@ -83,8 +83,6 @@ test-suite spec
hs-source-dirs: test hs-source-dirs: test
main-is: Spec.hs main-is: Spec.hs
other-modules: JavascriptSpec other-modules: JavascriptSpec
build-tool-depends:
hspec-discover:hspec-discover
build-depends: base build-depends: base
, tutorial , tutorial
, hspec , hspec

View file

@ -1,33 +1,2 @@
{-# LANGUAGE CPP #-} import Distribution.Simple
{-# OPTIONS_GHC -Wall #-}
module Main (main) where
#ifndef MIN_VERSION_cabal_doctest
#define MIN_VERSION_cabal_doctest(x,y,z) 0
#endif
#if MIN_VERSION_cabal_doctest(1,0,0)
import Distribution.Extra.Doctest ( defaultMainWithDoctests )
main :: IO ()
main = defaultMainWithDoctests "doctests"
#else
#ifdef MIN_VERSION_Cabal
-- If the macro is defined, we have new cabal-install,
-- but for some reason we don't have cabal-doctest in package-db
--
-- Probably we are running cabal sdist, when otherwise using new-build
-- workflow
#warning You are configuring this package without cabal-doctest installed. \
The doctests test-suite will not work as a result. \
To fix this, install cabal-doctest before configuring.
#endif
import Distribution.Simple
main :: IO ()
main = defaultMain main = defaultMain
#endif

View file

@ -22,7 +22,7 @@ license-file: LICENSE
author: Servant Contributors author: Servant Contributors
maintainer: haskell-servant-maintainers@googlegroups.com maintainer: haskell-servant-maintainers@googlegroups.com
copyright: 2014-2016 Zalora South East Asia Pte Ltd, 2016-2019 Servant Contributors copyright: 2014-2016 Zalora South East Asia Pte Ltd, 2016-2019 Servant Contributors
build-type: Custom build-type: Simple
tested-with: tested-with:
GHC ==8.0.2 GHC ==8.0.2
|| ==8.2.2 || ==8.2.2
@ -38,12 +38,6 @@ source-repository head
type: git type: git
location: http://github.com/haskell-servant/servant.git location: http://github.com/haskell-servant/servant.git
custom-setup
setup-depends:
base >= 4 && <5,
Cabal,
cabal-doctest >= 1.0.6 && <1.1
library library
exposed-modules: exposed-modules:
Servant Servant
@ -173,16 +167,3 @@ test-suite spec
build-tool-depends: build-tool-depends:
hspec-discover:hspec-discover >= 2.6.0 && <2.8 hspec-discover:hspec-discover >= 2.6.0 && <2.8
test-suite doctests
build-depends:
base
, servant-server
, doctest >= 0.16.0 && <0.17
type: exitcode-stdio-1.0
main-is: test/doctests.hs
buildable: True
default-language: Haskell2010
ghc-options: -Wall -threaded
if impl(ghc >= 8.2)
x-doctest-options: -fdiagnostics-color=never

View file

@ -1,27 +0,0 @@
-----------------------------------------------------------------------------
-- |
-- Module : Main (doctests)
-- Copyright : (C) 2012-14 Edward Kmett
-- License : BSD-style (see the file LICENSE)
-- Maintainer : Edward Kmett <ekmett@gmail.com>
-- Stability : provisional
-- Portability : portable
--
-- This module provides doctests for a project based on the actual versions
-- of the packages it was built with. It requires a corresponding Setup.lhs
-- to be added to the project
-----------------------------------------------------------------------------
module Main where
import Build_doctests
(flags, module_sources, pkgs)
import Data.Foldable
(traverse_)
import Test.DocTest
main :: IO ()
main = do
traverse_ putStrLn args
doctest args
where
args = flags ++ pkgs ++ module_sources

View file

@ -1,33 +1,2 @@
{-# LANGUAGE CPP #-} import Distribution.Simple
{-# OPTIONS_GHC -Wall #-}
module Main (main) where
#ifndef MIN_VERSION_cabal_doctest
#define MIN_VERSION_cabal_doctest(x,y,z) 0
#endif
#if MIN_VERSION_cabal_doctest(1,0,0)
import Distribution.Extra.Doctest ( defaultMainWithDoctests )
main :: IO ()
main = defaultMainWithDoctests "doctests"
#else
#ifdef MIN_VERSION_Cabal
-- If the macro is defined, we have new cabal-install,
-- but for some reason we don't have cabal-doctest in package-db
--
-- Probably we are running cabal sdist, when otherwise using new-build
-- workflow
#warning You are configuring this package without cabal-doctest installed. \
The doctests test-suite will not work as a result. \
To fix this, install cabal-doctest before configuring.
#endif
import Distribution.Simple
main :: IO ()
main = defaultMain main = defaultMain
#endif

View file

@ -18,7 +18,7 @@ license-file: LICENSE
author: Servant Contributors author: Servant Contributors
maintainer: haskell-servant-maintainers@googlegroups.com maintainer: haskell-servant-maintainers@googlegroups.com
copyright: 2014-2016 Zalora South East Asia Pte Ltd, 2016-2019 Servant Contributors copyright: 2014-2016 Zalora South East Asia Pte Ltd, 2016-2019 Servant Contributors
build-type: Custom build-type: Simple
tested-with: tested-with:
GHC ==8.0.2 GHC ==8.0.2
@ -35,12 +35,6 @@ source-repository head
type: git type: git
location: http://github.com/haskell-servant/servant.git location: http://github.com/haskell-servant/servant.git
custom-setup
setup-depends:
base >= 4 && <5,
Cabal,
cabal-doctest >= 1.0.6 && <1.1
library library
exposed-modules: exposed-modules:
Servant.API Servant.API
@ -176,26 +170,3 @@ test-suite spec
build-tool-depends: build-tool-depends:
hspec-discover:hspec-discover >= 2.6.0 && < 2.8 hspec-discover:hspec-discover >= 2.6.0 && < 2.8
test-suite doctests
if impl(ghcjs)
buildable: False
build-depends:
base
, servant
, doctest >= 0.16.0 && <0.17
-- We test Links failure with doctest, so we need extra dependencies
build-depends:
hspec >= 2.6.0 && < 2.8
type: exitcode-stdio-1.0
main-is: test/doctests.hs
buildable: True
default-language: Haskell2010
ghc-options: -Wall -threaded
if impl(ghc >= 8.2)
x-doctest-options: -fdiagnostics-color=never
x-doctest-source-dirs: test
x-doctest-modules: Servant.LinksSpec

View file

@ -92,6 +92,9 @@ spec = describe "Servant.Links" $ do
let firstLink :<|> _ = allLinks comprehensiveAPIWithoutRaw let firstLink :<|> _ = allLinks comprehensiveAPIWithoutRaw
firstLink `shouldBeLink` "" firstLink `shouldBeLink` ""
-- The doctests below aren't run on CI, setting that up is tricky.
-- They are run by makefile rule, however.
-- | -- |
-- Before https://github.com/CRogers/should-not-typecheck/issues/5 is fixed, -- Before https://github.com/CRogers/should-not-typecheck/issues/5 is fixed,
-- we'll just use doctest -- we'll just use doctest

View file

@ -1,27 +0,0 @@
-----------------------------------------------------------------------------
-- |
-- Module : Main (doctests)
-- Copyright : (C) 2012-14 Edward Kmett
-- License : BSD-style (see the file LICENSE)
-- Maintainer : Edward Kmett <ekmett@gmail.com>
-- Stability : provisional
-- Portability : portable
--
-- This module provides doctests for a project based on the actual versions
-- of the packages it was built with. It requires a corresponding Setup.lhs
-- to be added to the project
-----------------------------------------------------------------------------
module Main where
import Build_doctests
(flags, module_sources, pkgs)
import Data.Foldable
(traverse_)
import Test.DocTest
main :: IO ()
main = do
traverse_ putStrLn args
doctest args
where
args = flags ++ pkgs ++ module_sources