language: cpp
sudo: false
dist: xenial
os:
  - linux
  - osx
addons:
  apt:
    packages:
      - python3-pip
      - python3-dev
      - python3-numpy
      - python3-setuptools
      - scons
      - gfortran
      - libsundials-serial-dev
      - liblapack-dev
      - libblas-dev
      - libboost-dev
      - doxygen
      - graphviz
  ssh_known_hosts:
    - cantera.org

env:
  global:
    secure: "IqQ4IVKzZbMCIVrD6t3YQDi3mEiswhTWo3AAKg2CrA+CETads/I9d0g68krKCA2xue0zm9pFVWbs5MT2F6Yq2PNsdvoN3ZMHrpXTN2ZJ7pgukgVwNuBe7B/tm6xBzSbZ4KPIanWCu3TNXsZp9EPG1rdhagAZZ+TeDYdIUKAITjYOVIiiAsqiLllsE9cAq3jkiu/JAxB0tzicxERi1RtnMfL/1d9fupP+yrExwIYo+hhAwWwghdiKzh551sowpbVFVxuOtTJfpC+vh1a/kLo/VTr4DDe6Bdkubc7beU8WZiZNVVbNoydy/qYkKuOzmXu9Llo9flMzJKswR7Szxi8nhD2zc+3pOYxJilWPYtrG4WrJr3WFTU3xZg5KsLwNpCane1uAsrj/NNtMagp+Wj1yOBMDMmHF5GAyCVEgSqY2PLISaEPOPCJV4VihaHyie1hM/A5YlD2VwkkKJTjMIP2VpaLVo9Sr3jXUIhtp/wLNleSWENX7etFjVqhwX1ldhz6+gVrn/H6oS2LwHQwlAseE9O6eqAB5ia+9duYDt7JS5F1P8QMYhz1gaJGXKWBnCEur5XHoGhZ75nyNnpmLjDOHKk5NmQQNL6ltUqg3fX7EWOjzxHlymdZ/4lg5AESj/+nBAhJJcAYRn9hHti7JLMjF6Qk/Kf3pJ6qVBHETY2KivH8="


before_script: |
  echo TRAVIS_OS_NAME: $TRAVIS_OS_NAME
  if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then
      export CONDA_ARCH="${TRAVIS_OS_NAME}_${BUILD_ARCH}"
      curl https://repo.continuum.io/miniconda/Miniconda3-latest-MacOSX-x86_64.sh -o miniconda.sh;
      bash miniconda.sh -b -p $HOME/miniconda
      source $HOME/miniconda/etc/profile.d/conda.sh && conda activate
      conda config --set always_yes yes --set changeps1 no
      conda install -q numpy cython scons boost ruamel_yaml
      conda install -q -c conda-forge openmp
  else
      pip3 install --user --upgrade pip
      pip3 install --user --upgrade setuptools wheel
      pip3 install --user cython
      pip3 install --user ruamel.yaml==0.15.94  # Need a version compatible with Python 3.4

      # Install packages for the documentation
      pip3 install --user sphinx sphinxcontrib-matlabdomain sphinxcontrib-doxylink
      pip3 install --user https://github.com/hagenw/sphinxcontrib-katex/archive/master.tar.gz
  fi
  rm -f cantera.conf
script: |
  set -e
  if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then
      scons build -j2 python_cmd=/usr/bin/python3 VERBOSE=y python_package=full blas_lapack_libs=lapack,blas optimize=n coverage=y
      scons test
      scons samples
      scons build sphinx_docs=y doxygen_docs=y sphinx_cmd="/usr/bin/python3 `which sphinx-build`"
      if [[ "${TRAVIS_PULL_REQUEST}" == "false" ]] && [[ "${TRAVIS_BRANCH}" == "master" ]] && [[ "${TRAVIS_REPO_SLUG}" == "Cantera/cantera" ]]; then
        cd build
        find docs -type f | grep -v /xml/ | grep -v .map$ | grep -v .md5$ | tar cjvf docs/dev-docs.tar.bz2 --files-from - >/dev/null
        cd -
        openssl aes-256-cbc -k "${ctdeploy_pass}" -in ./doc/ctdeploy_key.enc -out ./doc/ctdeploy_key -d
        chmod 0600 ./doc/ctdeploy_key
        RSYNC_OPTIONS=(
          -avzP
          --checksum
          --rsh='ssh -i ./doc/ctdeploy_key'
          --exclude='*.map'
          --exclude='*.md5'
          --exclude='/doxygen/xml'
          --delete
          --delete-excluded
        )
        RSYNC_USER="ctdeploy"
        RSYNC_SERVER="cantera.org"
        RSYNC_DEST="cantera/documentation/dev"
        DOCS_OUTPUT_DIR="./build/docs/"
        rsync "${RSYNC_OPTIONS[@]}" "${DOCS_OUTPUT_DIR}" ${RSYNC_USER}@${RSYNC_SERVER}:${RSYNC_DEST}
      else
        echo "Skipping documentation upload from source other than Cantera/cantera:master"
      fi
  else
      scons build -j2 python_cmd=python3 VERBOSE=y python_package=full blas_lapack_libs=lapack,blas optimize=n coverage=y extra_inc_dirs=$CONDA_PREFIX/include extra_lib_dirs=$CONDA_PREFIX/lib
      scons test
      scons samples
  fi
after_success: |
  if [[ "$TRAVIS_OS_NAME" == "linux" ]]; then
      bash <(curl -s https://codecov.io/bash)
  fi
