trigger:
  - 'master'

jobs:
  - job: FlaskBB
    variables:
      TOXENV: 'py,coverage-ci'

    pool:
      vmImage: ubuntu-latest

    strategy:
      matrix:
        Python27:
          python.version: '2.7'
        Python35:
          python.version: '3.5'
        Python36:
          python.version: '3.6'
        Python37:
          python.version: '3.7'
      maxParallel: 4

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

      - script: |
          python -m pip install --upgrade pip
          pip install pytest-azurepipelines
          pip install -r requirements-dev.txt
        displayName: Install dependencies

      - script: flaskbb translations compile
        displayName: Prepare FlaskBB

      - script: tox -- --junitxml=test-results.xml
        displayName: Run tox
        env:
          # Can't define in section 'variables' due it being a secret one
          CODECOV_TOKEN: $(codecov.token)

      - task: PublishTestResults@2
        displayName: Publish test results
        inputs:
          testResultsFiles: test-results.xml
          testRunTitle: $(Agent.JobName)
        condition: succeededOrFailed()

      - task: PublishCodeCoverageResults@1
        displayName: Publish coverage results
        inputs:
          codeCoverageTool: Cobertura
          summaryFileLocation: coverage.xml
        condition: succeededOrFailed()
