language: python

# Tell travis we want Ubuntu 14.04
sudo: required
dist: trusty

notifications:
  email: false

# with building pushes enabled on travis we would get
# two builds for every new commit pushed to a branch
# for a PR. So we disable build-on-push for all branches
# except the ones whitelisted here.
branches:
  only:
    - master

matrix:
  fast_finish: true
  include:
    - os: linux
      python: "2.7"
      # Tell travis we want debian trusty
      sudo: required
      dist: trusty
      env:
        - TESTATTR="'not huge and not known_failing'"
      addons:
        apt:
          packages:
            - astyle
            - cppcheck
            - enchant

    - os: linux
      python: "3.5"
      # Tell travis we want debian trusty
      sudo: required
      dist: trusty
      env:
        - TESTATTR="'not huge and not known_failing'"
      addons:
        apt:
          packages:
            - astyle
            - cppcheck
            - enchant

    - os: osx
      language: generic
      osx_image: xcode7.3
      env:
        - TESTATTR="'not linux and not known_failing and not huge'"
      before_install:
        - source ci_scripts/install.sh

# command to install common dependencies
install:
  - python --version
  - which python
  - gcc --version
  - which gcc
  - make install-dependencies

# command to run tests
script:
  - make test
  - make pep8
  - make doc
  - make py-demos
  - make cpp-demos
  - cd examples/stamps && ./do.sh

# generate all the diagnostic reports
after_success:
  - cd $TRAVIS_BUILD_DIR && echo $TRAVIS_BUILD_DIR
  - make clean
  - PYTEST_ADDOPTS=-qqq make coverage-gcovr.xml coverage.xml
  # Fix suggested by http://diff-cover.readthedocs.io/en/latest/#troubleshooting
  - git fetch origin master:refs/remotes/origin/master
  - PYTEST_ADDOPTS=-qqq make diff-cover
  - make format
  - make diff_pylint_report
  - make cppcheck
  - make pydocstyle
  # XXX Do not upload results from travis yet. Currently jenkins is considered
  # XXX the source of truth about coverage
  # only upload one coverage report to codecov as it merges all reports
  # from all builds into one.
  - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then pip install codecov; fi
  - if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then codecov -X pycov search gcov -f coverage.xml coverage-gcovr.xml; fi
