language: cpp
cache:
  directories:
    - $HOME/.ccache
    - $HOME/.cache/pip
    - $TRAVIS_BUILD_DIR/build/third_party
    - $TRAVIS_BUILD_DIR/build_android/third_party
sudo: required
dist: trusty
services:
  - docker
os:
  - linux
env:
  - JOB=doc
  - JOB=check_style
  - JOB=build_android
addons:
  ssh_known_hosts: 13.229.163.131
before_install:
  # For pylint dockstring checker
  - sudo pip install pylint pytest astroid isort
  - |
    function timeout() { perl -e 'alarm shift; exec @ARGV' "$@"; }
script:
  - |
    # 43min timeout
    paddle/scripts/paddle_docker_build.sh ${JOB}
    if [ $? -eq 0 ] || [ $? -eq 142 ]; then true; else exit 1; fi;
  - |
    if [[ "$JOB" != "doc" ]]; then exit 0; fi;
    # For document only
    if [[ "$TRAVIS_PULL_REQUEST" != "false" ]]; then exit 0; fi;
    if [[ "$TRAVIS_BRANCH" != "develop"  && ! "$TRAVIS_BRANCH" =~ ^v[[:digit:]]+\.[[:digit:]]+(\.[[:digit:]]+)?(-\S*)?$ ]]; then exit 0; fi;
    export DEPLOY_DOCS_SH=https://raw.githubusercontent.com/PaddlePaddle/PaddlePaddle.org/master/scripts/deploy/deploy_docs.sh
    export DOCS_DIR=`pwd`
    cd ..
    curl $DEPLOY_DOCS_SH | bash -s $CONTENT_DEC_PASSWD $TRAVIS_BRANCH $DOCS_DIR $DOCS_DIR/build/doc/
notifications:
  email:
    on_success: change
    on_failure: always