git.iko.soy/typeable/swagger2
on master help sign in
Merge pull request #108 from phadej/ghc-8.2

Support GHC-8.2

commit3e81ba4a890e74a21d1f3c2f3cc8bc3ed9ae4b80 authorOleg Grenrus <oleg.grenrus@iki.fi> dateFri 14 Jul 2017, 20:47 (9 years ago) parent73c4c77c4c904d
9 files changed+147−84
.gitignore+2 .travis.yml+63−64 CHANGELOG.md+6 Setup.hs+31 install-hspec-discover.sh+18 src/Data/Swagger/Internal/Schema.hs+3−5 swagger2.cabal+12−7 test/DocTest.hs−8 test/doctests.hs+12
.gitignore+2
@@ -1,4 +1,6 @@
11dist
2+dist-newstyle
3+.ghc.environment.*
24cabal-dev
35*.o
46*.hi
.travis.yml+63−64
@@ -1,92 +1,91 @@
1−# This file has been generated -- see https://github.com/hvr/multi-ghc-travis
1+# This Travis job script has been generated by a script via
2+#
3+# make_travis_yml_2.hs '--branch' 'master' 'swagger2.cabal'
4+#
5+# For more information, see https://github.com/hvr/multi-ghc-travis
6+#
27language: c
38sudo: false
49
10+git:
11+ submodules: false # whether to recursively clone submodules
12+
13+branches:
14+ only:
15+ - master
16+
517cache:
618 directories:
7− - $HOME/.cabsnap
819 - $HOME/.cabal/packages
20+ - $HOME/.cabal/store
21+ - $HOME/.local/bin
922
1023before_cache:
1124 - rm -fv $HOME/.cabal/packages/hackage.haskell.org/build-reports.log
12− - rm -fv $HOME/.cabal/packages/hackage.haskell.org/00-index.tar
25+ # remove files that are regenerated by 'cabal update'
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
1331
1432matrix:
1533 include:
16− - env: CABALVER=1.18 GHCVER=7.8.4
17− compiler: ": #GHC 7.8.4"
18− addons: {apt: {packages: [cabal-install-1.18,ghc-7.8.4,happy-1.19.5], sources: [hvr-ghc]}}
19− - env: CABALVER=1.22 GHCVER=7.10.3
20− compiler: ": #GHC 7.10.3"
21− addons: {apt: {packages: [cabal-install-1.22,ghc-7.10.3,happy-1.19.5], sources: [hvr-ghc]}}
22− - env: CABALVER=1.24 GHCVER=8.0.1
23− compiler: ": #GHC 8.0.1"
24− addons: {apt: {packages: [cabal-install-1.24,ghc-8.0.1,happy-1.19.5], sources: [hvr-ghc]}}
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]}}
28− - env: CABALVER=1.22 GHCVER=7.10.3 CABALCONFIG=aeson-0.11.cabal.config
29− compiler: ": #GHC 7.10.3 aeson-0.11"
30− addons: {apt: {packages: [cabal-install-1.22,ghc-7.10.3,happy-1.19.5], sources: [hvr-ghc]}}
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]}}
34+ - compiler: "ghc-7.8.4"
35+ # env: TEST=--disable-tests BENCH=--disable-benchmarks
36+ addons: {apt: {packages: [ghc-ppa-tools,cabal-install-head,ghc-7.8.4], sources: [hvr-ghc]}}
37+ - compiler: "ghc-7.10.3"
38+ # env: TEST=--disable-tests BENCH=--disable-benchmarks
39+ addons: {apt: {packages: [ghc-ppa-tools,cabal-install-head,ghc-7.10.3], sources: [hvr-ghc]}}
40+ - compiler: "ghc-8.0.2"
41+ # env: TEST=--disable-tests BENCH=--disable-benchmarks
42+ addons: {apt: {packages: [ghc-ppa-tools,cabal-install-head,ghc-8.0.2], sources: [hvr-ghc]}}
43+ - compiler: "ghc-8.2.1"
44+ # env: TEST=--disable-tests BENCH=--disable-benchmarks
45+ addons: {apt: {packages: [ghc-ppa-tools,cabal-install-head,ghc-8.2.1], sources: [hvr-ghc]}}
3446
3547before_install:
48+ - HC=${CC}
3649 - unset CC
37− - export PATH=/opt/ghc/$GHCVER/bin:/opt/cabal/$CABALVER/bin:/opt/happy/1.19.5/bin:$PATH
38− - if [ -f "$CABALCONFIG" ]; then cp $CABALCONFIG cabal.config; fi
50+ - PATH=/opt/ghc/bin:/opt/ghc-ppa-tools/bin:$PATH
51+ - PKGNAME='swagger2'
3952
4053install:
4154 - cabal --version
42− - echo "$(ghc --version) [$(ghc --print-project-git-commit-id 2> /dev/null || echo '?')]"
43− - if [ -f $HOME/.cabal/packages/hackage.haskell.org/00-index.tar.gz ];
44− then
45− zcat $HOME/.cabal/packages/hackage.haskell.org/00-index.tar.gz >
46− $HOME/.cabal/packages/hackage.haskell.org/00-index.tar;
47− fi
55+ - echo "$(${HC} --version) [$(${HC} --print-project-git-commit-id 2> /dev/null || echo '?')]"
56+ - BENCH=${BENCH---enable-benchmarks}
57+ - TEST=${TEST---enable-tests}
4858 - travis_retry cabal update -v
4959 - sed -i 's/^jobs:/-- jobs:/' ${HOME}/.cabal/config
50− - cabal install --only-dependencies --enable-tests --enable-benchmarks --dry -v > installplan.txt
51− - sed -i -e '1,/^Resolving /d' installplan.txt; cat installplan.txt
52−
53−# check whether current requested install-plan matches cached package-db snapshot
54− - if diff -u installplan.txt $HOME/.cabsnap/installplan.txt;
55− then
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
60+ - sh install-hspec-discover.sh # TEMP: we should use build-tools-depends
61+ - rm -fv cabal.project.local
62+ - "echo 'packages: .' > cabal.project"
63+ - rm -f cabal.project.freeze
64+ - cabal new-build -w ${HC} ${TEST} ${BENCH} --dep -j2 all
65+ - cabal new-build -w ${HC} --disable-tests --disable-benchmarks --dep -j2 all
7566
7667# Here starts the actual work to be performed for the package under test;
7768# any command which exits with a non-zero exit code causes the build to fail.
7869script:
7970 - if [ -f configure.ac ]; then autoreconf -i; fi
80− - cabal configure --enable-tests --enable-benchmarks -v2 # -v2 provides useful information for debugging
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
71+ - rm -rf .ghc.environment.* dist/
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
8586
86−# Check that the resulting source distribution can be built & installed.
87−# If there are no other `.tar.gz` files in `dist`, this can be even simpler:
88−# `cabal install --force-reinstalls dist/*-*.tar.gz`
89− - SRC_TGZ=$(cabal info . | awk '{print $2;exit}').tar.gz &&
90− (cd dist && cabal install --force-reinstalls "$SRC_TGZ")
87+ # build & run tests
88+ - cabal new-build -w ${HC} ${TEST} ${BENCH} all
89+ - if [ "x$TEST" = "x--enable-tests" ]; then cabal new-test -w ${HC} ${TEST} all; fi
9190
9291# 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+
172.1.4
28-----
39
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+
128import Distribution.Simple
29+
30+main :: IO ()
231main = 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)
6565import qualified Data.Swagger.Lens as Swagger
6666import Data.Swagger.SchemaOptions
6767
68−#ifdef __DOCTEST__
69−import Data.Swagger.Lens (name, schema)
70−#endif
71−
7268#if __GLASGOW_HASKELL__ < 800
7369#else
7470import qualified Data.ByteString as BS
@@ -729,7 +725,7 @@ gdeclareNamedSumSchema opts proxy s
729725
730726type AllNullary = All
731727
732−class GSumToSchema f where
728+class GSumToSchema (f :: * -> *) where
733729 gsumToSchema :: SchemaOptions -> proxy f -> Schema -> WriterT AllNullary (Declare (Definitions Schema)) Schema
734730
735731instance (GSumToSchema f, GSumToSchema g) => GSumToSchema (f :+: g) where
@@ -768,3 +764,5 @@ data Proxy2 a b = Proxy2
768764
769765data Proxy3 a b c = Proxy3
770766
767+-- $setup
768+-- >>> import Data.Swagger
swagger2.cabal+12−7
@@ -1,5 +1,5 @@
11name: swagger2
2−version: 2.1.4
2+version: 2.1.4.1
33synopsis: Swagger 2.0 data model
44description: Please see README.md
55homepage: https://github.com/GetShopTV/swagger2
@@ -10,14 +10,18 @@ author: Nickolay Kudasov
1010maintainer: nickolay@getshoptv.com
1111copyright: (c) 2015-2016, GetShopTV
1212category: Web
13−build-type: Simple
13+build-type: Custom
1414extra-source-files:
1515 README.md
1616 , CHANGELOG.md
1717 , examples/*.hs
1818 , include/overlapping-compat.h
1919cabal-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
2125
2226library
2327 hs-source-dirs: src
@@ -39,7 +43,7 @@ library
3943 Data.Swagger.Internal.ParamSchema
4044 Data.Swagger.Internal.Utils
4145 Data.Swagger.Internal.AesonUtils
42− build-depends: base >=4.7 && <4.10
46+ build-depends: base >=4.7 && <4.11
4347 , base-compat >=0.9.1 && <0.10
4448 , aeson >=0.11.2.1
4549 , bytestring
@@ -93,11 +97,12 @@ test-suite spec
9397 Data.Swagger.Schema.ValidationSpec
9498 default-language: Haskell2010
9599
96−test-suite doctest
97− build-depends: base, doctest, Glob
100+test-suite doctests
101+ -- See QuickCheck note in https://github.com/phadej/cabal-doctest#notes
102+ build-depends: base, doctest, Glob, QuickCheck
98103 default-language: Haskell2010
99104 hs-source-dirs: test
100− main-is: DocTest.hs
105+ main-is: doctests.hs
101106 type: exitcode-stdio-1.0
102107
103108source-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