From b120c17137f5dc0750400852c2bf078ac2a417bd Mon Sep 17 00:00:00 2001 From: Oleg Grenrus Date: Sun, 22 Oct 2017 12:59:10 +0300 Subject: [PATCH] cabal new-build based .travis.yml --- .gitignore | 1 + .travis.yml | 134 +++++++++++++++++++++----- cabal.project | 3 +- doc/tutorial/tutorial.cabal | 5 + servant-client/servant-client.cabal | 6 +- servant-docs/servant-docs.cabal | 6 +- servant-foreign/servant-foreign.cabal | 6 ++ servant-server/servant-server.cabal | 6 +- servant/servant.cabal | 6 +- 9 files changed, 141 insertions(+), 32 deletions(-) diff --git a/.gitignore b/.gitignore index a66f2a0e..46e31b90 100644 --- a/.gitignore +++ b/.gitignore @@ -1,4 +1,5 @@ **/*/dist +.ghc.environment.* dist-newstyle /bin /lib diff --git a/.travis.yml b/.travis.yml index 32c4b6ce..c5b49419 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,31 +1,113 @@ -sudo: false -dist: trusty - +# This Travis job script has been generated by a script via +# +# make_travis_yml_2.hs '-o' '.travis.yml' 'cabal.project' +# +# For more information, see https://github.com/hvr/multi-ghc-travis +# language: c +sudo: false -env: - - STACK_YAML=stack-ghc-7.8.4.yaml - - STACK_YAML=stack-ghc-7.10.3.yaml - - STACK_YAML=stack.yaml - - STACK_YAML=stack-ghc-8.2.1.yaml - -addons: - apt: - packages: - - libgmp-dev - -install: - - mkdir -p ~/.local/bin - - export PATH=$HOME/.local/bin:$PATH - - travis_retry curl -L https://www.stackage.org/stack/linux-x86_64 | tar xz --wildcards --strip-components=1 -C ~/.local/bin '*/stack' - - stack --version - - stack setup --no-terminal - - (cd $HOME/.local/bin && wget https://zalora-public.s3.amazonaws.com/tinc && chmod +x tinc) - -script: - - if [ "$TRAVIS_EVENT_TYPE" = "cron" ] ; then ./scripts/ci-cron.sh ; else stack test --ghc-options=-Werror --no-terminal ; fi +git: + submodules: false # whether to recursively clone submodules cache: directories: - - $HOME/.tinc/cache - - $HOME/.stack + - $HOME/.cabal/packages + - $HOME/.cabal/store + +before_cache: + - rm -fv $HOME/.cabal/packages/hackage.haskell.org/build-reports.log + # remove files that are regenerated by 'cabal update' + - rm -fv $HOME/.cabal/packages/hackage.haskell.org/00-index.* + - rm -fv $HOME/.cabal/packages/hackage.haskell.org/*.json + - rm -fv $HOME/.cabal/packages/hackage.haskell.org/01-index.cache + - rm -fv $HOME/.cabal/packages/hackage.haskell.org/01-index.tar + - rm -fv $HOME/.cabal/packages/hackage.haskell.org/01-index.tar.idx + +matrix: + include: + - compiler: "ghc-7.8.4" + # env: TEST=--disable-tests BENCH=--disable-benchmarks + addons: {apt: {packages: [ghc-ppa-tools,cabal-install-head,ghc-7.8.4], sources: [hvr-ghc]}} + - compiler: "ghc-7.10.3" + # env: TEST=--disable-tests BENCH=--disable-benchmarks + addons: {apt: {packages: [ghc-ppa-tools,cabal-install-head,ghc-7.10.3], sources: [hvr-ghc]}} + - compiler: "ghc-8.0.2" + # env: TEST=--disable-tests BENCH=--disable-benchmarks + addons: {apt: {packages: [ghc-ppa-tools,cabal-install-head,ghc-8.0.2], sources: [hvr-ghc]}} + - compiler: "ghc-8.2.1" + # env: TEST=--disable-tests BENCH=--disable-benchmarks + addons: {apt: {packages: [ghc-ppa-tools,cabal-install-head,ghc-8.2.1], sources: [hvr-ghc]}} + +before_install: + - HC=${CC} + - HCPKG=${HC/ghc/ghc-pkg} + - unset CC + - PATH=/opt/ghc/bin:/opt/ghc-ppa-tools/bin:$PATH + +install: + - cabal --version + - echo "$(${HC} --version) [$(${HC} --print-project-git-commit-id 2> /dev/null || echo '?')]" + - BENCH=${BENCH---enable-benchmarks} + - TEST=${TEST---enable-tests} + - HADDOCK=${HADDOCK-true} + - INSTALLED=${INSTALLED-true} + - travis_retry cabal update -v + - sed -i.bak 's/^jobs:/-- jobs:/' ${HOME}/.cabal/config + - rm -fv cabal.project.local + - if [ -f "servant/configure.ac" ]; then + (cd "servant"; autoreconf -i); + fi + - if [ -f "servant-client/configure.ac" ]; then + (cd "servant-client"; autoreconf -i); + fi + - if [ -f "servant-docs/configure.ac" ]; then + (cd "servant-docs"; autoreconf -i); + fi + - if [ -f "servant-foreign/configure.ac" ]; then + (cd "servant-foreign"; autoreconf -i); + fi + - if [ -f "servant-server/configure.ac" ]; then + (cd "servant-server"; autoreconf -i); + fi + - if [ -f "doc/tutorial/configure.ac" ]; then + (cd "doc/tutorial"; autoreconf -i); + fi + - rm -f cabal.project.freeze + - cabal new-build -w ${HC} ${TEST} ${BENCH} --project-file="cabal.project" --dep -j2 all + - cabal new-build -w ${HC} --disable-tests --disable-benchmarks --project-file="cabal.project" --dep -j2 all + - rm -rf "servant"/.ghc.environment.* "servant-client"/.ghc.environment.* "servant-docs"/.ghc.environment.* "servant-foreign"/.ghc.environment.* "servant-server"/.ghc.environment.* "doc/tutorial"/.ghc.environment.* "servant"/dist "servant-client"/dist "servant-docs"/dist "servant-foreign"/dist "servant-server"/dist "doc/tutorial"/dist + - DISTDIR=$(mktemp -d /tmp/dist-test.XXXX) + +# Here starts the actual work to be performed for the package under test; +# any command which exits with a non-zero exit code causes the build to fail. +script: + # test that source-distributions can be generated + - (cd "servant"; cabal sdist) + - (cd "servant-client"; cabal sdist) + - (cd "servant-docs"; cabal sdist) + - (cd "servant-foreign"; cabal sdist) + - (cd "servant-server"; cabal sdist) + - (cd "doc/tutorial"; cabal sdist) + - mv "servant"/dist/servant-*.tar.gz "servant-client"/dist/servant-client-*.tar.gz "servant-docs"/dist/servant-docs-*.tar.gz "servant-foreign"/dist/servant-foreign-*.tar.gz "servant-server"/dist/servant-server-*.tar.gz "doc/tutorial"/dist/tutorial-*.tar.gz ${DISTDIR}/ + - cd ${DISTDIR} + - find . -maxdepth 1 -name '*.tar.gz' -exec tar -xvf '{}' \; + - "printf 'packages: servant-*/*.cabal servant-client-*/*.cabal servant-docs-*/*.cabal servant-foreign-*/*.cabal servant-server-*/*.cabal tutorial-*/*.cabal\n' > cabal.project" + # this builds all libraries and executables (without tests/benchmarks) + - cabal new-build -w ${HC} --disable-tests --disable-benchmarks all + + # Build with installed constraints for packages in global-db + - 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 + + # build & run tests, build benchmarks + - cabal new-build -w ${HC} ${TEST} ${BENCH} all + - if [ "x$TEST" = "x--enable-tests" ]; then cabal new-test -w ${HC} ${TEST} all; fi + + # haddock + - rm -rf ./dist-newstyle + - if $HADDOCK; then cabal new-haddock -w ${HC} --disable-tests --disable-benchmarks all; else echo "Skipping haddock generation";fi + +# REGENDATA ["-o",".travis.yml","cabal.project"] +# EOF diff --git a/cabal.project b/cabal.project index c6e53e56..8f4135d9 100644 --- a/cabal.project +++ b/cabal.project @@ -1,5 +1,4 @@ -packages: - servant/ +packages: servant/ servant-client/ servant-docs/ servant-foreign/ diff --git a/doc/tutorial/tutorial.cabal b/doc/tutorial/tutorial.cabal index 69d0b0bf..d0bbbd9d 100644 --- a/doc/tutorial/tutorial.cabal +++ b/doc/tutorial/tutorial.cabal @@ -8,6 +8,11 @@ author: Servant Contributors maintainer: haskell-servant-maintainers@googlegroups.com build-type: Simple cabal-version: >=1.10 +tested-with: + GHC==7.8.4 + GHC==7.10.3 + GHC==8.0.2 + GHC==8.2.1 library exposed-modules: ApiType diff --git a/servant-client/servant-client.cabal b/servant-client/servant-client.cabal index 09bb6736..839513cb 100644 --- a/servant-client/servant-client.cabal +++ b/servant-client/servant-client.cabal @@ -17,7 +17,11 @@ copyright: 2014-2016 Zalora South East Asia Pte Ltd, Servant Contribut category: Servant Web build-type: Simple cabal-version: >=1.10 -tested-with: GHC >= 7.8 +tested-with: + GHC==7.8.4 + GHC==7.10.3 + GHC==8.0.2 + GHC==8.2.1 homepage: http://haskell-servant.readthedocs.org/ Bug-reports: http://github.com/haskell-servant/servant/issues extra-source-files: diff --git a/servant-docs/servant-docs.cabal b/servant-docs/servant-docs.cabal index 2f1fa7bc..17cbd006 100644 --- a/servant-docs/servant-docs.cabal +++ b/servant-docs/servant-docs.cabal @@ -15,7 +15,11 @@ copyright: 2014-2016 Zalora South East Asia Pte Ltd, Servant Contribut category: Servant Web build-type: Simple cabal-version: >=1.10 -tested-with: GHC >= 7.8 +tested-with: + GHC==7.8.4 + GHC==7.10.3 + GHC==8.0.2 + GHC==8.2.1 homepage: http://haskell-servant.readthedocs.org/ Bug-reports: http://github.com/haskell-servant/servant/issues extra-source-files: diff --git a/servant-foreign/servant-foreign.cabal b/servant-foreign/servant-foreign.cabal index 17f2e1a7..df60c755 100644 --- a/servant-foreign/servant-foreign.cabal +++ b/servant-foreign/servant-foreign.cabal @@ -22,6 +22,12 @@ extra-source-files: CHANGELOG.md README.md bug-reports: http://github.com/haskell-servant/servant/issues +tested-with: + GHC==7.8.4 + GHC==7.10.3 + GHC==8.0.2 + GHC==8.2.1 + source-repository head type: git location: http://github.com/haskell-servant/servant.git diff --git a/servant-server/servant-server.cabal b/servant-server/servant-server.cabal index e66ded54..0459b9d4 100644 --- a/servant-server/servant-server.cabal +++ b/servant-server/servant-server.cabal @@ -22,7 +22,11 @@ copyright: 2014-2016 Zalora South East Asia Pte Ltd, Servant Contribut category: Servant Web build-type: Custom cabal-version: >=1.10 -tested-with: GHC >= 7.8 +tested-with: + GHC==7.8.4 + GHC==7.10.3 + GHC==8.0.2 + GHC==8.2.1 extra-source-files: include/*.h CHANGELOG.md diff --git a/servant/servant.cabal b/servant/servant.cabal index ec599701..74de1d4d 100644 --- a/servant/servant.cabal +++ b/servant/servant.cabal @@ -18,7 +18,11 @@ copyright: 2014-2016 Zalora South East Asia Pte Ltd, Servant Contribut category: Servant Web build-type: Custom cabal-version: >=1.10 -tested-with: GHC >= 7.8 +tested-with: + GHC==7.8.4 + GHC==7.10.3 + GHC==8.0.2 + GHC==8.2.1 extra-source-files: include/*.h CHANGELOG.md