Test with ghc-head too
[packages/containers.git] / .travis.yml
1 # This Travis job script has been generated by a script via
2 #
3 #   haskell-ci '--config=cabal.haskell-ci' 'cabal.project'
4 #
5 # For more information, see https://github.com/haskell-CI/haskell-ci
6 #
7 # version: 0.3.20190413
8 #
9 language: c
10 dist: xenial
11 git:
12   # whether to recursively clone submodules
13   submodules: false
14 branches:
15   only:
16     - master
17 cache:
18   directories:
19     - $HOME/.cabal/packages
20     - $HOME/.cabal/store
21 before_cache:
22   - rm -fv $CABALHOME/packages/hackage.haskell.org/build-reports.log
23   # remove files that are regenerated by 'cabal update'
24   - rm -fv $CABALHOME/packages/hackage.haskell.org/00-index.*
25   - rm -fv $CABALHOME/packages/hackage.haskell.org/*.json
26   - rm -fv $CABALHOME/packages/hackage.haskell.org/01-index.cache
27   - rm -fv $CABALHOME/packages/hackage.haskell.org/01-index.tar
28   - rm -fv $CABALHOME/packages/hackage.haskell.org/01-index.tar.idx
29   - rm -rfv $CABALHOME/packages/head.hackage
30 matrix:
31   include:
32     - compiler: ghc-8.6.4
33       addons: {"apt":{"sources":["hvr-ghc"],"packages":["ghc-8.6.4","cabal-install-2.4"]}}
34     - compiler: ghc-8.4.4
35       addons: {"apt":{"sources":["hvr-ghc"],"packages":["ghc-8.4.4","cabal-install-2.4"]}}
36     - compiler: ghc-8.2.2
37       addons: {"apt":{"sources":["hvr-ghc"],"packages":["ghc-8.2.2","cabal-install-2.4"]}}
38     - compiler: ghc-8.0.2
39       addons: {"apt":{"sources":["hvr-ghc"],"packages":["ghc-8.0.2","cabal-install-2.4"]}}
40     - compiler: ghc-7.10.3
41       addons: {"apt":{"sources":["hvr-ghc"],"packages":["ghc-7.10.3","cabal-install-2.4"]}}
42     - compiler: ghc-7.8.4
43       addons: {"apt":{"sources":["hvr-ghc"],"packages":["ghc-7.8.4","cabal-install-2.4"]}}
44     - compiler: ghc-7.6.3
45       addons: {"apt":{"sources":["hvr-ghc"],"packages":["ghc-7.6.3","cabal-install-2.4"]}}
46     - compiler: ghc-head
47       addons: {"apt":{"sources":["hvr-ghc"],"packages":["ghc-head","cabal-install-head"]}}
48       env: GHCHEAD=true
49   allow_failures:
50     - compiler: ghc-head
51 before_install:
52   - HC=$(echo "/opt/$CC/bin/ghc" | sed 's/-/\//')
53   - HCPKG="$HC-pkg"
54   - unset CC
55   - CABAL=/opt/ghc/bin/cabal
56   - CABALHOME=$HOME/.cabal
57   - export PATH="$CABALHOME/bin:$PATH"
58   - TOP=$(pwd)
59   - HCNUMVER=$(( $(${HC} --numeric-version|sed -E 's/([0-9]+)\.([0-9]+)\.([0-9]+).*/\1 * 10000 + \2 * 100 + \3/') ))
60   - echo $HCNUMVER
61   - CABAL="$CABAL -vnormal+nowrap+markoutput"
62   - set -o pipefail
63   - |
64     echo 'function blue(s) { printf "\033[0;34m" s "\033[0m " }'           >> .colorful.awk
65     echo 'BEGIN { state = "output"; }'                                     >> .colorful.awk
66     echo '/^-----BEGIN CABAL OUTPUT-----$/ { state = "cabal" }'            >> .colorful.awk
67     echo '/^-----END CABAL OUTPUT-----$/ { state = "output" }'             >> .colorful.awk
68     echo '!/^(-----BEGIN CABAL OUTPUT-----|-----END CABAL OUTPUT-----)/ {' >> .colorful.awk
69     echo '  if (state == "cabal") {'                                       >> .colorful.awk
70     echo '    print blue($0)'                                              >> .colorful.awk
71     echo '  } else {'                                                      >> .colorful.awk
72     echo '    print $0'                                                    >> .colorful.awk
73     echo '  }'                                                             >> .colorful.awk
74     echo '}'                                                               >> .colorful.awk
75   - cat .colorful.awk
76   - |
77     color_cabal_output () {
78       awk -f $TOP/.colorful.awk
79     }
80   - echo text | color_cabal_output
81 install:
82   - ${CABAL} --version
83   - echo "$(${HC} --version) [$(${HC} --print-project-git-commit-id 2> /dev/null || echo '?')]"
84   - TEST=--enable-tests
85   - BENCH=--enable-benchmarks
86   - if [ $HCNUMVER -lt 70804 ] ; then BENCH=--disable-benchmarks ; fi
87   - GHCHEAD=${GHCHEAD-false}
88   - rm -f $CABALHOME/config
89   - |
90     echo "verbose: normal +nowrap +markoutput"          >> $CABALHOME/config
91     echo "remote-build-reporting: anonymous"            >> $CABALHOME/config
92     echo "remote-repo-cache: $CABALHOME/packages"       >> $CABALHOME/config
93     echo "logs-dir:          $CABALHOME/logs"           >> $CABALHOME/config
94     echo "world-file:        $CABALHOME/world"          >> $CABALHOME/config
95     echo "extra-prog-path:   $CABALHOME/bin"            >> $CABALHOME/config
96     echo "symlink-bindir:    $CABALHOME/bin"            >> $CABALHOME/config
97     echo "build-summary:     $CABALHOME/logs/build.log" >> $CABALHOME/config
98     echo "store-dir:         $CABALHOME/store"          >> $CABALHOME/config
99     echo "install-dirs user"                            >> $CABALHOME/config
100     echo "  prefix: $CABALHOME"                         >> $CABALHOME/config
101     echo "repository hackage.haskell.org"               >> $CABALHOME/config
102     echo "  url: http://hackage.haskell.org/"           >> $CABALHOME/config
103   - |
104     if $GHCHEAD; then
105     echo "allow-newer: $($HCPKG list --simple-output | sed -E 's/([a-zA-Z-]+)-[0-9.]+/*:\1/g')" >> $CABALHOME/config
106     
107     echo "repository head.hackage"                                                        >> $CABALHOME/config
108     echo "   url: http://head.hackage.haskell.org/"                                       >> $CABALHOME/config
109     echo "   secure: True"                                                                >> $CABALHOME/config
110     echo "   root-keys: 07c59cb65787dedfaef5bd5f987ceb5f7e5ebf88b904bbd4c5cbdeb2ff71b740" >> $CABALHOME/config
111     echo "              2e8555dde16ebd8df076f1a8ef13b8f14c66bad8eafefd7d9e37d0ed711821fb" >> $CABALHOME/config
112     echo "              8f79fd2389ab2967354407ec852cbe73f2e8635793ac446d09461ffb99527f6e" >> $CABALHOME/config
113     echo "   key-threshold: 3"                                                            >> $CABALHOME/config
114     fi
115   - cat $CABALHOME/config
116   - rm -fv cabal.project cabal.project.local cabal.project.freeze
117   - travis_retry ${CABAL} v2-update -v
118   # Generate cabal.project
119   - rm -rf cabal.project cabal.project.local cabal.project.freeze
120   - touch cabal.project
121   - |
122     echo 'packages: "containers"' >> cabal.project
123     echo 'packages: "containers-tests"' >> cabal.project
124   - |
125     echo "write-ghc-environment-files: always" >> cabal.project
126   - "for pkg in $($HCPKG list --simple-output); do echo $pkg | sed 's/-[^-]*$//' | grep -vE -- '^(binary|containers|containers-tests)$' | sed 's/^/constraints: /' | sed 's/$/ installed/' >> cabal.project.local; done"
127   - cat cabal.project || true
128   - cat cabal.project.local || true
129   - if [ -f "containers/configure.ac" ]; then (cd "containers" && autoreconf -i); fi
130   - if [ -f "containers-tests/configure.ac" ]; then (cd "containers-tests" && autoreconf -i); fi
131   - ${CABAL} v2-freeze -w ${HC} ${TEST} ${BENCH} | color_cabal_output
132   - "cat cabal.project.freeze | sed -E 's/^(constraints: *| *)//' | sed 's/any.//'"
133   - rm  cabal.project.freeze
134 script:
135   - DISTDIR=$(mktemp -d /tmp/dist-test.XXXX)
136   # Packaging...
137   - ${CABAL} v2-sdist all | color_cabal_output
138   # Unpacking...
139   - mv dist-newstyle/sdist/*.tar.gz ${DISTDIR}/
140   - cd ${DISTDIR} || false
141   - find . -maxdepth 1 -name '*.tar.gz' -exec tar -xvf '{}' \;
142   # Generate cabal.project
143   - rm -rf cabal.project cabal.project.local cabal.project.freeze
144   - touch cabal.project
145   - |
146     echo 'packages: "containers-*/*.cabal"' >> cabal.project
147     echo 'packages: "containers-tests-*/*.cabal"' >> cabal.project
148   - |
149     echo "write-ghc-environment-files: always" >> cabal.project
150   - "for pkg in $($HCPKG list --simple-output); do echo $pkg | sed 's/-[^-]*$//' | grep -vE -- '^(binary|containers|containers-tests)$' | sed 's/^/constraints: /' | sed 's/$/ installed/' >> cabal.project.local; done"
151   - cat cabal.project || true
152   - cat cabal.project.local || true
153   # Building...
154   # this builds all libraries and executables (without tests/benchmarks)
155   - ${CABAL} v2-build -w ${HC} --disable-tests --disable-benchmarks all | color_cabal_output
156   # Building with tests and benchmarks...
157   # build & run tests, build benchmarks
158   - ${CABAL} v2-build -w ${HC} ${TEST} ${BENCH} all | color_cabal_output
159   # Testing...
160   - ${CABAL} v2-test -w ${HC} ${TEST} ${BENCH} all | color_cabal_output
161   # cabal check...
162   - (cd containers-* && ${CABAL} -vnormal check)
163   - (cd containers-tests-* && ${CABAL} -vnormal check)
164   # haddock...
165   - ${CABAL} v2-haddock -w ${HC} ${TEST} ${BENCH} all | color_cabal_output
166   # Building without installed constraints for packages in global-db...
167   - rm -f cabal.project.local
168   - ${CABAL} v2-build -w ${HC} --disable-tests --disable-benchmarks all | color_cabal_output
169
170 # REGENDATA ["--config=cabal.haskell-ci","cabal.project"]
171 # EOF