sudo: false
language: python
python:
- '3.6'
cache: pip

git:
  depth: 10

branches:
  only:
  - master
  - staging
  - production
  - /.*/

env:
  global:
  - LOCAL_MODE=True
  - REPO="APM-PM-Maven-Build"
  - FILES="pmlib-1.0.0.tar.gz"
  - GH_REPO="https://${GIT_ACCESS_TOKEN}@github.ibm.com/asset-performance/APM-PM-Maven-Build.git"
  - GH_USER="pmqcloud"
  - GH_EMAIL="pmqcloud@us.ibm.com"
 #- BRANCH=$(if [ "$TRAVIS_PULL_REQUEST" == "false" ]; then echo $TRAVIS_BRANCH; else echo $TRAVIS_PULL_REQUEST_BRANCH; fi)
  - BRANCH=${TRAVIS_BRANCH}

services:
  - docker

addons:
  apt:
    packages:
    - python3
    - python3-pip

before_install:
- chmod +x build_doc.sh

install:
- pip install .[test]
- pip install pdoc3

before_script:
- echo "${PMI_ARTIFACTORY_API_KEY}" | docker login -u "${PMI_ARTIFACTORY_USER}" --password-stdin iot-connectionservice-docker-local.artifactory.swg-devops.com
- docker build -f as-container/Dockerfile-travis -t pmlib/build .

script:
- docker run --rm -it -e LOCAL_MODE=True pmlib/build
# - pytest pmlib

after_success:
- python setup.py sdist
- "./build_doc.sh"

deploy:
- provider: script
  skip_cleanup: true
  script: bash ./deploy.sh  
  on:
    all_branches: true
    condition: $TRAVIS_BRANCH =~ ^(staging|master)$

notifications:
 slack: ibm-iot-division:wFEibv6f1VIYYmB2wJI5t2cH
