sudo: false
language: python

addons:
  apt:
    sources:
      # Debian sid currently holds OpenSSL 1.0.2
      # change this with future releases!
      - debian-sid
    packages:
      - libssl-dev

env:
  global:
    - CI_DEPS=codecov>=2.0.5
    - CI_COMMANDS=codecov

matrix:
  fast_finish: true
  include:
    - python: 3.5
      env: TOXENV=lint
    - os: osx
      osx_image: xcode7.3
      language: generic
      env: TOXENV=py35 BDIST=1
    - python: 3.5
      env: TOXENV=py35 BDIST=1
    - python: 3.5
      env: TOXENV=py35 NO_ALPN=1
    - python: 2.7
      env: TOXENV=py27
    - python: 2.7
      env: TOXENV=py27 NO_ALPN=1
    - python: 3.5
      env: TOXENV=docs
  allow_failures:
    - python: pypy

install:
  - |
    if [[ $TRAVIS_OS_NAME == "osx" ]]
    then
      brew update || brew update # try again if it fails
      brew upgrade
      brew reinstall openssl
      brew reinstall pyenv
      eval "$(pyenv init -)"
      env PYTHON_CONFIGURE_OPTS="--enable-framework" pyenv install --skip-existing 3.5.2
      pyenv global 3.5.2
      pyenv shell 3.5.2
      pip install -U pip setuptools wheel virtualenv
    fi
  - pip install tox

script: tox -- --cov netlib --cov mitmproxy --cov pathod -v

after_success:
  - |
    if [[ $BDIST == "1" && $TRAVIS_PULL_REQUEST == "false" && ($TRAVIS_BRANCH == "master" || -n $TRAVIS_TAG) ]]
    then
        git fetch --unshallow
        ./dev.sh 3.5
        source venv3.5/bin/activate
        pip install -e ./release
        python -u ./release/rtool.py bdist
        python -u ./release/rtool.py upload-snapshot --bdist
    fi

notifications:
  slack:
      -rooms:
          mitmproxy:YaDGC9Gt9TEM7o8zkC2OLNsu
      on_success: change
      on_failure: change
      on_start: never

cache:
  directories:
    - $HOME/.pyenv
    - $HOME/.cache/pip
