sudo: false
language: cpp

git:
  depth: 10000

env:
  global:
    MAKEFLAGS='-j 4'

addons:
  apt:
    packages:
      - libgmp-dev
      - zlib1g-dev

install:
  - ./scripts/travis-install.sh

script:
  - ./scripts/travis-script.sh

after_success:
  - ./scripts/travis-after_success.sh

after_script:
  - sleep 2  # avoids the bug of travis-ci/travis-ci#6018

# NOTE:
# - The following combinations give many false positives on the valgrind check:
#   - openmpi-bin + valgrind on precise,
#   - mpich-3.2 + valgrind-3.12.0 on xcode7.3.
#   The ATP whitelist request for mpich seems to be continuously ignored,
#   travis-ci/apt-package-whitelist#406, so on linux we need to build/brew it.
#   Here our strategy for the valgrind check of parform is to use
#   mpich + valgrind-3.11.0 on osx.
# - openmpi + gcov on precise occasionally crashes. We measure the code
#   coverage of parform with mpich on osx.
# - It is best to cache ./texlive for doc-*-release:
#     cache: { directories: [ texlive ] }
matrix:
  include:
    - os: linux
      compiler: gcc
      env: CI_TARGET=form
    - os: linux
      compiler: gcc
      env: CI_TARGET=tform
    - os: linux
      compiler: gcc
      env: CI_TARGET=parform
      addons: { apt: { packages: [ libgmp-dev, libopenmpi-dev, openmpi-bin, zlib1g-dev ] } }
    - os: osx
      compiler: clang
      env: CI_TARGET=form
    - os: osx
      compiler: clang
      env: CI_TARGET=tform
    - os: osx
      compiler: clang
      env: CI_TARGET=parform
    - os: linux
      compiler: gcc
      env: CI_TARGET=coverage-vorm
    - os: linux
      compiler: gcc
      env: CI_TARGET=coverage-tvorm
    - os: osx
      compiler: gcc
      env: CI_TARGET=coverage-parvorm
    - os: linux
      compiler: gcc
      env: CI_TARGET=valgrind-vorm TEST=examples.frm
      addons: { apt: { packages: [ libgmp-dev, valgrind, zlib1g-dev ] } }
    - os: linux
      compiler: gcc
      env: CI_TARGET=valgrind-vorm TEST=features.frm
      addons: { apt: { packages: [ libgmp-dev, valgrind, zlib1g-dev ] } }
    - os: linux
      compiler: gcc
      env: CI_TARGET=valgrind-vorm TEST=fixes.frm
      addons: { apt: { packages: [ libgmp-dev, valgrind, zlib1g-dev ] } }
    - os: linux
      compiler: gcc
      env: CI_TARGET=valgrind-tvorm TEST=examples.frm
      addons: { apt: { packages: [ libgmp-dev, valgrind, zlib1g-dev ] } }
    - os: linux
      compiler: gcc
      env: CI_TARGET=valgrind-tvorm TEST=features.frm
      addons: { apt: { packages: [ libgmp-dev, valgrind, zlib1g-dev ] } }
    - os: linux
      compiler: gcc
      env: CI_TARGET=valgrind-tvorm TEST=fixes.frm
      addons: { apt: { packages: [ libgmp-dev, valgrind, zlib1g-dev ] } }
    - os: osx
      compiler: gcc
      env: CI_TARGET=valgrind-parvorm TEST=examples.frm
    - os: osx
      compiler: gcc
      env: CI_TARGET=valgrind-parvorm TEST=features.frm
    - os: osx
      compiler: gcc
      env: CI_TARGET=valgrind-parvorm TEST=fixes.frm
    - os: linux
      env: CI_TARGET=src-release
    - os: linux
      env: CI_TARGET=doc-pdf-release
      addons: { apt: { packages: [] } }
      cache: { directories: [ texlive ] }
    - os: linux
      env: CI_TARGET=doc-html-release
      addons: { apt: { packages: [] } }
      cache: { directories: [ texlive ] }
    - os: linux
      compiler: gcc
      env: CI_TARGET=bin-release
    - os: osx
      compiler: clang
      env: CI_TARGET=bin-release

# NOTE: $GITHUB_TOKEN is given as an encrypted environment variable.
deploy:
  provider: releases
  api_key: "$GITHUB_TOKEN"
  file_glob: true
  file:
    - "form-*.tar.gz"
    - "form-*.pdf"
  skip_cleanup: true
  overwrite: true
  on:
    tags: true
    condition: "( $TRAVIS_SECURE_ENV_VARS == true ) && ( $CI_TARGET == *release )"

notifications:
  email: false
