sudo: required
dist: trusty
services: docker
language: python
python: 3.5
cache:
  timeout: 600

notifications:
  webhooks:
    urls:
      - secure: "A/Ai9L2s3B5L3DEMhwrKGFTJmTOIldUTNDGCrKgcZhIDBE+uXXqXwy2VpSKaWG0jnPl56x4aBqeSkMR65QqMm35ArNGQVO7oN2aXOR8wwb+TGgt1rQXx+I90Q0swVRPgRUY+kHsCTHMT+dnsFLR+K68Yo0IL+hIEYtQB/9ns2Jz1gl4ssoQPQ7+ODXIWqc1VQCtpEgF1OxyZLWPTbzIrIrjSLsSHipyBiShHCZDvju9uip8fw4/LggQktTmbBg8ftdzfZO0l3xUN4kWul8iidXT3d9G+GHx9wXdkiQLKZY5/TdplLjbdHvjAI0XpnOqQpolYon46Q98ktzZr+Su9Pyg2H9J5m5o7QGYt6+U7QmXkA3oxJSXBbmf8JhLIeC1w6u6KK15PZAjPDAm7cRM6lISA/+6LoCTe4AHem70fNl0MaSHmATQK5Gku3kBtPIH8I52eWknFtWDYdM6rxNZAW2KFt6A8hSRte4zYcH1fBZnpu8u97+Upul+ao9IKFJrlovxrV/424LMmuhurBltsXAOu0Dy2KVBSdXI6L9cvfLL+xiTTbxyoc1VB6xURsJvTISpYilc9vzlYKveAgLae0zpahrsAtNkkHLe2gDicr4MZrx8XYLjleYOm9aLiMaxLPXsbNBEvI1LMA6eZRVUevbuC0ltftWu08OfvlkuYun8="

jobs:
  include:
    - stage: build+test
      os: linux
      env:
      - D="STYLE"
      - STYLECHECK='TRUE'
      - PLATFORM='xenial'
      install:
      - python --version
      - echo "Skip installing requirements.txt"
      script:
      - "./travis/build.sh"

    - stage: build+test
      os: linux
      env:
      - D="UNITTESTS"
      - TEST='TRUE'
      - PLATFORM='xenial'
      - CODACY_PROJECT_TOKEN=$CODACY_PROJECT_TOKEN
      install:
      - python --version
      - echo "Skip installing requirements.txt when running integration tests"
      script:
      - "./travis/build.sh"
      - sudo pip install -U coverage codacy-coverage | cat
      - if [[ "$TRAVIS_BRANCH" == "master" ]]; then python-codacy-coverage -r coverage.xml || echo "failed"; fi

    - stage: build+test
      os: linux
      env:
      - D="UNITTESTS"
      - TEST='TRUE'
      - PLATFORM='stretch'
      - CODACY_PROJECT_TOKEN=$CODACY_PROJECT_TOKEN
      install:
      - python --version
      - echo "Skip installing requirements.txt when running integration tests"
      script:
      - "./travis/build.sh"

    - stage: build+test
      os: linux
      env:
      - D="UNITTESTS"
      - TEST='TRUE'
      - PLATFORM='jessie'
      - CODACY_PROJECT_TOKEN=$CODACY_PROJECT_TOKEN
      install:
      - python --version
      - echo "Skip installing requirements.txt when running integration tests"
      script:
      - "./travis/build.sh"

    - stage: build+test
      os: linux
      env:
      - D="INTTEST_SYNC"
      - INTEGRATION_TESTINPLACE='TRUE'
      - PLATFORM='xenial'
      install:
      - python --version
      - echo "Skip installing requirements.txt when running integration tests"
      script:
      - sudo pip install -U docker-compose | cat
      - docker-compose --version
      - sudo pip install pytest
      - export PYTHONPATH=$(pwd)/tests_integration
      - "cd tests_integration; pytest -s --ignore=tests/custom"

    - stage: build+test
      os: linux
      env:
      - D="INTTEST_SYNC+1MIN"
      - INTEGRATION_TESTINPLACE='TRUE'
      - PLATFORM='xenial'
      install:
      - python --version
      - echo "Skip installing requirements.txt when running integration tests"
      script:
      - sudo pip install -U docker-compose | cat
      - docker-compose --version
      - sudo pip install pytest
      - export PYTHONPATH=$(pwd)/tests_integration
      - "cd tests_integration; pytest --noconftest -s -m oneminaftersync"

    - stage: publish
      if: tag =~ ^v
      os: linux
      env:
      - PLATFORM='xenial'
      - DEPLOY='TRUE'
      install:
      - python --version
      - echo "Skip installing requirements.txt when using docker builders"
      script:
      - sudo apt install -y python-dev libssl-dev libffi-dev
      - sudo pip install -U pip setuptools twine pyOpenSSL ndg-httpsclient pyasn1 | cat
      - "./travis/build.sh"

      deploy:
        provider: pypi
        skip_cleanup: true
        user: deployqrl
        password:
          secure: rav+35H/zB7IiVmFEeoJ0FAbTph3b9fc74NrKwKrQTrtD9vvQx3q66sWrKibA/Ws1DqkORS3leMBqJGU5Q4JTp5lcfMTvqtZhdBCJwUHMUlZ9Qw5SiVHpK+adFOwbtzKisgMPhPTgOyxiUtI18I9fMd5SeHEzTXDDZAWuJRVPuLYLDhHj+he5EfoaGtNgN5kVDIP3c6jo6mE+dVvJl89IvuMQihDScpv3TSEmA9klUF4Vm7VeQwrkZn81SfoR8RpIU4QoWhxXbK52hVRK9126Y9JMMBK4XXfGRLjtv3likdX50TjclS7IBjarMGc27LBKfcmpRBqCXcYo4oWV/hDaH7U+AdB+M0wUnR8zoNEEJX1pzTbMsnu+yvLDZ8wS1gjJxr5JEMgkWxg4cnND2hJW2zLKzRqVpFpicYH48Hv13p0QXMxfbpI3hsRHjs9Sl2oV9svcYoFlFTZHcxHkmw6RthxaI/85pj7m1RzfTy1CatRpmY8sRgjpbuztU8lkRTiiuOhqL+OBidstsjygXKMUVP78LxqBuSH3i/kJxF0vkE6FxlkwnSjxk6isN+T+CvAfvqqqjYNI+sbZ1grLVEhC0eOtgLXTcvzfHj2Zcc9XscJMfo8EQ9rnXVRhJAI67P0EqRTdGcv6GH5xCZfRFYkmG4+0kWUl5LYJJpEyMHtV9I=
        on:
          tags: true
          all_branches: true
