env:
 # Note: We have to use Cabal 2.4 with GHC 7.0 since for some reason
 # builds of "text" fail with GHC 7.0 and Cabal versions prior to 2.4
 # https://github.com/haskell/bytestring/issues/213
 # With Cabal 2.4 we also get improved syntax in cabal.project files,
 # supporting remote sources, and other goodies, so use it across the
 # board.
 # For GHC >= 7.10 we use Cabal 3.2 which supports the --benchmark-options
 # flag.
 #
 - GHCVER=7.0.4 CABALVER=2.4
 - GHCVER=7.2.2 CABALVER=2.4
 - GHCVER=7.4.2 CABALVER=2.4
 - GHCVER=7.6.3 CABALVER=2.4
 - GHCVER=7.8.4 CABALVER=2.4
 - GHCVER=7.10.3 CABALVER=3.2
 - GHCVER=8.0.2 CABALVER=3.2
 - GHCVER=8.2.2 CABALVER=3.2
 - GHCVER=8.4.4 CABALVER=3.2
 - GHCVER=8.6.5 CABALVER=3.2
 - GHCVER=8.8.3 CABALVER=3.2
 - GHCVER=8.10.1 CABALVER=3.2

 ### The head in "ppa", currently 8.7, is no longer worth testing.
 # - GHCVER=head  CABALVER=2.4

matrix:
  allow_failures:
   - env: GHCVER=head  CABALVER=2.4

before_install:
 - travis_retry sudo add-apt-repository -y ppa:hvr/ghc
 - travis_retry sudo apt-get update
 - travis_retry sudo apt-get install cabal-install-$CABALVER ghc-$GHCVER
 - export PATH=/opt/ghc/$GHCVER/bin:/opt/cabal/$CABALVER/bin:$PATH
 - cabal --version
 - "GHCNUMVER=$(ghc --numeric-version|perl -ne '/^(\\d+)\\.(\\d+)\\.(\\d+)(\\.(\\d+))?$/; print(10000 * $1 + 100 * $2 + ($3 == 0 ? $5 != 1 : $3))')"
 - echo $GHCNUMVER

install:
 - travis_retry cabal update

script:
 - cabal v2-configure
 - cabal v2-build
 - cabal v2-haddock -O0
 - cabal v2-sdist -o .
 # Remove to enable build of sdist.
 - rm -f cabal.project
 - (cd tests; cabal v2-configure; cabal v2-test)
 # Build the benchmarks and run a single iteration.
 - if [ "$GHCNUMVER" -ge 71000 ]; then
      (cd bench; cabal v2-bench -O0 --benchmark-options "--quick --min-duration=0 --include-first-iter");
   fi
 # "cabal check" disabled due to -O2 warning
 - export SRC=$(cabal info . | awk '{print $2; exit}');
   if [ -f "$SRC.tar.gz" ]; then
      cabal get "./$SRC.tar.gz";
      (cd "$SRC"; cabal v2-build);
   else
      echo "expected '$SRC.tar.gz' not found";
      exit 1;
   fi
