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