sudo: false
dist: trusty
language: python

cache:
  pip: true
  apt: true
  directories:
    - $HOME/tensorpack_data

addons:
  apt:
    packages:
    - pandoc
    - libprotobuf-dev
    - protobuf-compiler

matrix:
  fast_finish: true
  include:
  - os: linux
    python: 2.7
    env: TF_VERSION=1.3.0 TF_TYPE=release
  - os: linux
    python: 3.5
    env: TF_VERSION=1.3.0 TF_TYPE=release
  - os: linux
    python: 2.7
    env: TF_VERSION=1.6.0 TF_TYPE=release
  - os: linux
    python: 3.5
    env: TF_VERSION=1.6.0 TF_TYPE=release PYPI=true
  - os: linux
    python: 2.7
    env: TF_TYPE=nightly
  - os: linux
    python: 3.5
    env: TF_TYPE=nightly
  allow_failures:
  - env: TF_TYPE=nightly

install:
- pip install -U pip    # the pip version on travis is too old
- pip install flake8 scikit-image opencv-python pypandoc
  # here we use opencv-python, but users are in general not recommended to use this package,
  # because it brings issues working with tensorflow on gpu
- pip install .
  # check that dataflow can be imported alone
- python -c "import tensorpack.dataflow"
- ./tests/install-tensorflow.sh

before_script:
- flake8 --version
- protoc --version
- python -c "import cv2; print('OpenCV '+ cv2.__version__)"
- python -c "import tensorflow as tf; print('TensorFlow '+ tf.__version__)"

script:
- flake8 .
- if [[ $TRAVIS_PYTHON_VERSION == '3.5' ]]; then cd examples && flake8 .; fi  # some examples are py3 only
- mkdir -p $HOME/tensorpack_data
- export TENSORPACK_DATASET=$HOME/tensorpack_data
- $TRAVIS_BUILD_DIR/tests/run-tests.sh
- cd $TRAVIS_BUILD_DIR  # go back to root so that deploy may work

notifications:
  email:
    recipients:
      - ppwwyyxxc@gmail.com
    on_success: never
    on_failure: always
  webhooks:
    urls:
      - https://webhooks.gitter.im/e/cede9dbbf6630b3704b3
    on_success: change  # options: [always|never|change] default: always
    on_failure: always  # options: [always|never|change] default: always
    on_start: never     # options: [always|never|change] default: always


# see https://docs.travis-ci.com/user/deployment/pypi/
deploy:
- provider: pypi
  user: ppwwyyxx
  distributions: "sdist bdist_wheel"
  skip_upload_docs: true
  password:
    secure: lnNfzPFSk4HF7seuu63CoUa0g4V0JPs42H5FTzWecEIro8IqjdaAvzNKuhu9E4rkrMXPzoYYA6gC4YhseT7N/jg7lyV/Nn1koGXK1gmzu5JnXZXHw5/Ri0I3hOF3OFpEvkR39tzV0r5HsO0JIU3pl11+bBS8iloEtzdTPaUaRgyYxyZGrHl8l3VnUyM50PRnPGDouK6DHxJmknnFCOZFCrEpwN4zpOs55c1rChjJ8aql69rSsXQOUP8++jRtGwgqEvHh0K86uGm1AJUYvSWmcoD+5Urcg8LGaQzySmXtJnFgxtzsORactIEJoAteSMXufWZITn4OQ5VQkc4/CfU0HgHioQw86dpdJrfOLkhEx65JxfUsQiOTgpcTOgYYEda6+dY4cnTTpj2fASVDhQMQ/vo+Ab/W14nYG8z0IPwGJ1qDXRO6AtPD7vbah2LdHQTUTiAbbtva7NWuKbFiVxD2tdrVQHKWqmKXw+JF5F8TBDEnUxFtulW2hbM+vwu6mPxbYQZEpONjLKSa7qiZ8jQZ8cy9KatQYkqPLeGEbgI+IsmA4bnJJennToyWZ2N4W071ddtLB7hDH4ZRVdaLVYtfeKW/b/+YGX3N8p5cMKGIDjpGyF0BocFalQ7gYfg2ouAn1RyEPkCaw6ntA2uzIgvTqxU5inWJCFn20Ogst0oIaPs=
  on:
    tags: true
    branch: master
    repo: ppwwyyxx/tensorpack
    python: "3.5"
    condition: "$PYPI = true"

- provider: pypi
  server: https://testpypi.python.org/pypi
  user: ppwwyyxx
  distributions: "sdist bdist_wheel"
  skip_upload_docs: true
  password:
    secure: lnNfzPFSk4HF7seuu63CoUa0g4V0JPs42H5FTzWecEIro8IqjdaAvzNKuhu9E4rkrMXPzoYYA6gC4YhseT7N/jg7lyV/Nn1koGXK1gmzu5JnXZXHw5/Ri0I3hOF3OFpEvkR39tzV0r5HsO0JIU3pl11+bBS8iloEtzdTPaUaRgyYxyZGrHl8l3VnUyM50PRnPGDouK6DHxJmknnFCOZFCrEpwN4zpOs55c1rChjJ8aql69rSsXQOUP8++jRtGwgqEvHh0K86uGm1AJUYvSWmcoD+5Urcg8LGaQzySmXtJnFgxtzsORactIEJoAteSMXufWZITn4OQ5VQkc4/CfU0HgHioQw86dpdJrfOLkhEx65JxfUsQiOTgpcTOgYYEda6+dY4cnTTpj2fASVDhQMQ/vo+Ab/W14nYG8z0IPwGJ1qDXRO6AtPD7vbah2LdHQTUTiAbbtva7NWuKbFiVxD2tdrVQHKWqmKXw+JF5F8TBDEnUxFtulW2hbM+vwu6mPxbYQZEpONjLKSa7qiZ8jQZ8cy9KatQYkqPLeGEbgI+IsmA4bnJJennToyWZ2N4W071ddtLB7hDH4ZRVdaLVYtfeKW/b/+YGX3N8p5cMKGIDjpGyF0BocFalQ7gYfg2ouAn1RyEPkCaw6ntA2uzIgvTqxU5inWJCFn20Ogst0oIaPs=
  on:
    branch: test-travis
    repo: ppwwyyxx/tensorpack
    python: "3.5"
    condition: "$PYPI = true"
