dist: xenial
language: python
services:
  - docker
python:
  - "3.7"
sudo: false
cache: pip
env:
  global:
    - LD_PRELOAD=/lib/x86_64-linux-gnu/libSegFault.so
    - SEGFAULT_SIGNALS=all
  matrix:
    - TOXENV=check
    - TOXENV=docs
    - TOXENV=py37,report
before_install:
  - python --version
  - uname -a
  - lsb_release -a
install:
  - pip install tox
  - virtualenv --version
  - easy_install --version
  - pip --version
  - tox --version
script:
  - tox -v
after_failure:
  - more .tox/log/* | cat
  - more .tox/*/log/* | cat
notifications:
  email:
    on_success: never
    on_failure: always
jobs:
  include:
    - stage: deploy
      script: echo "Deploying..."
      before_deploy:
        - echo "Installing deployment tools..."
        - wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh
        - bash miniconda.sh -b -p $HOME/miniconda
        - export PATH="$HOME/miniconda/bin:$PATH"
        - rm miniconda.sh
        - conda config --set anaconda_upload yes
        - conda config --set always_yes yes
        - conda config --set changeps1 no
        - conda config --prepend channels conda-forge
        - conda config --prepend channels albumentations
        - conda config --prepend channels pytorch
        - conda update -q conda
        - conda install conda-build conda-verify anaconda-client
        - conda info -a
        - docker --version
        - if [ "$TRAVIS_PULL_REQUEST" == "false" ]; then echo "$DOCKER_PASSWORD" | docker login --username="$DOCKER_USERNAME" --password-stdin; fi
        - echo "ENV GIT_SHA ${TRAVIS_COMMIT}" >> Dockerfile
      deploy:
        provider: pypi
        user: "${PYPI_USERNAME}"
        password: "${PYPI_PASSWORD}"
        skip_existing: true
        on:
          tags: true
      after_deploy:
        - docker build -t ${DOCKER_REPO}:${TRAVIS_TAG} -t ${DOCKER_REPO}:latest .
        - docker run -t ${DOCKER_REPO}:latest thelper --version
        - if [ "$TRAVIS_PULL_REQUEST" == "false" ]; then travis_wait 30 docker push ${DOCKER_REPO}; fi
        - travis_wait 30 conda build --token $CONDA_TOKEN --user $CONDA_USERNAME ci/
