# We set the language to c because python isn't supported on the MacOS X nodes
# on Travis. However, the language ends up being irrelevant anyway, since we
# install Python ourselves using conda.
language: c

os:
    - linux

# Setting sudo to false opts in to Travis-CI container-based builds.
sudo: false

# The apt packages below are needed for sphinx builds. A full list of packages
# that can be included can be found here:
#
# https://github.com/travis-ci/apt-package-whitelist/blob/master/ubuntu-precise

addons:
    apt:
        packages:
            - graphviz
            - texlive-latex-extra
            - dvipng

env:
    global:

        # The following versions are the 'default' for tests, unless
        # overridden underneath. They are defined here in order to save having
        # to repeat them for all configurations.
        - PYTHON_VERSION=3.6
        - NUMPY_VERSION=stable
        - ASTROPY_VERSION=stable
        - MAIN_CMD='python setup.py'
        - SETUP_CMD='test'
        - PIP_DEPENDENCIES='requests python-dateutil flask'
        - EVENT_TYPE='pull_request push'
        - CONDA_DEPENDENCIES=''
        - CONDA_CHANNELS='astropy-ci-extras astropy'

    matrix:
        # Make sure that egg_info works without dependencies
        - PYTHON_VERSION=2.7 SETUP_CMD='egg_info'
        - PYTHON_VERSION=3.3 SETUP_CMD='egg_info' NUMPY_VERSION=1.11
        - PYTHON_VERSION=3.4 SETUP_CMD='egg_info'
        - PYTHON_VERSION=3.5 SETUP_CMD='egg_info'
        - PYTHON_VERSION=3.6 SETUP_CMD='egg_info'

matrix:

    # Don't wait for allowed failures
    fast_finish: true

    include:
        # Try MacOS X
        - os: osx
          env: SETUP_CMD='test'

        # Do a coverage test.
        - os: linux
          env: SETUP_CMD='test --coverage'

        # Now try Astropy dev and LTS vesions with the latest 3.x and 2.7.
        - os: linux
          env: PYTHON_VERSION=2.7 ASTROPY_VERSION=development
               EVENT_TYPE='pull_request push cron'
        - os: linux
          env: ASTROPY_VERSION=development
               EVENT_TYPE='pull_request push cron'
        - os: linux
          env: PYTHON_VERSION=2.7 ASTROPY_VERSION=lts
        - os: linux
          env: ASTROPY_VERSION=lts

          # try all python versions
        - os: linux
          env: PYTHON_VERSION=2.7 NUMPY_VERSION=1.7
        - os: linux
          env: PYTHON_VERSION=3.3 NUMPY_VERSION=1.8
        - os: linux
          env: PYTHON_VERSION=3.4 NUMPY_VERSION=1.9
        - os: linux
          env: PYTHON_VERSION=3.5 NUMPY_VERSION=1.11

        # Do a PEP8 test with pycodestyle
        - os: linux
          env: MAIN_CMD='pycodestyle pyvo --count' SETUP_CMD=''

    allow_failures:
        # Do a PEP8 test with pycodestyle
        # (allow to fail unless your code completely compliant)
        - os: linux
          env: MAIN_CMD='pycodestyle pyvo --count' SETUP_CMD=''

        # Check for sphinx doc build warnings
        # (allow to fail because docs aren't in the right state yet')
        - os: linux
          env: SETUP_CMD='build_docs -w'

        # Unresolvable conda dependencies
        - os: linux
          env: PYTHON_VERSION=3.3 NUMPY_VERSION=1.11

install:
    - git clone git://github.com/astropy/ci-helpers.git
    - source ci-helpers/travis/setup_conda.sh

script:
   - $MAIN_CMD $SETUP_CMD

after_success:
    # If coveralls.io is set up for this package, uncomment the line
    # below and replace "packagename" with the name of your package.
    # The coveragerc file may be customized as needed for your package.
    - if [[ $SETUP_CMD == 'test --coverage' ]]; then coveralls --rcfile='pyvo/tests/coveragerc'; fi
