git.iko.soy/typeable/servant-swagger-ui
on master help sign in
Regenerate .travis.yml
commit81f04bd91724e5652d2d0a099644a09c967d645c authorOleg Grenrus <oleg.grenrus@iki.fi> dateSun 10 Dec 2017, 01:12 (9 years ago) parent1ee4f6c
3 files changed+147−51
.travis.yml+45−50 constraints.hs+101 servant-swagger-ui.cabal+1−1
.travis.yml+45−50
@@ -1,6 +1,6 @@
11# This Travis job script has been generated by a script via
22#
3−# make_travis_yml_2.hs '--branch' 'master' 'servant-swagger-ui.cabal'
3+# make_travis_yml_2.hs '-o' '.travis.yml' '--branch' 'master' '--constraints=$ROOTDIR/constraints.hs' 'servant-swagger-ui.cabal'
44#
55# For more information, see https://github.com/hvr/multi-ghc-travis
66#
@@ -39,67 +39,62 @@ matrix:
3939 - compiler: "ghc-8.0.2"
4040 # env: TEST=--disable-tests BENCH=--disable-benchmarks
4141 addons: {apt: {packages: [ghc-ppa-tools,cabal-install-head,ghc-8.0.2], sources: [hvr-ghc]}}
42− - compiler: "ghc-8.2.1"
42+ - compiler: "ghc-8.2.2"
4343 # env: TEST=--disable-tests BENCH=--disable-benchmarks
44− addons: {apt: {packages: [ghc-ppa-tools,cabal-install-head,ghc-8.2.1], sources: [hvr-ghc]}}
44+ addons: {apt: {packages: [ghc-ppa-tools,cabal-install-head,ghc-8.2.2], sources: [hvr-ghc]}}
4545
4646before_install:
47− - HC=${CC}
48− - unset CC
49− - PATH=/opt/ghc/bin:/opt/ghc-ppa-tools/bin:$PATH
50− - PKGNAME='servant-swagger-ui'
47+ - HC=${CC}
48+ - HCPKG=${HC/ghc/ghc-pkg}
49+ - unset CC
50+ - ROOTDIR=$(pwd)
51+ - "PATH=/opt/ghc/bin:/opt/ghc-ppa-tools/bin:$PATH"
5152
5253install:
53− - cabal --version
54− - echo "$(${HC} --version) [$(${HC} --print-project-git-commit-id 2> /dev/null || echo '?')]"
55− - BENCH=${BENCH---enable-benchmarks}
56− - TEST=${TEST---enable-tests}
57− - travis_retry cabal update -v
58− - sed -i 's/^jobs:/-- jobs:/' ${HOME}/.cabal/config
59− - rm -fv cabal.project.local
60− - "echo 'packages: .' > cabal.project"
61− - rm -f cabal.project.freeze
62− - cabal new-build -w ${HC} ${TEST} ${BENCH} --dep -j2 all
63− - cabal new-build -w ${HC} --disable-tests --disable-benchmarks --dep -j2 all
54+ - cabal --version
55+ - echo "$(${HC} --version) [$(${HC} --print-project-git-commit-id 2> /dev/null || echo '?')]"
56+ - BENCH=${BENCH---enable-benchmarks}
57+ - TEST=${TEST---enable-tests}
58+ - HADDOCK=${HADDOCK-true}
59+ - INSTALLED=${INSTALLED-true}
60+ - travis_retry cabal update -v
61+ - "sed -i.bak 's/^jobs:/-- jobs:/' ${HOME}/.cabal/config"
62+ - rm -fv cabal.project.local
63+ - "echo 'packages: .' > cabal.project"
64+ - if [ -f "./configure.ac" ]; then
65+ (cd "."; autoreconf -i);
66+ fi
67+ - rm -f cabal.project.freeze
68+ - cabal new-build -w ${HC} ${TEST} ${BENCH} --project-file="cabal.project" --dep -j2 all
69+ - cabal new-build -w ${HC} --disable-tests --disable-benchmarks --project-file="cabal.project" --dep -j2 all
70+ - rm -rf "."/.ghc.environment.* "."/dist
71+ - DISTDIR=$(mktemp -d /tmp/dist-test.XXXX)
6472
6573# Here starts the actual work to be performed for the package under test;
6674# any command which exits with a non-zero exit code causes the build to fail.
6775script:
68− - if [ -f configure.ac ]; then autoreconf -i; fi
69− - rm -rf .ghc.environment.* dist/
70− - cabal sdist # test that a source-distribution can be generated
71− - cd dist/
72− - SRCTAR=(${PKGNAME}-*.tar.gz)
73− - SRC_BASENAME="${SRCTAR/%.tar.gz}"
74− - tar -xvf "./$SRC_BASENAME.tar.gz"
75− - cd "$SRC_BASENAME/"
76−## from here on, CWD is inside the extracted source-tarball
77− - rm -fv cabal.project.local
78− - "echo 'packages: .' > cabal.project"
79− # this builds all libraries and executables (without tests/benchmarks)
80− - rm -f cabal.project.freeze
81− - cabal new-build -w ${HC} --disable-tests --disable-benchmarks all
82− # this builds all libraries and executables (including tests/benchmarks)
83− # - rm -rf ./dist-newstyle
76+ # test that source-distributions can be generated
77+ - (cd "." && cabal sdist)
78+ - mv "."/dist/servant-swagger-ui-*.tar.gz ${DISTDIR}/
79+ - cd ${DISTDIR} || false
80+ - find . -maxdepth 1 -name '*.tar.gz' -exec tar -xvf '{}' \;
81+ - "printf 'packages: servant-swagger-ui-*/*.cabal\\n' > cabal.project"
82+ # this builds all libraries and executables (without tests/benchmarks)
83+ - cabal new-build -w ${HC} --disable-tests --disable-benchmarks all
8484
85− - if [ $HC = "ghc-8.0.2" -o $HC = "ghc-8.2.1" ]; then UNLESSGHC80=true; fi
86− - if [ $HC = "ghc-8.2.1" ]; then UNLESSGHC82=true; fi
85+ # Build with installed constraints for packages in global-db
86+ - if $INSTALLED; then 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; else echo "Not building with installed constraints"; fi
8787
88− #- $UNLESSGHC80 cabal new-build -w ${HC} --disable-tests --disable-benchmarks '--constraint=servant==0.4.*'
89− #- $UNLESSGHC80 cabal new-build -w ${HC} --disable-tests --disable-benchmarks '--constraint=servant==0.5.*'
90− #- $UNLESSGHC80 cabal new-build -w ${HC} --disable-tests --disable-benchmarks '--constraint=servant==0.6.*'
91− #- $UNLESSGHC82 cabal new-build -w ${HC} --disable-tests --disable-benchmarks '--constraint=servant==0.7.*'
92− #- $UNLESSGHC82 cabal new-build -w ${HC} --disable-tests --disable-benchmarks '--constraint=servant==0.8.*'
93− - $UNLESSGHC82 cabal new-build -w ${HC} --disable-tests --disable-benchmarks '--constraint=servant==0.9.*'
94− - $UNLESSGHC82 cabal new-build -w ${HC} --disable-tests --disable-benchmarks '--constraint=servant==0.10.*'
95− - cabal new-build -w ${HC} --disable-tests --disable-benchmarks '--constraint=servant==0.11.*'
88+ # build & run tests, build benchmarks
89+ - cabal new-build -w ${HC} ${TEST} ${BENCH} all
90+ - if [ "x$TEST" = "x--enable-tests" ]; then cabal new-test -w ${HC} ${TEST} all; fi
9691
92+ # build & run tests, with constraints
93+ - for c in $($ROOTDIR/constraints.hs list ${HC}); do echo "=== Constraint" $c; echo "--------------------------------"; cabal new-build -w ${HC} --disable-tests --disable-benchmarks $($ROOTDIR/constraints.hs constraints $c) all; done
9794
98− # build & run tests, build benchmarks
99− - cabal new-build -w ${HC} ${TEST} ${BENCH} all
100− - if [ "x$TEST" = "x--enable-tests" ]; then cabal new-test -w ${HC} ${TEST} all; fi
101−
102− # haddock
103− - cabal new-haddock -w ${HC} --disable-tests --disable-benchmarks all
95+ # haddock
96+ - rm -rf ./dist-newstyle
97+ - if $HADDOCK; then cabal new-haddock -w ${HC} --disable-tests --disable-benchmarks all; else echo "Skipping haddock generation";fi
10498
99+# REGENDATA ["-o",".travis.yml","--branch","master","--constraints=$ROOTDIR/constraints.hs","servant-swagger-ui.cabal"]
105100# EOF
constraints.hsnew file+101
@@ -0,0 +1,101 @@
1+#!/usr/bin/env runghc
2+{-# OPTIONS_GHC -Wall #-}
3+
4+import Data.Char (toLower)
5+import Data.Foldable (traverse_)
6+import Data.List (isPrefixOf)
7+import Data.Version (Version, parseVersion)
8+import System.Environment (getArgs)
9+import Text.ParserCombinators.ReadP (readP_to_S)
10+
11+-------------------------------------------------------------------------------
12+-- Definitions
13+-------------------------------------------------------------------------------
14+
15+-- | The guts of the implementation works with this value.
16+defns :: [Defn]
17+defns = map defn [minBound .. maxBound]
18+
19+-- | C is a helper type to make 'defns'
20+data C
21+ = Servant_0_4
22+ | Servant_0_5
23+ | Servant_0_6
24+ | Servant_0_7
25+ | Servant_0_8
26+ | Servant_0_9
27+ | Servant_0_10
28+ | Servant_0_11
29+ | Servant_0_12
30+ deriving (Eq, Show, Enum, Bounded)
31+
32+-- Constraint definitions
33+defn :: C -> Defn
34+defn c = case c of
35+ -- identifier, constraint, min <= v < max ghc versions
36+ -- Note: we shouldn't have spaces in the constraint, because /bin/sh
37+ Servant_0_4 -> mkDefn c ["servant==0.4.4.*"] "7.8" "8.0"
38+ Servant_0_5 -> mkDefn c ["servant==0.5.*" ] "7.8" "8.0"
39+ Servant_0_6 -> mkDefn c ["servant==0.6.*" ] "7.8" "8.0"
40+ Servant_0_7 -> mkDefn c ["servant==0.7.*" ] "7.8" "8.2"
41+ Servant_0_8 -> mkDefn c ["servant==0.8.*" ] "7.8" "8.2"
42+ Servant_0_9 -> mkDefn c ["servant==0.9.*" ] "7.8" "8.2"
43+ Servant_0_10 -> mkDefn c ["servant==0.10.*" ] "7.8" "8.2"
44+ Servant_0_11 -> mkDefn c ["servant==0.11.*" ] "7.8" "8.3"
45+ Servant_0_12 -> mkDefn c ["servant==0.12.*" ] "7.8" "8.3"
46+
47+mkDefn :: C -> [String] -> String -> String -> Defn
48+mkDefn c x mi ma = Defn (map toLower $ show c) x (unsafeMkV mi) (unsafeMkV ma)
49+
50+-------------------------------------------------------------------------------
51+-- Implementation
52+-------------------------------------------------------------------------------
53+
54+data Defn = Defn
55+ { defnId :: String
56+ , defnConstraints :: [String]
57+ , defnMinGHC :: Version
58+ , defnMaxGHC :: Version
59+ }
60+
61+mkV :: String -> Maybe Version
62+mkV s = case filter (null . snd) $ readP_to_S parseVersion s of
63+ ((v, "") : _) -> Just v
64+ _ -> Nothing
65+
66+unsafeMkV :: String -> Version
67+unsafeMkV s = case mkV s of
68+ Nothing -> error $ "panic: Cannot parse version: " ++ s
69+ Just v -> v
70+
71+parseGHCVersion :: String -> Maybe Version
72+parseGHCVersion s
73+ | "ghc-" `isPrefixOf` s = mkV (drop 4 s)
74+ | otherwise = Nothing
75+
76+unsafeParseGHCVersion :: String -> Version
77+unsafeParseGHCVersion s = case parseGHCVersion s of
78+ Nothing -> error $ "panic: Cannot parse ghc version: " ++ s
79+ Just v -> v
80+
81+main :: IO ()
82+main = do
83+ args <- getArgs
84+ case args of
85+ ["list", ghc] -> traverse_ putStrLn
86+ [ i
87+ | Defn i _ mi ma <- defns
88+ , mi <= v, v < ma
89+ ]
90+ where
91+ v = unsafeParseGHCVersion ghc
92+
93+ ["constraints", i'] -> traverse_ putStrLn
94+ [ "--constraint " ++ x
95+ | Defn i xs _ _ <- defns
96+ , i' == i
97+ , x <- xs
98+ ]
99+
100+ _ -> error $ "unknown args: " ++ show args
101+
servant-swagger-ui.cabal+1−1
@@ -10,7 +10,7 @@ author: Oleg Grenrus <oleg.grenrus@iki.fi>
1010maintainer: Oleg Grenrus <oleg.grenrus@iki.fi>
1111license: BSD3
1212license-file: LICENSE
13−tested-with: GHC==7.8.4, GHC==7.10.3, GHC==8.0.2, GHC==8.2.1
13+tested-with: GHC==7.8.4, GHC==7.10.3, GHC==8.0.2, GHC==8.2.2
1414build-type: Simple
1515cabal-version: >= 1.10
1616