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