# This Travis job script has been generated by a script via
#
#   make_travis_yml_2.hs 'lens.cabal'
#
# For more information, see https://github.com/hvr/multi-ghc-travis
#
language: c
sudo: false

git:
  submodules: false  # whether to recursively clone submodules

cache:
  directories:
    - $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

addons:
  apt:
    packages: &apt_packages
      - ghc-ppa-tools
      - alex-3.1.7
      - happy-1.19.5

matrix:
  include:
    - compiler: "ghc-8.2.1"
    # env: TEST=--disable-tests BENCH=--disable-benchmarks
      addons: {apt: {packages: [*apt_packages,cabal-install-2.0,ghc-8.2.1], sources: [hvr-ghc]}}
    - compiler: "ghc-8.0.2"
    # env: TEST=--disable-tests BENCH=--disable-benchmarks
      addons: {apt: {packages: [*apt_packages,cabal-install-2.0,ghc-8.0.2], sources: [hvr-ghc]}}
    - compiler: "ghc-7.10.3"
    # env: TEST=--disable-tests BENCH=--disable-benchmarks
      addons: {apt: {packages: [*apt_packages,cabal-install-2.0,ghc-7.10.3], sources: [hvr-ghc]}}
    - compiler: "ghc-7.8.4"
    # env: TEST=--disable-tests BENCH=--disable-benchmarks
      addons: {apt: {packages: [*apt_packages,cabal-install-2.0,ghc-7.8.4], sources: [hvr-ghc]}}
    - compiler: "ghc-7.6.3"
    # env: TEST=--disable-tests BENCH=--disable-benchmarks
      addons: {apt: {packages: [*apt_packages,cabal-install-2.0,ghc-7.6.3], sources: [hvr-ghc]}}
    - compiler: "ghc-7.4.2"
    # env: TEST=--disable-tests BENCH=--disable-benchmarks
      addons: {apt: {packages: [*apt_packages,cabal-install-2.0,ghc-7.4.2], sources: [hvr-ghc]}}

before_install:
 - HC=${CC}
 - unset CC
 - export HAPPYVER=1.19.5
 - export ALEXVER=3.1.7
 - export HLINTVER=2.0.9
 - mkdir ~/.hlint
 - curl -L https://github.com/ndmitchell/hlint/releases/download/v$HLINTVER/hlint-$HLINTVER-x86_64-linux.tar.gz | tar -xz --strip-components=1 -C ~/.hlint
 - PATH=/opt/ghc/bin:/opt/ghc-ppa-tools/bin:~/.hlint:~/.cabal/bin:/opt/ghc/$GHCVER/bin:/opt/cabal/$CABALVER/bin:/opt/happy/$HAPPYVER/bin:/opt/alex/$ALEXVER/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}
 - travis_retry cabal update -v
 - sed -i 's/^jobs:/-- jobs:/' ${HOME}/.cabal/config
 - rm -fv cabal.project.local
 - rm -f cabal.project.freeze
 - cabal new-build -w ${HC} ${TEST} ${BENCH} --dep -j

# 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:
 - if [ -f configure.ac ]; then autoreconf -i; fi
 - rm -rf .ghc.environment.* dist/
 # build tests and benchmarks, run tests
 - cabal new-build -w ${HC} ${TEST} ${BENCH}
 - if [ "x$TEST" = "x--enable-tests" ]; then cabal new-test -w ${HC} ${TEST} ${BENCH}; fi
 - hlint src --cpp-define=HLINT --cpp-ansi

notifications:
  irc:
    channels:
      - "irc.freenode.org#haskell-lens"
    skip_join: true
    template:
      - "\x0313lens\x0f/\x0306%{branch}\x0f \x0314%{commit}\x0f %{message} \x0302\x1f%{build_url}\x0f"
# EOF
