# Liang-Ting Chen 2019-09-07:
# Switched to Build Stages

# NB: don't set `language: haskell` here.
language: c

os: linux

# Request Ubuntu Bionic (18.04 LTS).  20.04 is not yet available
dist: bionic

##############################################################################
# Every master and maintenance branches >= 2.5 or >= maint-2.4 must
# be here. You can also add your private branches if you want travis to
# test them.

branches:
  only:
    - monoid
    - master
    - future
    - maint-2.4
    - stable-2.5
    - /^release-.*/
    # Test all issue* and future-.* branches. Saves you opening a PR.
    - /^issue.*/
    - /^future-.*/

##############################################################################
# The submodules are needed by tests using the standard library and the cubical
# library, but also needed for stack to find fix-whitespace. Even if it doesn't
# need it, stack expects it to be there.
#
git:
  submodules: true

##############################################################################
# Stages:
#

stages:
  - name: complete
    if: (branch =~ /^release-.*/) OR (tag IS present) OR (commit_message =~ complete\s+tests)

jobs:
  # Builds are loooong, we want to send an email as fast as possible.
  fast_finish: true

  include:
    - &complete-job
      stage: complete
      env: GHC_VER=9.0.1 CABAL_VER=3.4
      before_install:
        - sudo -E apt-add-repository -y "ppa:hvr/ghc" &&
          travis_apt_get_update &&
          sudo -E apt-get -yq --no-install-suggests --no-install-recommends install ghc-${GHC_VER} cabal-install-${CABAL_VER} &&
          sudo -E apt-get -yq --no-install-suggests --no-install-recommends install texlive-binaries

        - export PATH=/opt/ghc/$GHC_VER/bin:/opt/cabal/$CABAL_VER/bin:$PATH &&
          export PATH=$HOME/.local/bin:$PATH &&
          export BUILD_DIR=$HOME/dist &&
          export PARALLEL_TESTS=2 &&
          export PATH=$HOME/.cabal/bin:$PATH &&
          export PATH=$HOME/texlive/bin/x86_64-linux:$PATH
      install:
        - .travis/cabal_install
      ##############################################################################
      script:
        - make BUILD_DIR=$BUILD_DIR common
        - make AGDA_TESTS_OPTIONS="-j${PARALLEL_TESTS} --hide-successes" TASTY_ANSI_TRICKS=false BUILD_DIR=$BUILD_DIR succeed
        - make AGDA_TESTS_OPTIONS="-j${PARALLEL_TESTS} --hide-successes" TASTY_ANSI_TRICKS=false BUILD_DIR=$BUILD_DIR fail
        - make BUILD_DIR=$BUILD_DIR interaction
        - make BUILD_DIR=$BUILD_DIR interactive
        # We don't run LaTeX/XeLaTeX/LuaLaTeX on Travis (see Issues #1022 and
        # #1675), but we still compare the generated tex/html files with the
        # golden files.
        - make AGDA_TESTS_OPTIONS="-j${PARALLEL_TESTS} --hide-successes" TASTY_ANSI_TRICKS=false BUILD_DIR=$BUILD_DIR DONT_RUN_LATEX="Y" latex-html-test
        - make BUILD_DIR=$BUILD_DIR examples
        - make BUILD_DIR=$BUILD_DIR std-lib-test
        - make BUILD_DIR=$BUILD_DIR cubical-test
        - make BUILD_DIR=$BUILD_DIR api-test
        - make AGDA_TESTS_OPTIONS="-j${PARALLEL_TESTS} --hide-successes" TASTY_ANSI_TRICKS=false BUILD_DIR=$BUILD_DIR user-manual-test
        - make AGDA_TESTS_OPTIONS="-j${PARALLEL_TESTS} --hide-successes" TASTY_ANSI_TRICKS=false BUILD_DIR=$BUILD_DIR internal-tests
        - make BUILD_DIR=$BUILD_DIR benchmark-without-logs
        - make BUILD_DIR=$BUILD_DIR benchmark-summary

        ##################################################################################
        # Andreas, 2019-08-20: disable compiler test on ghc 8.0 since it takes too long,
        # making the whole travis run fail.
        # Ulf, 2019-08-29: only disable the std-lib compiler test
        # Liang-Ting, 2019-12-02: the maximum heap size has been increased, and std-lib compiler test is working again on GHC 8.0
        - make AGDA_TESTS_OPTIONS="-j${PARALLEL_TESTS} --hide-successes" TASTY_ANSI_TRICKS=false BUILD_DIR=$BUILD_DIR compiler-test
        - make AGDA_TESTS_OPTIONS="-j${PARALLEL_TESTS} --hide-successes" TASTY_ANSI_TRICKS=false BUILD_DIR=$BUILD_DIR std-lib-compiler-test
        - make AGDA_TESTS_OPTIONS="-j${PARALLEL_TESTS} --hide-successes" TASTY_ANSI_TRICKS=false BUILD_DIR=$BUILD_DIR std-lib-succeed
        - make BUILD_DIR=$BUILD_DIR std-lib-interaction
        - make BUILD_DIR=$BUILD_DIR TAGS
        - make BUILD_DIR="dist" test-size-solver
        - make BUILD_DIR=$BUILD_DIR testing-emacs-mode
        - make install-agda-bisect

    - <<: *complete-job
      env: GHC_VER=8.10.5 CABAL_VER=3.2
    - <<: *complete-job
      env: GHC_VER=8.8.4 CABAL_VER=3.2
    - <<: *complete-job
      env: GHC_VER=8.6.5 CABAL_VER=2.4
    - <<: *complete-job
      env: GHC_VER=8.4.4 CABAL_VER=2.2
    - <<: *complete-job
      env: GHC_VER=8.2.2 CABAL_VER=2.0
