language: haskell
before_install:
  # Uncomment whenever hackage is down.
  # - mkdir -p ~/.cabal && cp travis/config ~/.cabal/config && cabal update
  - cabal update

  # Try installing some of the build-deps with apt-get for speed.
  - travis/cabal-apt-install $mode

install:
  - cabal configure -flib-Werror $mode
  - cabal build

script:
  - $script
  - scripts/stats

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

env:
  - mode="--enable-tests" script="cabal test --show-details=always"
  # - mode="--enable-tests -fsafe" script="cabal test"
  # - mode="--enable-tests -fdump-splices" script="cabal test --show-details=always"
  # - mode="--enable-benchmarks -fdump-splices" script="cabal bench"

language: haskell

env:
  - GHCVER=7.4.2
  - GHCVER=7.6.3
  # - >
  #   GHCVER=7.4.2
  #   MODE="-fsafe"

before_install:
  # If $GHCVER is the one travis has, don't bother reinstalling it.
  # We can also have faster builds by installing some libraries with
  # `apt`. If it isn't, install the GHC we want from hvr's PPA along
  # with cabal-1.18.
  - |
    if [ $GHCVER = `ghc --numeric-version` ]; then
      # Try installing some of the build-deps with apt-get for speed.
      travis/cabal-apt-install --enable-tests $MODE
      export CABAL=cabal
    else
      # Install the GHC we want from hvr's PPA
      sudo add-apt-repository -y ppa:hvr/ghc
      sudo apt-get update
      sudo apt-get install cabal-install-1.18 ghc-$GHCVER
      export CABAL=cabal-1.18
      export PATH=/opt/ghc/$GHCVER/bin:$PATH
    fi
  # Uncomment whenever hackage is down.
  # - mkdir -p ~/.cabal && cp travis/config ~/.cabal/config && $CABAL update
  - $CABAL update

install:
  - $CABAL install --dependencies-only --enable-tests
  - $CABAL configure -flib-Werror --enable-tests $MODE

script:
  - $CABAL build
  - $CABAL test --show-details=always
  - scripts/stats

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

Build on Travis with hvr's GHC versions PPA.
Build on Travis with hvr's GHC versions PPA.

Preserve other environment variables for travis.

I didn't really think about what would happen with $mode and $script.
>.>

Install dependencies for travis in the `install` step.

Rewrite the .travis.yml almost completely.

This .travis.yml allows us to specify versions more nicely and also fall
back to travis' GHC if it's the same version as the one we want.

I'd be OK with adding benchmarking options back, but $script seems like
a weird way to do it.

Install test dependencies for travis with cabal-apt-install.

This should make things a little quicker.
