dist: xenial
language: cpp
sudo: false
python: 3.6.5
before_cache:
  - conda deactivate
  - conda remove --name p4env --all
cache:
  timeout: 1000
  directories:
    - $HOME/miniconda

env:
  global:
    - CTEST_OUTPUT_ON_FAILURE=1

matrix:
  #allow_failures:
  #  - compiler: clang
  #    env:
  #      - CXX_COMPILER='clang++-3.9'
  #      - PYTHON_VER='3.5'
  #      - C_COMPILER='clang-3.9'
  #      - Fortran_COMPILER='gfortran'
  #      - BUILD_TYPE='release'

  include:

  - os: linux
    compiler: clang
    addons: &1
      apt:
        packages:
        - liblapack-dev
        - clang-3.6
        - libhdf5-serial-dev
        - gfortran
    env:
      - CXX_COMPILER='clang++-3.6'
      - PYTHON_VER='3.6'
      - C_COMPILER='clang-3.6'
      - Fortran_COMPILER='gfortran'
      - BUILD_TYPE='release'

  #- os: linux
  #  compiler: clang
  #  addons: &2
  #    apt:
  #      sources:
  #      - llvm-toolchain-precise-3.9
  #      - ubuntu-toolchain-r-test
  #      packages:
  #      - liblapack-dev
  #      - clang-3.9
  #      - libhdf5-serial-dev
  #      - gfortran
  #  env:
  #    - CXX_COMPILER='clang++-3.9'
  #    - PYTHON_VER='3.5'
  #    - C_COMPILER='clang-3.9'
  #    - Fortran_COMPILER='gfortran'
  #    - BUILD_TYPE='release'

  - os: linux
    compiler: gcc
    addons: &3
      apt:
        packages:
        - python-numpy
        - liblapack-dev
        - libhdf5-serial-dev
        - gfortran
    env:
      - CXX_COMPILER='g++'
      - PYTHON_VER='3.7'
      - C_COMPILER='gcc'
      - Fortran_COMPILER='gfortran'
      - BUILD_TYPE='release'

#  - os: linux
#    compiler: gcc
#    addons: &4
#      apt:
#        sources:
#        - ubuntu-toolchain-r-test
#        packages:
#        - python-numpy
#        - libhdf5-serial-dev
#        - liblapack-dev
#        - g++-8
#        - gcc-8
#        - gfortran-8
#    env:
#      - CXX_COMPILER='g++-8'
#      - PYTHON_VER='3.6'
#      - C_COMPILER='gcc-8'
#      - Fortran_COMPILER='gfortran-8'
#      - BUILD_TYPE='release'

#  - os: linux
#    compiler: gcc
#    addons: &5
#      apt:
#        sources:
#        - ubuntu-toolchain-r-test
#        packages:
#        - python3
#        - cmake
#        - cmake-data
#        - libhdf5-serial-dev
#        - liblapack-dev
#        - g++-6
#        - gcc-6
#        - gfortran-6
#    env:
#      - CXX_COMPILER='g++-6'
#      - PYTHON_VER='3.5'
#      - C_COMPILER='gcc-6'
#      - Fortran_COMPILER='gfortran-6'
#      - BUILD_TYPE='release'

before_install:
  - uname -a
  - free -m
  - df -h
  - ulimit -a
  - mkdir -p $HOME/miniconda

install:
  - ./.scripts/miniconda.sh
  - export PATH="$HOME/miniconda/bin:$PATH"
  - conda create -q -n p4env python=$PYTHON_VER psi4 --only-deps -c psi4/label/dev
  - source activate p4env
  - conda install dftd3 gcp resp pylibefp pybind11 snsmp2 qcelemental=0.3.3 -c psi4/label/dev
  - conda list

before_script:
- python -V
- python -c 'import numpy; print(numpy.version.version)'
- cd ${TRAVIS_BUILD_DIR}
- export CXX=${CXX_COMPILER}
- export CC=${C_COMPILER}
- export FC=${Fortran_COMPILER}
- ${CXX_COMPILER} --version
- ${Fortran_COMPILER} --version
- ${C_COMPILER} --version
    # * can't use conda dist of the more complicated lib pkgs (e.g., CheMPS2, PCMSolver, v2rdm)
    #   b/c their c++ symbols don't mix with the different Travis compilers. for other
    #   reasons, pkgs are being compiled less statically, sad for CI.
    # * can't enable trivial plugins b/c no psi4 for them to detect at start (e.g., snsmp2)
- >
    cmake -Bbuild -H.
    -DCMAKE_CXX_COMPILER=${CXX_COMPILER}
    -DCMAKE_C_COMPILER=${C_COMPILER}
    -DCMAKE_BUILD_TYPE=${BUILD_TYPE}
    -DCMAKE_PREFIX_PATH=${HOME}/miniconda/envs/p4env
    -DPYTHON_EXECUTABLE="${HOME}/miniconda/envs/p4env/bin/python"
    -DENABLE_CheMPS2=OFF
    -DENABLE_dkh=ON
    -DENABLE_libefp=ON
    -DENABLE_erd=OFF
    -DENABLE_gdma=ON
    -DENABLE_PCMSolver=OFF
    -DENABLE_simint=ON
    -DENABLE_snsmp2=OFF
    -DENABLE_v2rdm_casscf=OFF
    -DENABLE_PLUGIN_TESTING=ON
    -DCMAKE_INSTALL_PREFIX=${TRAVIS_BUILD_DIR}/Install
- cd build
- ../.scripts/travis_build.sh
script:
- ./stage/bin/psi4 ../tests/tu1-h2o-energy/input.dat
- python ../.scripts/travis_run_test.py
- python ../.scripts/travis_print_failing.py
- PYTHONPATH=stage/lib/ pytest -v -rws --durations=15 -m 'quick' stage/lib/psi4/tests/

# safelist
branches:
  only:
  - master
  - 1.3.x
  - 1.2.x
  - 1.1.x
  - 1.0.x
