dist: trusty
language: python

jobs:
  fast_finish: true
  include:
  - &latest_py2
    python: 2.7
  - <<: *latest_py2
    env: LANG=C
  - python: pypy
    env: DISABLE_COVERAGE=1  # Don't run coverage on pypy (too slow).
  - python: pypy3
    env: DISABLE_COVERAGE=1
  - python: 3.4
  - python: 3.5
  - &default_py
    python: 3.6
  - &latest_py3
    python: 3.7
    dist: xenial
  - <<: *latest_py3
    env: LANG=C
  - python: 3.8-dev
    dist: xenial
    env: DISABLE_COVERAGE=1  # Ignore invalid coverage data.
  - <<: *default_py
    stage: deploy (to PyPI for tagged commits)
    if: tag IS present
    install: skip
    script: skip
    after_success: true
    before_deploy:
      - python bootstrap.py
      - "! grep pyc setuptools.egg-info/SOURCES.txt"
    deploy:
      provider: pypi
      on:
        tags: true
        all_branches: true
      user: jaraco
      password:
        secure: tfWrsQMH2bHrWjqnP+08IX1WlkbW94Q30f4d7lCyhWS1FIf/jBDx4jrEILNfMxQ1NCwuBRje5sihj1Ow0BFf0vVrkaeff2IdvnNDEGFduMejaEQJL3s3QrLfpiAvUbtqwyWaHfAdGfk48PovDKTx0ZTvXZKYGXZhxGCYSlG2CE6Y6RDvnEl6Tk8e+LqUohkcSOwxrRwUoyxSnUaavdGohXxDT8MJlfWOXgr2u+KsRrriZqp3l6Fdsnk4IGvy6pXpy42L1HYQyyVu9XyJilR2JTbC6eCp5f8p26093m1Qas49+t6vYb0VLqQe12dO+Jm3v4uztSS5pPQzS7PFyjEYd2Rdb6ijsdbsy1074S4q7G9Sz+T3RsPUwYEJ07lzez8cxP64dtj5j94RL8m35A1Fb1OE8hHN+4c1yLG1gudfXbem+fUhi2eqhJrzQo5vsvDv1xS5x5GIS5ZHgKHCsWcW1Tv+dsFkrhaup3uU6VkOuc9UN+7VPsGEY7NvquGpTm8O1CnGJRzuJg6nbYRGj8ORwDpI0KmrExx6akV92P72fMC/I5TCgbSQSZn370H3Jj40gz1SM30WAli9M+wFHFd4ddMVY65yxj0NLmrP+m1tvnWdKtNh/RHuoW92d9/UFtiA5IhMf1/3djfsjBq6S9NT1uaLkVkTttqrPYJ7hOql8+g=
      distributions: release
      skip_cleanup: true
      skip_upload_docs: true

cache: pip

install:

# ensure we have recent pip/setuptools/wheel
- pip install --disable-pip-version-check --upgrade pip setuptools wheel
# need tox to get started
- pip install --upgrade tox tox-venv

# Output the env, to verify behavior
- pip freeze --all
- env

# update egg_info based on setup.py in checkout
- python bootstrap.py
- "! grep pyc setuptools.egg-info/SOURCES.txt"

script:
  - |
    ( # Run testsuite.
      if [ -z "$DISABLE_COVERAGE" ]
      then
        tox -- --cov
      else
        tox
      fi
    )

after_success:
  - |
    ( # Upload coverage data.
      if [ -z "$DISABLE_COVERAGE" ]
      then
        export TRAVIS_JOB_NAME="${TRAVIS_PYTHON_VERSION} (LANG=$LANG)" CODECOV_ENV=TRAVIS_JOB_NAME
        tox -e coverage,codecov
      fi
    )
