# NB: don't set `language: haskell` here
# See https://github.com/hvr/multi-ghc-travis for more information

env:
 - CABALVER=1.18 GHCVER=7.4.2
 - CABALVER=1.18 GHCVER=7.6.3
 - CABALVER=1.18 GHCVER=7.8.3
 - CABALVER=1.22 GHCVER=7.10.1

before_install:
 - sudo add-apt-repository -y ppa:hvr/ghc
 - sudo apt-get update
 - sudo apt-get install cabal-install-$CABALVER ghc-$GHCVER
 - export PATH=/opt/ghc/$GHCVER/bin:/opt/cabal/$CABALVER/bin:$PATH

install:
 - cabal update
 - cabal sandbox init
# can't use "cabal install --only-dependencies --enable-tests --enable-benchmarks" due to dep-cycle
 - cabal install criterion deepseq mtl "QuickCheck >= 2.8" HUnit "test-framework-quickcheck2 >= 0.3" "random >= 1.0.1.0" attoparsec cereal -j

script:
 - cabal configure --enable-tests --enable-benchmarks -v2 --ghc-options=-fno-spec-constr
 - cabal build
 - cabal test
# "cabal check" disabled due to -O2 warning
# - cabal check
 - cabal sdist
# check that the generated source-distribution can be built & installed
 - export SRC_TGZ=$(cabal info . | awk '{print $2 ".tar.gz";exit}') ;
   cd dist/;
   cabal sandbox init;
   if [ -f "$SRC_TGZ" ]; then
      cabal install --force-reinstalls "$SRC_TGZ";
   else
      echo "expected '$SRC_TGZ' not found";
      exit 1;
   fi

notifications:
  email:
    - kolmodin@gmail.com
