language: cpp
sudo: false

branches:
  only:
    - master

matrix:
  include:
    - os: linux
      addons:
        apt:
          sources:
            - ubuntu-toolchain-r-test
          packages:
            - g++-7
      env:
        - MATRIX_EVAL="CXX=g++-7 && CC=gcc-7"
    - os: osx
      osx_image: xcode9.4
      env:
        - MATRIX_EVAL="CXX=clang++ && CC=clang"

before_install:
  - echo "$TRAVIS_PULL_REQUEST"
  - eval "${MATRIX_EVAL}"
  - |
    if [ "$TRAVIS_OS_NAME" == "linux" ]; then
      pip install --user cpp-coveralls;
    fi

install:
  # Install a supported cmake version (>= 3.10)
  - |
    if [ "$TRAVIS_OS_NAME" == "linux" ]; then
      wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh;
    else
      curl -o miniconda.sh  https://repo.anaconda.com/miniconda/Miniconda3-latest-MacOSX-x86_64.sh;
    fi
  - bash miniconda.sh -b -p $HOME/miniconda
  - export PATH="$HOME/miniconda/bin:$PATH"
  - conda config --set always_yes yes
  - conda env create -n ale python=3.7.3
  - conda env update -f environment.yml -n ale
  - source activate ale
  - conda install pytest

script:
  - PYTHONPATH=. pytest tests/pytests -vv
  - python setup.py install # install to use python lib in c code
  - mkdir -p build
  - cd build
  - cmake -DCOVERAGE=ON ..
  - cmake --build .
  - ctest -VV

after_success:
  - |
    if [ "$TRAVIS_OS_NAME" == linux ]; then
      coveralls --root $(dirname $PWD) -i src/ --verbose;
    fi
