Skip to content

Commit 6fa1b23

Browse files
committed
Add support for cabal.project files.
Squashed commit of the following: commit fc696637241ea9321dde5abffcdcc1b3d507b34e Author: Oleg Grenrus <[email protected]> Date: Wed Oct 25 18:23:52 2017 +0300 Use fmap commit 430b316 Author: Merijn Verstraaten <[email protected]> Date: Wed Oct 25 13:51:44 2017 +0200 Add servant cabal files as test case and several cabal.project files to test. commit 144751f Author: Merijn Verstraaten <[email protected]> Date: Wed Oct 25 13:51:04 2017 +0200 Fix error reporting about incomplete GHC version range tests. commit 3e53f75 Author: Merijn Verstraaten <[email protected]> Date: Wed Oct 25 11:50:41 2017 +0200 Determine generation flags from YAML result. commit 37eff31 Author: Merijn Verstraaten <[email protected]> Date: Wed Oct 25 10:52:34 2017 +0200 Improve error reporting. commit d0a09e8 Author: Merijn Verstraaten <[email protected]> Date: Sat Oct 21 14:39:36 2017 +0200 Update Travis yaml file to new version and fix tests. commit 4f13d57 Merge: 5703564 3782b8e Author: Merijn Verstraaten <[email protected]> Date: Fri Oct 20 18:11:37 2017 +0200 Merge with tests by phadej. commit 3782b8e Author: Merijn Verstraaten <[email protected]> Date: Fri Oct 20 13:33:11 2017 +0200 Default directory globs to ending in "*.cabal". commit d5191fd Author: Merijn Verstraaten <[email protected]> Date: Tue Oct 17 09:57:38 2017 +0200 Add optional folding of build output. By default nothing is folded. Sections to fold are controlled by new `-f`/`--fold` flags. Default for flag without argument is to fold everything. commit 4d1e048 Author: Merijn Verstraaten <[email protected]> Date: Fri Oct 13 19:27:38 2017 +0200 Fix missing qualifier for `null`. commit a5e51d3 Author: Merijn Verstraaten <[email protected]> Date: Fri Oct 13 17:15:32 2017 +0200 Another attempt to fix build on GHC 7.8 commit 37fb886 Author: Merijn Verstraaten <[email protected]> Date: Fri Oct 13 16:57:04 2017 +0200 No null in Foldable. commit 39bcdee Author: Merijn Verstraaten <[email protected]> Date: Fri Oct 13 15:41:02 2017 +0200 Import foldable functions for old GHC. commit a9a0ef5 Author: Merijn Verstraaten <[email protected]> Date: Fri Oct 13 15:32:47 2017 +0200 More missing imports on older GHCs. commit 703c3a5 Author: Merijn Verstraaten <[email protected]> Date: Fri Oct 13 15:17:52 2017 +0200 Add missing import for Monoid(..). commit 606c397 Author: Merijn Verstraaten <[email protected]> Date: Fri Oct 13 15:08:58 2017 +0200 Add support for cabal.project files. make-travis-yml now accept cabal.project files as input argument in addition to cabal files, generating a test script that properly validates the individual packages.
1 parent 5703564 commit 6fa1b23

14 files changed

+1400
-197
lines changed

.travis.yml

+37-41
Original file line numberDiff line numberDiff line change
@@ -40,55 +40,51 @@ matrix:
4040
addons: {apt: {packages: [ghc-ppa-tools,cabal-install-head,ghc-8.2.1], sources: [hvr-ghc]}}
4141

4242
before_install:
43-
- HC=${CC}
44-
- HCPKG=${HC/ghc/ghc-pkg}
45-
- unset CC
46-
- PATH=/opt/ghc/bin:/opt/ghc-ppa-tools/bin:$PATH
47-
- PKGNAME='make-travis-yml'
43+
- HC=${CC}
44+
- HCPKG=${HC/ghc/ghc-pkg}
45+
- unset CC
46+
- PATH=/opt/ghc/bin:/opt/ghc-ppa-tools/bin:$PATH
4847

4948
install:
50-
- cabal --version
51-
- echo "$(${HC} --version) [$(${HC} --print-project-git-commit-id 2> /dev/null || echo '?')]"
52-
- BENCH=${BENCH---enable-benchmarks}
53-
- TEST=${TEST---enable-tests}
54-
- HADDOCK=${HADDOCK-true}
55-
- INSTALLED=${INSTALLED-true}
56-
- travis_retry cabal update -v
57-
- sed -i.bak 's/^jobs:/-- jobs:/' ${HOME}/.cabal/config
58-
- rm -fv cabal.project.local
59-
- "echo 'packages: .' > cabal.project"
60-
- rm -f cabal.project.freeze
61-
- cabal new-build -w ${HC} ${TEST} ${BENCH} --dep -j2 all
62-
- cabal new-build -w ${HC} --disable-tests --disable-benchmarks --dep -j2 all
49+
- cabal --version
50+
- echo "$(${HC} --version) [$(${HC} --print-project-git-commit-id 2> /dev/null || echo '?')]"
51+
- BENCH=${BENCH---enable-benchmarks}
52+
- TEST=${TEST---enable-tests}
53+
- HADDOCK=${HADDOCK-true}
54+
- INSTALLED=${INSTALLED-true}
55+
- travis_retry cabal update -v
56+
- sed -i.bak 's/^jobs:/-- jobs:/' ${HOME}/.cabal/config
57+
- rm -fv cabal.project.local
58+
- "echo 'packages: .' > cabal.project"
59+
- if [ -f "./configure.ac" ]; then
60+
(cd "."; autoreconf -i);
61+
fi
62+
- rm -f cabal.project.freeze
63+
- cabal new-build -w ${HC} ${TEST} ${BENCH} --project-file="cabal.project" --dep -j2 all
64+
- cabal new-build -w ${HC} --disable-tests --disable-benchmarks --project-file="cabal.project" --dep -j2 all
65+
- rm -rf "."/.ghc.environment.* "."/dist
66+
- DISTDIR=$(mktemp -d /tmp/dist-test.XXXX)
6367

6468
# Here starts the actual work to be performed for the package under test;
6569
# any command which exits with a non-zero exit code causes the build to fail.
6670
script:
67-
- if [ -f configure.ac ]; then autoreconf -i; fi
68-
- rm -rf .ghc.environment.* dist/
69-
- cabal sdist # test that a source-distribution can be generated
70-
- cd dist/
71-
- SRCTAR=(${PKGNAME}-*.tar.gz)
72-
- SRC_BASENAME="${SRCTAR/%.tar.gz}"
73-
- tar -xvf "./$SRC_BASENAME.tar.gz"
74-
- cd "$SRC_BASENAME/"
75-
## from here on, CWD is inside the extracted source-tarball
76-
- rm -fv cabal.project.local
77-
- "echo 'packages: .' > cabal.project"
78-
# this builds all libraries and executables (without tests/benchmarks)
79-
- rm -f cabal.project.freeze
80-
- cabal new-build -w ${HC} --disable-tests --disable-benchmarks all
81-
# this builds all libraries and executables (including tests/benchmarks)
82-
# - rm -rf ./dist-newstyle
71+
# test that source-distributions can be generated
72+
- (cd "."; cabal sdist)
73+
- mv "."/dist/make-travis-yml-*.tar.gz ${DISTDIR}/
74+
- cd ${DISTDIR}
75+
- find . -maxdepth 1 -name '*.tar.gz' -exec tar -xvf '{}' \;
76+
- "printf 'packages: make-travis-yml-*/*.cabal\n' > cabal.project"
77+
# this builds all libraries and executables (without tests/benchmarks)
78+
- cabal new-build -w ${HC} --disable-tests --disable-benchmarks all
8379

84-
# Build with installed constraints for packages in global-db
85-
- if $INSTALLED; then
86-
echo cabal new-build -w ${HC} --disable-tests --disable-benchmarks $(${HCPKG} list --global --simple-output --names-only | sed 's/\([a-zA-Z0-9-]\{1,\}\) */--constraint="\1 installed" /g') all | sh;
87-
else echo "Not building with installed constraints"; fi
80+
# Build with installed constraints for packages in global-db
81+
- if $INSTALLED; then
82+
echo cabal new-build -w ${HC} --disable-tests --disable-benchmarks $(${HCPKG} list --global --simple-output --names-only | sed 's/\([a-zA-Z0-9-]\{1,\}\) */--constraint="\1 installed" /g') all | sh;
83+
else echo "Not building with installed constraints"; fi
8884

89-
# build & run tests, build benchmarks
90-
- cabal new-build -w ${HC} ${TEST} ${BENCH} all
91-
- if [ "x$TEST" = "x--enable-tests" ]; then cabal new-test -w ${HC} ${TEST} all; fi
85+
# build & run tests, build benchmarks
86+
- cabal new-build -w ${HC} ${TEST} ${BENCH} all
87+
- if [ "x$TEST" = "x--enable-tests" ]; then cabal new-test -w ${HC} ${TEST} all; fi
9288

9389
# REGENDATA ["-o",".travis.yml","make-travis-yml.cabal"]
9490
# EOF

CONTRIBUTORS

+2
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Cabal files and directory structure from Servant, copyright of the Servant
2+
contributors, licensed under BSD3.

Tests.hs

+25-11
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,51 @@
11
module Main (main) where
22

3-
import MakeTravisYml (travisFromCabalFile, Options (..), defOptions, options)
3+
import MakeTravisYml (travisFromConfigFile, Options (..), defOptions, options)
44

5+
import Control.Exception (ErrorCall(..), throwIO)
56
import Control.Monad.Trans.Writer
67
import Data.Algorithm.Diff (Diff (..), getGroupedDiff)
8+
import Data.List (stripPrefix)
9+
import Data.Maybe (catMaybes)
710
import System.Console.GetOpt (getOpt, ArgOrder(Permute))
811
import System.Exit (exitFailure)
912
import System.FilePath (replaceExtension, (</>))
1013
import System.IO (hPutStrLn, stderr)
1114
import Test.Tasty (TestName, TestTree, defaultMain, testGroup)
1215
import Test.Tasty.Golden.Advanced (goldenTest)
16+
import Text.Read (readMaybe)
1317

1418
import qualified Data.ByteString as BS
1519
import qualified Data.ByteString.Char8 as BS8
1620

1721
main :: IO ()
1822
main = defaultMain $ testGroup "fixtures"
1923
[ fixtureGoldenTest "make-travis-yml.cabal"
20-
["-o",".travis.yml","make-travis-yml.cabal"]
2124
]
2225

23-
-- |
26+
linesToArgv :: String -> Maybe [String]
27+
linesToArgv txt = case catMaybes (map lineToArgv (lines txt)) of
28+
[argv] -> Just argv
29+
_ -> Nothing
30+
where
31+
lineToArgv line
32+
| Just rest <- "# REGENDATA " `stripPrefix` line = readMaybe rest
33+
| otherwise = Nothing
34+
35+
-- |
2436
-- @
25-
-- travisFromCabalFile ::
37+
-- travisFromConfigFile ::
2638
-- ... => ([String],Options) -> FilePath -> [String] -> Writer [String] m ()
2739
-- @
28-
fixtureGoldenTest :: FilePath -> [String] -> TestTree
29-
fixtureGoldenTest fp argv = cabalGoldenTest fp output $ do
30-
(opts, _fp, xpkgs) <- parseOpts argv
31-
fmap (BS8.pack . unlines) $ execWriterT $
32-
-- always pass empty argv
33-
-- TODO: make test take argv, parse them.
34-
travisFromCabalFile (argv, opts) fp xpkgs
40+
fixtureGoldenTest :: FilePath -> TestTree
41+
fixtureGoldenTest fp = cabalGoldenTest fp output $ do
42+
result <- BS8.unpack `fmap` BS.readFile output
43+
case linesToArgv result of
44+
Nothing -> throwIO (ErrorCall "No REGENDATA in result file.")
45+
Just argv -> do
46+
(opts, _fp, xpkgs) <- parseOpts argv
47+
fmap (BS8.pack . unlines) $ execWriterT $
48+
travisFromConfigFile (argv, opts) fp xpkgs
3549
where
3650
input = "fixtures" </> fp
3751
output = replaceExtension input "travis.yml"

fixtures/cabal.project.empty-line

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
packages:
2+
servant/
3+
servant-client/
4+
servant-docs/
5+
servant-server/

fixtures/cabal.project.fail-versions

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
packages: servant/
2+
servant-client/
3+
servant-client-core/
4+
servant-docs/
5+
servant-foreign/
6+
servant-server/
7+
doc/tutorial/

fixtures/doc/tutorial/tutorial.cabal

+65
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
name: tutorial
2+
version: 0.10
3+
synopsis: The servant tutorial
4+
homepage: http://haskell-servant.readthedocs.org/
5+
license: BSD3
6+
license-file: LICENSE
7+
author: Servant Contributors
8+
maintainer: [email protected]
9+
build-type: Simple
10+
cabal-version: >=1.10
11+
tested-with: GHC >= 7.10
12+
13+
library
14+
exposed-modules: ApiType
15+
, Authentication
16+
, Client
17+
, Docs
18+
, Javascript
19+
, Server
20+
build-depends: base == 4.*
21+
, base-compat
22+
, text
23+
, aeson
24+
, aeson-compat
25+
, blaze-html
26+
, directory
27+
, blaze-markup
28+
, containers
29+
, servant == 0.11.*
30+
, servant-server == 0.11.*
31+
, servant-client == 0.11.*
32+
, servant-docs == 0.11.*
33+
, servant-js >= 0.9 && <0.10
34+
, warp
35+
, http-api-data
36+
, http-media
37+
, lucid
38+
, time
39+
, string-conversions
40+
, bytestring
41+
, attoparsec
42+
, mtl
43+
, random
44+
, js-jquery
45+
, wai
46+
, http-types
47+
, transformers
48+
, markdown-unlit >= 0.4
49+
, http-client
50+
default-language: Haskell2010
51+
ghc-options: -Wall -pgmL markdown-unlit
52+
build-tool-depends: markdown-unlit:markdown-unlit
53+
54+
test-suite spec
55+
type: exitcode-stdio-1.0
56+
ghc-options: -Wall
57+
default-language: Haskell2010
58+
hs-source-dirs: test
59+
main-is: Spec.hs
60+
other-modules: JavascriptSpec
61+
build-depends: base == 4.*
62+
, tutorial
63+
, hspec
64+
, hspec-wai
65+
, string-conversions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
name: servant-client-core
2+
version: 0.11
3+
synopsis: Core functionality and class for client function generation for servant APIs
4+
description:
5+
This library provides backend-agnostic generation of client functions. For
6+
more information, see the README.
7+
license: BSD3
8+
license-file: LICENSE
9+
author: Servant Contributors
10+
maintainer: [email protected]
11+
homepage: http://haskell-servant.readthedocs.org/
12+
bug-reports: http://github.com/haskell-servant/servant/issues
13+
cabal-version: >=1.10
14+
copyright: 2014-2016 Zalora South East Asia Pte Ltd, 2016-2017 Servant Contributors
15+
category: Web
16+
build-type: Simple
17+
tested-with: GHC >= 7.10
18+
extra-source-files:
19+
include/*.h
20+
CHANGELOG.md
21+
README.md
22+
source-repository head
23+
type: git
24+
location: http://github.com/haskell-servant/servant.git
25+
26+
library
27+
exposed-modules:
28+
Servant.Client.Core
29+
Servant.Client.Core.Reexport
30+
Servant.Client.Core.Internal.Auth
31+
Servant.Client.Core.Internal.BaseUrl
32+
Servant.Client.Core.Internal.BasicAuth
33+
Servant.Client.Core.Internal.Generic
34+
Servant.Client.Core.Internal.HasClient
35+
Servant.Client.Core.Internal.Request
36+
Servant.Client.Core.Internal.RunClient
37+
build-depends:
38+
base >= 4.7 && < 4.11
39+
, base-compat >= 0.9.1 && < 0.10
40+
, base64-bytestring >= 1.0.0.1 && < 1.1
41+
, bytestring >= 0.10 && < 0.11
42+
, containers >= 0.5 && < 0.6
43+
, exceptions >= 0.8 && < 0.9
44+
, generics-sop >= 0.1.0.0 && < 0.4
45+
, http-api-data >= 0.3.6 && < 0.4
46+
, http-media >= 0.6.2 && < 0.8
47+
, http-types >= 0.8.6 && < 0.10
48+
, mtl >= 2.1 && < 2.3
49+
, network-uri >= 2.6 && < 2.7
50+
, safe >= 0.3.9 && < 0.4
51+
, servant == 0.11.*
52+
, text >= 1.2 && < 1.3
53+
if !impl(ghc >= 8.0)
54+
build-depends:
55+
semigroups >=0.16.2.2 && <0.19
56+
hs-source-dirs: src
57+
default-language: Haskell2010
58+
ghc-options: -Wall
59+
include-dirs: include
60+
61+
test-suite spec
62+
type: exitcode-stdio-1.0
63+
ghc-options: -Wall
64+
default-language: Haskell2010
65+
hs-source-dirs: test
66+
main-is: Spec.hs
67+
build-depends:
68+
base
69+
, base-compat
70+
, deepseq
71+
, servant-client-core
72+
, hspec == 2.*
73+
, QuickCheck >= 2.7 && < 2.11
74+
other-modules:
75+
Servant.Client.Core.Internal.BaseUrlSpec

0 commit comments

Comments
 (0)