# Copyright (c) Microsoft Corporation.
# Licensed under the MIT license.

trigger:
  - main
  - release/*

strategy:
  matrix:
    python-3.7:
      imageTag: '3.7'
    python-3.10:
      imageTag: '3.10'
    python-3.12:
      imageTag: '3.12'
  maxParallel: 3

pool:
  vmImage: ubuntu-latest

container:
  image: python:$(imageTag)

steps:
  - script: |
      echo "##vso[task.prependpath]$HOME/.local/bin"
    displayName: Export path
  - script: |
      if python3 -c "import sys; exit(0 if sys.version_info < (3, 11) else 1)"; then
        python3 -m pip install --upgrade setuptools==65.7
      fi
      python3 -m pip install .[test,cpuworker]
      make postinstall
    displayName: Install dependencies
  - script: |
      python3 setup.py lint
    displayName: Run code lint
  - script: |
      python3 setup.py test
    displayName: Run unit tests
    timeoutInMinutes: 10
    env:
      SB_TEST_CUDA: '0'
  - script: |
      bash <(curl -s https://codecov.io/bash) -cF cpu-python$(imageTag)-unit-test
    displayName: Report coverage results
    env:
      CODECOV_TOKEN: $(codecovToken)
