steps:
- task: UsePythonVersion@0
  displayName: Use Python $(python.version)
  inputs:
    versionSpec: '$(python.version)'

- bash: pip install --upgrade setuptools tox
  displayName: Install Tox

- script: tox -e py -- -m unit --junit-xml=junit/unit-test.xml
  displayName: Tox run unit tests

# Run integration tests in two groups so we will fail faster if there is a failure in the first group
- script: tox -e py -- -m integration -n 4 --duration=5 -k "not test_install" --junit-xml=junit/integration-test-group0.xml
  displayName: Tox run Group 0 integration tests

- script: tox -e py -- -m integration -n 4 --duration=5 -k "test_install" --junit-xml=junit/integration-test-group1.xml
  displayName: Tox run Group 1 integration tests

- task: PublishTestResults@2
  displayName: Publish Test Results
  inputs:
    testResultsFiles: junit/*.xml
    testRunTitle: 'Python $(python.version)'
  condition: succeededOrFailed()