language: generic

sudo: false

cache:
    directories:
        - ${HOME}/miniconda3

env:
    global:
        - secure: "bF1Ljix0pDNBBjgewrOxxNHJDEvlWDT5v5KckSq/Wl0v9QMAG5Fiilj0hPHVQrWoGz7F3xPU5KeprjQcfTo2UB7qPGDOVsovafbUTZ+0o6kc2mVLApYsRvlhUPX8tsRCrq6Zo874buMzbDPyAo3nnl3lkkWQ2Dh+gA7b7er9xS0="

# Travis has limited OSX resources
# Only do OSX on Python 3.6
matrix:
    include:
      - os: linux
        env: CONDA_PY=36 BUILD_DOC=1
      - os: osx
        env: CONDA_PY=36
             MACOSX_DEPLOYMENT_TARGET=10.9

install:
    - |
      if [ ! -f ${HOME}/miniconda3/bin/conda ] ; then
          echo "Fresh miniconda install..."
          MINICONDA_URL="https://repo.continuum.io/miniconda"
          if [ `uname` == "Darwin" ]; then
              MINICONDA_FILE="Miniconda3-latest-MacOSX-x86_64.sh"
          else
              MINICONDA_FILE="Miniconda3-latest-Linux-x86_64.sh"
          fi
          wget ${MINICONDA_URL}/${MINICONDA_FILE}
          rm -rf ${HOME}/miniconda3
          bash ${MINICONDA_FILE} -b -p ${HOME}/miniconda3
      fi
      export PATH=${HOME}/miniconda3/bin:$PATH

      conda config --add channels conda-forge
      
      conda update --yes conda

      conda config --set show_channel_urls true
      conda install --yes --quiet conda-build

script:
    - |
      set -e
      conda build conda-recipe
      if [ "$BUILD_DOC" -eq "1" ]; then
        if [[ "${TRAVIS_BRANCH}" == "master" ]]; then
            pip install doctr
            doctr deploy . --deploy-repo pywr/pywr-docs --built-docs ${HOME}/pywr/docs/html
        fi
      fi

before_cache:
    - rm -rf ${HOME}/miniconda3/conda-bld/*
    - rm -rf ${HOME}/miniconda3/envs/*

notifications:
    email: false
