git.iko.soy/typeable/openapi3
on master help sign in
Merge pull request #108 from phadej/ghc-8.2
3e81ba4Oleg Grenrus
.gitignore+2
@@ -1,4 +1,6 @@
1dist
1dist
2+dist-newstyle
3+.ghc.environment.*
2cabal-dev
4cabal-dev
3*.o
5*.o
4*.hi
6*.hi
.travis.yml+63−64
@@ -1,92 +1,91 @@
1+# This Travis job script has been generated by a script via
2+#
3+# make_travis_yml_2.hs '--branch' 'master' 'swagger2.cabal'
4+#
1−# This file has been generated -- see https://github.com/hvr/multi-ghc-travis
5+# For more information, see https://github.com/hvr/multi-ghc-travis
6+#
2language: c
7language: c
3sudo: false
8sudo: false
4
9
10+git:
11+ submodules: false # whether to recursively clone submodules
12+
13+branches:
14+ only:
15+ - master
16+
5cache:
17cache:
6 directories:
18 directories:
7− - $HOME/.cabsnap
8 - $HOME/.cabal/packages
19 - $HOME/.cabal/packages
20+ - $HOME/.cabal/store
21+ - $HOME/.local/bin
9
22
10before_cache:
23before_cache:
11 - rm -fv $HOME/.cabal/packages/hackage.haskell.org/build-reports.log
24 - rm -fv $HOME/.cabal/packages/hackage.haskell.org/build-reports.log
25+ # remove files that are regenerated by 'cabal update'
12− - rm -fv $HOME/.cabal/packages/hackage.haskell.org/00-index.tar
26+ - rm -fv $HOME/.cabal/packages/hackage.haskell.org/00-index.*
27+ - rm -fv $HOME/.cabal/packages/hackage.haskell.org/*.json
28+ - rm -fv $HOME/.cabal/packages/hackage.haskell.org/01-index.cache
29+ - rm -fv $HOME/.cabal/packages/hackage.haskell.org/01-index.tar
30+ - rm -fv $HOME/.cabal/packages/hackage.haskell.org/01-index.tar.idx
13
31
14matrix:
32matrix:
15 include:
33 include:
16− - env: CABALVER=1.18 GHCVER=7.8.4
34+ - compiler: "ghc-7.8.4"
17− compiler: ": #GHC 7.8.4"
35+ # env: TEST=--disable-tests BENCH=--disable-benchmarks
18− addons: {apt: {packages: [cabal-install-1.18,ghc-7.8.4,happy-1.19.5], sources: [hvr-ghc]}}
36+ addons: {apt: {packages: [ghc-ppa-tools,cabal-install-head,ghc-7.8.4], sources: [hvr-ghc]}}
19− - env: CABALVER=1.22 GHCVER=7.10.3
37+ - compiler: "ghc-7.10.3"
20− compiler: ": #GHC 7.10.3"
38+ # env: TEST=--disable-tests BENCH=--disable-benchmarks
21− addons: {apt: {packages: [cabal-install-1.22,ghc-7.10.3,happy-1.19.5], sources: [hvr-ghc]}}
39+ addons: {apt: {packages: [ghc-ppa-tools,cabal-install-head,ghc-7.10.3], sources: [hvr-ghc]}}
22− - env: CABALVER=1.24 GHCVER=8.0.1
23− compiler: ": #GHC 8.0.1"
40+ - compiler: "ghc-8.0.2"
24− addons: {apt: {packages: [cabal-install-1.24,ghc-8.0.1,happy-1.19.5], sources: [hvr-ghc]}}
41+ # env: TEST=--disable-tests BENCH=--disable-benchmarks
25− - env: CABALVER=1.18 GHCVER=7.8.4 CABALCONFIG=aeson-0.11.cabal.config
26− compiler: ": #GHC 7.8.4 aeson-0.11"
27− addons: {apt: {packages: [cabal-install-1.18,ghc-7.8.4,happy-1.19.5], sources: [hvr-ghc]}}
42+ addons: {apt: {packages: [ghc-ppa-tools,cabal-install-head,ghc-8.0.2], sources: [hvr-ghc]}}
28− - env: CABALVER=1.22 GHCVER=7.10.3 CABALCONFIG=aeson-0.11.cabal.config
29− compiler: ": #GHC 7.10.3 aeson-0.11"
43+ - compiler: "ghc-8.2.1"
30− addons: {apt: {packages: [cabal-install-1.22,ghc-7.10.3,happy-1.19.5], sources: [hvr-ghc]}}
44+ # env: TEST=--disable-tests BENCH=--disable-benchmarks
31− - env: CABALVER=1.24 GHCVER=8.0.1 CABALCONFIG=aeson-0.11.cabal.config
32− compiler: ": #GHC 8.0.1 aeson-0.11"
33− addons: {apt: {packages: [cabal-install-1.24,ghc-8.0.1,happy-1.19.5], sources: [hvr-ghc]}}
45+ addons: {apt: {packages: [ghc-ppa-tools,cabal-install-head,ghc-8.2.1], sources: [hvr-ghc]}}
34
46
35before_install:
47before_install:
48+ - HC=${CC}
36 - unset CC
49 - unset CC
37− - export PATH=/opt/ghc/$GHCVER/bin:/opt/cabal/$CABALVER/bin:/opt/happy/1.19.5/bin:$PATH
50+ - PATH=/opt/ghc/bin:/opt/ghc-ppa-tools/bin:$PATH
38− - if [ -f "$CABALCONFIG" ]; then cp $CABALCONFIG cabal.config; fi
51+ - PKGNAME='swagger2'
39
52
40install:
53install:
41 - cabal --version
54 - cabal --version
42− - echo "$(ghc --version) [$(ghc --print-project-git-commit-id 2> /dev/null || echo '?')]"
55+ - echo "$(${HC} --version) [$(${HC} --print-project-git-commit-id 2> /dev/null || echo '?')]"
43− - if [ -f $HOME/.cabal/packages/hackage.haskell.org/00-index.tar.gz ];
56+ - BENCH=${BENCH---enable-benchmarks}
44− then
57+ - TEST=${TEST---enable-tests}
45− zcat $HOME/.cabal/packages/hackage.haskell.org/00-index.tar.gz >
46− $HOME/.cabal/packages/hackage.haskell.org/00-index.tar;
47− fi
48 - travis_retry cabal update -v
58 - travis_retry cabal update -v
49 - sed -i 's/^jobs:/-- jobs:/' ${HOME}/.cabal/config
59 - sed -i 's/^jobs:/-- jobs:/' ${HOME}/.cabal/config
50− - cabal install --only-dependencies --enable-tests --enable-benchmarks --dry -v > installplan.txt
60+ - sh install-hspec-discover.sh # TEMP: we should use build-tools-depends
51− - sed -i -e '1,/^Resolving /d' installplan.txt; cat installplan.txt
61+ - rm -fv cabal.project.local
52−
62+ - "echo 'packages: .' > cabal.project"
53−# check whether current requested install-plan matches cached package-db snapshot
63+ - rm -f cabal.project.freeze
54− - if diff -u installplan.txt $HOME/.cabsnap/installplan.txt;
64+ - cabal new-build -w ${HC} ${TEST} ${BENCH} --dep -j2 all
55− then
65+ - cabal new-build -w ${HC} --disable-tests --disable-benchmarks --dep -j2 all
56− echo "cabal build-cache HIT";
57− rm -rfv .ghc;
58− cp -a $HOME/.cabsnap/ghc $HOME/.ghc;
59− cp -a $HOME/.cabsnap/lib $HOME/.cabsnap/share $HOME/.cabsnap/bin $HOME/.cabal/;
60− else
61− echo "cabal build-cache MISS";
62− rm -rf $HOME/.cabsnap;
63− mkdir -p $HOME/.ghc $HOME/.cabal/lib $HOME/.cabal/share $HOME/.cabal/bin;
64− cabal install --only-dependencies --enable-tests --enable-benchmarks;
65− fi
66−
67−# snapshot package-db on cache miss
68− - if [ ! -d $HOME/.cabsnap ];
69− then
70− echo "snapshotting package-db to build-cache";
71− mkdir $HOME/.cabsnap;
72− cp -a $HOME/.ghc $HOME/.cabsnap/ghc;
73− cp -a $HOME/.cabal/lib $HOME/.cabal/share $HOME/.cabal/bin installplan.txt $HOME/.cabsnap/;
74− fi
75
66
76# Here starts the actual work to be performed for the package under test;
67# Here starts the actual work to be performed for the package under test;
77# any command which exits with a non-zero exit code causes the build to fail.
68# any command which exits with a non-zero exit code causes the build to fail.
78script:
69script:
79 - if [ -f configure.ac ]; then autoreconf -i; fi
70 - if [ -f configure.ac ]; then autoreconf -i; fi
80− - cabal configure --enable-tests --enable-benchmarks -v2 # -v2 provides useful information for debugging
71+ - rm -rf .ghc.environment.* dist/
81− - cabal build # this builds all libraries and executables (including tests/benchmarks)
82− - cabal test
83− - cabal check
84− - cabal sdist # tests that a source-distribution can be generated
72+ - cabal sdist # test that a source-distribution can be generated
73+ - cd dist/
74+ - SRCTAR=(${PKGNAME}-*.tar.gz)
75+ - SRC_BASENAME="${SRCTAR/%.tar.gz}"
76+ - tar -xvf "./$SRC_BASENAME.tar.gz"
77+ - cd "$SRC_BASENAME/"
78+## from here on, CWD is inside the extracted source-tarball
79+ - rm -fv cabal.project.local
80+ - "echo 'packages: .' > cabal.project"
81+ # this builds all libraries and executables (without tests/benchmarks)
82+ - rm -f cabal.project.freeze
83+ - cabal new-build -w ${HC} --disable-tests --disable-benchmarks all
84+ # this builds all libraries and executables (including tests/benchmarks)
85+ # - rm -rf ./dist-newstyle
85
86
86−# Check that the resulting source distribution can be built & installed.
87+ # build & run tests
87−# If there are no other `.tar.gz` files in `dist`, this can be even simpler:
88+ - cabal new-build -w ${HC} ${TEST} ${BENCH} all
88−# `cabal install --force-reinstalls dist/*-*.tar.gz`
89+ - if [ "x$TEST" = "x--enable-tests" ]; then cabal new-test -w ${HC} ${TEST} all; fi
89− - SRC_TGZ=$(cabal info . | awk '{print $2;exit}').tar.gz &&
90− (cd dist && cabal install --force-reinstalls "$SRC_TGZ")
91
90
92# EOF
91# EOF
CHANGELOG.md+6
@@ -1,3 +1,9 @@
1+2.1.4.1
2+-------
3+
4+* GHC-8.2 support (see [#95](https://github.com/GetShopTV/swagger2/issues/95))
5+* Documentation corrections (see [#105](https://github.com/GetShopTV/swagger2/pull/105))
6+
12.1.4
72.1.4
2-----
8-----
3
9
Setup.hs+31
@@ -1,2 +1,33 @@
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+
1import Distribution.Simple
28import Distribution.Simple
29+
30+main :: IO ()
2main = defaultMain
31main = defaultMain
32+
33+#endif
install-hspec-discover.shnew file+18
@@ -0,0 +1,18 @@
1+#!/bin/sh
2+
3+set -ex
4+
5+if [ ! -e $HOME/.local/bin/hspec-discover ]; then
6+ # Fetch the source
7+ cabal get hspec-discover-2.4.4
8+ cd hspec-discover-2.4.4
9+
10+ # Set-up project
11+ echo 'packages: .' > cabal.project
12+
13+ # build exe
14+ cabal new-build hspec-discover:exe:hspec-discover
15+
16+ # copy executable to $HOME/.local/bin
17+ cp $(find dist-newstyle -name hspec-discover -type f) $HOME/.local/bin
18+fi
src/Data/Swagger/Internal/Schema.hs+3−5
@@ -65,10 +65,6 @@ import Data.Swagger.Lens hiding (name, schema)
65import qualified Data.Swagger.Lens as Swagger
65import qualified Data.Swagger.Lens as Swagger
66import Data.Swagger.SchemaOptions
66import Data.Swagger.SchemaOptions
67
67
68−#ifdef __DOCTEST__
69−import Data.Swagger.Lens (name, schema)
70−#endif
71−
72#if __GLASGOW_HASKELL__ < 800
68#if __GLASGOW_HASKELL__ < 800
73#else
69#else
74import qualified Data.ByteString as BS
70import qualified Data.ByteString as BS
@@ -729,7 +725,7 @@ gdeclareNamedSumSchema opts proxy s
729
725
730type AllNullary = All
726type AllNullary = All
731
727
732−class GSumToSchema f where
728+class GSumToSchema (f :: * -> *) where
733 gsumToSchema :: SchemaOptions -> proxy f -> Schema -> WriterT AllNullary (Declare (Definitions Schema)) Schema
729 gsumToSchema :: SchemaOptions -> proxy f -> Schema -> WriterT AllNullary (Declare (Definitions Schema)) Schema
734
730
735instance (GSumToSchema f, GSumToSchema g) => GSumToSchema (f :+: g) where
731instance (GSumToSchema f, GSumToSchema g) => GSumToSchema (f :+: g) where
@@ -768,3 +764,5 @@ data Proxy2 a b = Proxy2
768
764
769data Proxy3 a b c = Proxy3
765data Proxy3 a b c = Proxy3
770
766
767+-- $setup
768+-- >>> import Data.Swagger
swagger2.cabal+12−7
@@ -1,5 +1,5 @@
1name: swagger2
1name: swagger2
2−version: 2.1.4
2+version: 2.1.4.1
3synopsis: Swagger 2.0 data model
3synopsis: Swagger 2.0 data model
4description: Please see README.md
4description: Please see README.md
5homepage: https://github.com/GetShopTV/swagger2
5homepage: https://github.com/GetShopTV/swagger2
@@ -10,14 +10,18 @@ author: Nickolay Kudasov
10maintainer: nickolay@getshoptv.com
10maintainer: nickolay@getshoptv.com
11copyright: (c) 2015-2016, GetShopTV
11copyright: (c) 2015-2016, GetShopTV
12category: Web
12category: Web
13−build-type: Simple
13+build-type: Custom
14extra-source-files:
14extra-source-files:
15 README.md
15 README.md
16 , CHANGELOG.md
16 , CHANGELOG.md
17 , examples/*.hs
17 , examples/*.hs
18 , include/overlapping-compat.h
18 , include/overlapping-compat.h
19cabal-version: >=1.10
19cabal-version: >=1.10
20−tested-with: GHC==7.8.4, GHC==7.10.3, GHC==8.0.1
20+tested-with: GHC==7.8.4, GHC==7.10.3, GHC==8.0.2, GHC==8.2.1
21+
22+custom-setup
23+ setup-depends:
24+ base, Cabal, cabal-doctest >=1.0.2 && <1.1
21
25
22library
26library
23 hs-source-dirs: src
27 hs-source-dirs: src
@@ -39,7 +43,7 @@ library
39 Data.Swagger.Internal.ParamSchema
43 Data.Swagger.Internal.ParamSchema
40 Data.Swagger.Internal.Utils
44 Data.Swagger.Internal.Utils
41 Data.Swagger.Internal.AesonUtils
45 Data.Swagger.Internal.AesonUtils
42− build-depends: base >=4.7 && <4.10
46+ build-depends: base >=4.7 && <4.11
43 , base-compat >=0.9.1 && <0.10
47 , base-compat >=0.9.1 && <0.10
44 , aeson >=0.11.2.1
48 , aeson >=0.11.2.1
45 , bytestring
49 , bytestring
@@ -93,11 +97,12 @@ test-suite spec
93 Data.Swagger.Schema.ValidationSpec
97 Data.Swagger.Schema.ValidationSpec
94 default-language: Haskell2010
98 default-language: Haskell2010
95
99
96−test-suite doctest
100+test-suite doctests
101+ -- See QuickCheck note in https://github.com/phadej/cabal-doctest#notes
97− build-depends: base, doctest, Glob
102+ build-depends: base, doctest, Glob, QuickCheck
98 default-language: Haskell2010
103 default-language: Haskell2010
99 hs-source-dirs: test
104 hs-source-dirs: test
100− main-is: DocTest.hs
105+ main-is: doctests.hs
101 type: exitcode-stdio-1.0
106 type: exitcode-stdio-1.0
102
107
103source-repository head
108source-repository head
test/DocTest.hsdeleted−8
@@ -1,8 +0,0 @@
1−module Main (main) where
2−
3−import System.FilePath.Glob (glob)
4−import Test.DocTest (doctest)
5−
6−main :: IO ()
7−main = glob "src/**/*.hs" >>= doctest'
8− where doctest' files = doctest $ "-Iinclude/" : "-D__DOCTEST__" : files
test/doctests.hsnew file+12
@@ -0,0 +1,12 @@
1+module Main where
2+
3+import Build_doctests (flags, pkgs, module_sources)
4+import Data.Foldable (traverse_)
5+import Test.DocTest
6+
7+main :: IO ()
8+main = do
9+ traverse_ putStrLn args
10+ doctest args
11+ where
12+ args = flags ++ pkgs ++ module_sources