Factor out haskell-ci configuration
[packages/mtl.git] / .travis.yml
1 # This Travis job script has been generated by a script via
2 #
3 #   runghc make_travis_yml_2.hs '-o' '.travis.yml' '--ghc-head' '--irc-channel=irc.freenode.org#haskell-lens' '--no-no-tests-no-bench' '--no-unconstrained' '--env=7.6.3:HADDOCK=false' '--env=7.8.4:NOINSTALLEDCONSTRAINTS=true' 'cabal.project'
4 #
5 # For more information, see https://github.com/haskell-CI/haskell-ci
6 #
7 language: c
8 sudo: false
9
10 git:
11   submodules: false  # whether to recursively clone submodules
12
13 notifications:
14   irc:
15     channels:
16       - "irc.freenode.org#haskell-lens"
17     skip_join: true
18     template:
19       - "\x0313mtl\x03/\x0306%{branch}\x03 \x0314%{commit}\x03 %{build_url} %{message}"
20
21 cache:
22   directories:
23     - $HOME/.cabal/packages
24     - $HOME/.cabal/store
25
26 before_cache:
27   - rm -fv $HOME/.cabal/packages/hackage.haskell.org/build-reports.log
28   # remove files that are regenerated by 'cabal update'
29   - rm -fv $HOME/.cabal/packages/hackage.haskell.org/00-index.*
30   - rm -fv $HOME/.cabal/packages/hackage.haskell.org/*.json
31   - rm -fv $HOME/.cabal/packages/hackage.haskell.org/01-index.cache
32   - rm -fv $HOME/.cabal/packages/hackage.haskell.org/01-index.tar
33   - rm -fv $HOME/.cabal/packages/hackage.haskell.org/01-index.tar.idx
34
35   - rm -rfv $HOME/.cabal/packages/head.hackage
36
37 matrix:
38   include:
39     - compiler: "ghc-8.6.3"
40     # env: TEST=--disable-tests BENCH=--disable-benchmarks
41       addons: {apt: {packages: [ghc-ppa-tools,cabal-install-2.4,ghc-8.6.3], sources: [hvr-ghc]}}
42     - compiler: "ghc-8.4.4"
43     # env: TEST=--disable-tests BENCH=--disable-benchmarks
44       addons: {apt: {packages: [ghc-ppa-tools,cabal-install-2.4,ghc-8.4.4], sources: [hvr-ghc]}}
45     - compiler: "ghc-8.2.2"
46     # env: TEST=--disable-tests BENCH=--disable-benchmarks
47       addons: {apt: {packages: [ghc-ppa-tools,cabal-install-2.4,ghc-8.2.2], sources: [hvr-ghc]}}
48     - compiler: "ghc-8.0.2"
49     # env: TEST=--disable-tests BENCH=--disable-benchmarks
50       addons: {apt: {packages: [ghc-ppa-tools,cabal-install-2.4,ghc-8.0.2], sources: [hvr-ghc]}}
51     - compiler: "ghc-7.10.3"
52     # env: TEST=--disable-tests BENCH=--disable-benchmarks
53       addons: {apt: {packages: [ghc-ppa-tools,cabal-install-2.4,ghc-7.10.3], sources: [hvr-ghc]}}
54     - compiler: "ghc-7.8.4"
55       env: NOINSTALLEDCONSTRAINTS=true
56       addons: {apt: {packages: [ghc-ppa-tools,cabal-install-2.4,ghc-7.8.4], sources: [hvr-ghc]}}
57     - compiler: "ghc-7.6.3"
58       env: HADDOCK=false
59       addons: {apt: {packages: [ghc-ppa-tools,cabal-install-2.4,ghc-7.6.3], sources: [hvr-ghc]}}
60     - compiler: "ghc-7.4.2"
61     # env: TEST=--disable-tests BENCH=--disable-benchmarks
62       addons: {apt: {packages: [ghc-ppa-tools,cabal-install-2.4,ghc-7.4.2], sources: [hvr-ghc]}}
63     - compiler: "ghc-7.2.2"
64     # env: TEST=--disable-tests BENCH=--disable-benchmarks
65       addons: {apt: {packages: [ghc-ppa-tools,cabal-install-2.4,ghc-7.2.2], sources: [hvr-ghc]}}
66     - compiler: "ghc-7.0.4"
67     # env: TEST=--disable-tests BENCH=--disable-benchmarks
68       addons: {apt: {packages: [ghc-ppa-tools,cabal-install-2.4,ghc-7.0.4], sources: [hvr-ghc]}}
69     - compiler: "ghc-head"
70       env: GHCHEAD=true
71       addons: {apt: {packages: [ghc-ppa-tools,cabal-install-head,ghc-head], sources: [hvr-ghc]}}
72
73   allow_failures:
74     - compiler: "ghc-head"
75
76 before_install:
77   - HC=${CC}
78   - HCPKG=${HC/ghc/ghc-pkg}
79   - unset CC
80   - ROOTDIR=$(pwd)
81   - mkdir -p $HOME/.local/bin
82   - "PATH=/opt/ghc/bin:/opt/ghc-ppa-tools/bin:$HOME/local/bin:$PATH"
83   - HCNUMVER=$(( $(${HC} --numeric-version|sed -E 's/([0-9]+)\.([0-9]+)\.([0-9]+).*/\1 * 10000 + \2 * 100 + \3/') ))
84   - echo $HCNUMVER
85
86 install:
87   - cabal --version
88   - echo "$(${HC} --version) [$(${HC} --print-project-git-commit-id 2> /dev/null || echo '?')]"
89   - BENCH=${BENCH---enable-benchmarks}
90   - TEST=${TEST---enable-tests}
91   - HADDOCK=${HADDOCK-true}
92   - UNCONSTRAINED=${UNCONSTRAINED-true}
93   - NOINSTALLEDCONSTRAINTS=${NOINSTALLEDCONSTRAINTS-false}
94   - GHCHEAD=${GHCHEAD-false}
95   - travis_retry cabal update -v
96   - "sed -i.bak 's/^jobs:/-- jobs:/' ${HOME}/.cabal/config"
97   - rm -fv cabal.project cabal.project.local
98   # Overlay Hackage Package Index for GHC HEAD: https://github.com/hvr/head.hackage
99   - |
100     if $GHCHEAD; then
101       sed -i 's/-- allow-newer: .*/allow-newer: *:base/' ${HOME}/.cabal/config
102       for pkg in $($HCPKG list --simple-output); do pkg=$(echo $pkg | sed 's/-[^-]*$//'); sed -i "s/allow-newer: /allow-newer: *:$pkg, /" ${HOME}/.cabal/config; done
103
104       echo 'repository head.hackage'                                                        >> ${HOME}/.cabal/config
105       echo '   url: http://head.hackage.haskell.org/'                                       >> ${HOME}/.cabal/config
106       echo '   secure: True'                                                                >> ${HOME}/.cabal/config
107       echo '   root-keys: 07c59cb65787dedfaef5bd5f987ceb5f7e5ebf88b904bbd4c5cbdeb2ff71b740' >> ${HOME}/.cabal/config
108       echo '              2e8555dde16ebd8df076f1a8ef13b8f14c66bad8eafefd7d9e37d0ed711821fb' >> ${HOME}/.cabal/config
109       echo '              8f79fd2389ab2967354407ec852cbe73f2e8635793ac446d09461ffb99527f6e' >> ${HOME}/.cabal/config
110       echo '   key-threshold: 3'                                                            >> ${HOME}/.cabal.config
111
112       grep -Ev -- '^\s*--' ${HOME}/.cabal/config | grep -Ev '^\s*$'
113
114       cabal new-update head.hackage -v
115     fi
116   - grep -Ev -- '^\s*--' ${HOME}/.cabal/config | grep -Ev '^\s*$'
117   - "printf 'packages: \".\"\\n' > cabal.project"
118   - "printf 'write-ghc-environment-files: always\\n' >> cabal.project"
119   - touch cabal.project.local
120   - "if ! $NOINSTALLEDCONSTRAINTS; then for pkg in $($HCPKG list --simple-output); do echo $pkg  | grep -vw -- mtl | sed 's/^/constraints: /' | sed 's/-[^-]*$/ installed/' >> cabal.project.local; done; fi"
121   - cat cabal.project || true
122   - cat cabal.project.local || true
123   - if [ -f "./configure.ac" ]; then
124       (cd "." && autoreconf -i);
125     fi
126   - rm -f cabal.project.freeze
127   - cabal new-build -w ${HC} ${TEST} ${BENCH} --project-file="cabal.project" --dep -j2 all
128   - rm -rf .ghc.environment.* "."/dist
129   - DISTDIR=$(mktemp -d /tmp/dist-test.XXXX)
130
131 # Here starts the actual work to be performed for the package under test;
132 # any command which exits with a non-zero exit code causes the build to fail.
133 script:
134   # test that source-distributions can be generated
135   - cabal new-sdist all
136   - mv dist-newstyle/sdist/*.tar.gz ${DISTDIR}/
137   - cd ${DISTDIR} || false
138   - find . -maxdepth 1 -name '*.tar.gz' -exec tar -xvf '{}' \;
139   - "printf 'packages: mtl-*/*.cabal\\n' > cabal.project"
140   - "printf 'write-ghc-environment-files: always\\n' >> cabal.project"
141   - touch cabal.project.local
142   - "if ! $NOINSTALLEDCONSTRAINTS; then for pkg in $($HCPKG list --simple-output); do echo $pkg  | grep -vw -- mtl | sed 's/^/constraints: /' | sed 's/-[^-]*$/ installed/' >> cabal.project.local; done; fi"
143   - cat cabal.project || true
144   - cat cabal.project.local || true
145
146   # build & run tests, build benchmarks
147   - cabal new-build -w ${HC} ${TEST} ${BENCH} all
148
149   # cabal check
150   - (cd mtl-* && cabal check)
151
152   # haddock
153   - if $HADDOCK; then cabal new-haddock -w ${HC} ${TEST} ${BENCH} all; else echo "Skipping haddock generation";fi
154
155 # REGENDATA ["--output=.travis.yml","--config=cabal.haskell-ci","cabal.project"]
156 # EOF