# https://docs.travis-ci.com/user/languages/python/
language: python

# https://docs.travis-ci.com/user/caching/#pip-cache
cache:
  directories:
    - $HOME/.cache/pip/wheels

addons:
  apt:
    update: false

branches:
  only:
    - master
    - TensorLayer-2.x
    - /^\d+\.\d+(\.\d+)?(\S*)?$/

python:
  - "3.6"
  - "3.5"
#  - "2.7"  # TensorLayer 2.0 does not support python2 now

env:

  # Backward Compatibility in insured for release less than 1 year old.
  # https://pypi.org/project/tensorflow/#history
  matrix:
    - _TF_VERSION=2.0.0-rc1
#     - _TF_VERSION=1.12.0 # Remove on Oct 22, 2019
#     - _TF_VERSION=1.11.0 # Remove on Sep 28, 2019
#     - _TF_VERSION=1.10.1 # Remove on Aug 24, 2019
#     - _TF_VERSION=1.9.0  # Remove on Jul 10, 2019
#     - _TF_VERSION=1.8.0  # Remove on Apr 28, 2019
#     - _TF_VERSION=1.7.1  # Remove on May 08, 2019
#     - _TF_VERSION=1.7.0  # Remove on Mar 29, 2019
#     - _TF_VERSION=1.6.0  # Remove on Mar 01, 2019

  global:

  - PYPI_USER='jonathandekhtiar'

  # See https://docs.travis-ci.com/user/encryption-keys/ for more details about secure keys.

  ### == PYPI_PASSWORD === ###
  ## To update: travis encrypt PYPI_PASSWORD=################################
  - secure: "fGIRDjfzzP9DhdDshgh/+bWTZ5Y0jTD4aR+gsT1TyAyc6N4f3RRlx70xZZwYMdQ+XC3no/q4na8UzhhuSM0hCCM1EaQ78WF1c6+FBScf4vYGoYgyJ1am+4gu54JXt+4f0bd+s6jyYBafJALUJp5fqHoxCUXqzjrOqGBBU2+JbL71Aaj8yhQuK0VPPABexsQPQM312Gvzg7hy9dh63J0Q02PqINn+CTcwq3gLH9Oua58zWQ7TaT0cdy/hzAc6Yxy3ajo2W5NU+nKROaaG9W57sa7K/v1dshDFFFST2DdGxm9i7vvfPsq0OWM6qWLsec/4mXJWsmai2ygZEv+IhaABb10c7spd2nl7oHFj2UGmldtO5W0zLb1KkCPWDPilFt3lvHM+OS/YaibquL5/5+yGj0LsRJrVyWoMBA8idcQeH4dvTAfySeFpO42VNwW5ez9JaEOh7bBp7naAA8c/fbNJJ5YEW4MEmOZ9dwFTohNNDiN+oITSrcXBS+jukbfTOmtCeYNUker+4G2YwII9cxHXbZeIMrTq9AqTfOVTAYCFaFHKbpSc1+HCyF7n5ZfNC00kBaw93XUnLRzSNKe5Ir791momYL8HecMN3OAI77bz26/pHSfzJnLntq9qx2nLBTnqDuSq5/pHvdZ8hyt+hTDxvF7HJIVMhbnkjoLPxmn4k/I="

  ### === GITHUB_PERSONAL_TOKEN === ###
  ## To update: travis encrypt GITHUB_PERSONAL_TOKEN=################################
  - secure: "kMxg4WfTwhnYMD7WjYk71vgw7XlShPpANauKzfTL6oawDrpQRkBUai4uQwiL3kXVBuVv9rKKKZxxnyAm05iB5wGasPDhlFA1DPF0IbyU3pwQKlw2Xo5qtHdgxBnbms6JJ9z5b+hHCVg+LXYYeUw5qG01Osg5Ue6j1g2juQQHCod00FNuo3fe8ah/Y10Rem6CigH8ofosCrTvN2w1GaetJwVehRYf8JkPC6vQ+Yk8IIjHn2CaVJALbhuchVblxwH0NXXRen915BVBwWRQtsrvEVMXKu7A8sMHmvPz1u3rhXQfjpF2KeVOfy1ZnyiHcLE2HgAPuAGh4kxZAAA8ovmcaCbv8m64bm72BrQApSbt6OEtR9L1UeUwdEgi54FH1XFOHQ9dA6CpiGCyk3wAJZqO0/PkNYVLfb4gPLvnvBRwYBaPgUPvVNhidFu/oODENZmcf8g9ChtuC1GT70EYlVwhgDGqUY7/USZCEvIPe81UToqtIKgcgA+Is51XindumJVMiqTsjgdqeC/wZcw+y37TAjIvvXbtYxeqIKv9zh1JuZppqUhnf+OhI+HHFaY4iu7lQTs3C0WmoLskZAp9srwRtifnVFFkdYzngmPaSjWyko2qiS0cTdFJQB/ljqmnJdksacbv5OOa0Q4qZef/hW774nVx105FlkAIk70D2b5l2pA="

  ### === GITHUB_PERSONAL_TOKEN === ###
  ## To update: travis encrypt HYPERDASH_APIKEY=################################
  - secure: "ez9Ck1VpqWOd2PPu+CMWzd8R4aAIXbjKCk96PCKwWu8VXoHjaPkiy8Nn0LUzSlUg3nKdZmu2JSndwDMy3+lMLG7zE2WlGNY7MF5KM3GrvFpP3cxJQ6OuPcZcEH4j5KtBtNTrNqa8SWglqhc9mr66a92SD8Ydc4aMj6L9nbQvrsvVzIMmMy6weVlpBF35nweYCM8LxlsnqyPLleHPZo3o/k+hsTqQQbiMGjC78tqrGr56u7AjL2+D/m33+dfCGzFvMJFcpLQ5ldbcVU54i5e6V3xJ48P30QOGZaqG3fcpfZsyJEIWjykt6XFA8GfJjaVVbxdlr7zP7Vd9iWBuemnMEX3F9Cy/4x7LmX9PJfsVPC6FQnanDvsZSNO5hpmKe8BTpttJJvxgscOczV4jnI69OzqhSQeyChwtkqhIg1E/53XIO+uLJAAZsCkAco7tjGGXTKyv8ZlpSJwSqsLcmgpmQbfodCoMLcYenTxqKZv78e2B4tOPGQyS2bkSxAqhvAIam7RCq/yEvz5n2/mBFEGwP6OQFIdC7ypO2LyrOlLT7HJjCeYMeKSm+GOD3LW9oIy9QJZpG6N/zAAjnk9C2mYtWRQIBo4qdHjRvyDReevDexI8j0AXySblxREmQ7ZaT6KEDXXZSu5goTlaGm0g2HwAkKu9xYFV/bRtp6+i1mP7CQg="

matrix:
  include:
    - python: '3.6'
      env:
        - _DOC_AND_YAPF_TEST=True

install:
  - |
    if [[ -v _DOC_AND_YAPF_TEST ]]; then
        pip install tensorflow==2.0.0-rc1
        pip install yapf
        pip install -e .[doc]
    else
        pip install tensorflow==$_TF_VERSION
        pip install -e .[all_cpu_dev]
    fi

script:
  # units test
  # https://docs.pytest.org/en/latest/
  - rm setup.cfg
  - |
    if [[ -v _DOC_AND_YAPF_TEST ]]; then
        mv setup.travis_doc.cfg setup.cfg
    else
        mv setup.travis.cfg setup.cfg
    fi
  - pytest


before_deploy:
  - python setup.py sdist
  - python setup.py bdist_wheel
  - python setup.py bdist_wheel --universal
  - python setup.py egg_info


deploy:

# Documentation: https://docs.travis-ci.com/user/deployment/pypi/
- provider: pypi
  user: '$PYPI_USER'
  password: '$PYPI_PASSWORD'
  skip_cleanup: true
  on:
    tags: true
    python: '3.6'
    condition: '$_TF_VERSION = 2.0.0-rc1'
#     condition: '$_TF_VERSION = 1.11.0'

# Documentation: https://docs.travis-ci.com/user/deployment/releases/
- provider: releases
  file:
    - dist/*
    - tensorlayer.egg-info/PKG-INFO
  file_glob: true
  skip_cleanup: true
  api_key: '$GITHUB_PERSONAL_TOKEN'
  on:
    tags: true
    python: '3.6'
    condition: '$_TF_VERSION = 2.0.0-rc1'
#     condition: '$_TF_VERSION = 1.11.0'
