# Python package
# Create and test a Python package on multiple Python versions.
# Add steps that analyze code, save the dist with the build record, publish to a PyPI-compatible index, and more:
# https://docs.microsoft.com/azure/devops/pipelines/languages/python

parameters:
  # defaults for any parameters that are not specified
  name: ''
  vmImage: ''


jobs:

- job: ${{ parameters.name }}Test
  pool:
    vmImage: ${{ parameters.vmImage }}
  strategy:
    matrix:
      python39_win_latest:
        python.version: '3.9'
        python.architecture: 'x64'
      python310_win_latest:
        python.version: '3.10'
        python.architecture: 'x64'
      python311_win_latest:
        python.version: '3.11'
        python.architecture: 'x64'
      python312_win_latest:
        python.version: '3.12'
        python.architecture: 'x64'
    maxParallel: 10

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

  - script: |
      python -m pip install --upgrade pip setuptools wheel
    displayName: 'Update essentials'

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

  - script: |
      python -m pip list
    displayName: 'List Configuration'

  - script: |
      python -m pip install -e . -v --no-build-isolation
    displayName: 'Build Cython Extensions'

  - script: |
      pytest statsmodels --skip-examples --junitxml=junit/test-results.xml -n 2 --durations=50
    displayName: 'pytest'

  - task: PublishTestResults@2
    inputs:
      testResultsFiles: '**/test-results.xml'
      testRunTitle: 'Python $(python.version)'
    condition: succeededOrFailed()
