parameters:
  name: ''
  vmImage: ''
  matrix: []
  dependsOn: []
  condition: ''

jobs:
- job: ${{ parameters.name }}
  dependsOn: ${{ parameters.dependsOn }}
  condition: ${{ parameters.condition }}
  timeoutInMinutes: 120
  pool:
    vmImage: ${{ parameters.vmImage }}
  variables:
    TEST_DIR: '$(Agent.WorkFolder)/tmp_folder'
    VIRTUALENV: 'testvenv'
    JUNITXML: 'test-data.xml'
    OMP_NUM_THREADS: '2'
    OPENBLAS_NUM_THREADS: '2'
    CPU_COUNT: '2'
    SKLEARN_SKIP_NETWORK_TESTS: '1'
    SKLEARN_DATA_DIR: $(System.DefaultWorkingDirectory)/scikit_learn_data
    NUMPY_VERSION: 'latest'
    SCIPY_VERSION: 'latest'
    SKLEARN_VERSION: 'latest'
    TENSORFLOW_VERSION: 'none'
    KERAS_VERSION: 'none'
    JOBLIB_VERSION: 'latest'
    PANDAS_VERSION: 'latest'
    PILLOW_VERSION: 'latest'
    MATPLOTLIB_VERSION: 'latest'
    PYTEST_VERSION: 'latest'
    PYTEST_XDIST_VERSION: 'latest'
    THREADPOOLCTL_VERSION: 'latest'
    COVERAGE: 'true'
    TEST_DOCS: 'false'
    TEST_DOCSTRINGS: 'false'
    CHECK_WARNINGS: 'false'
    SHOW_SHORT_SUMMARY: 'false'
  strategy:
    matrix:
      ${{ insert }}: ${{ parameters.matrix }}

  steps:
    - bash: echo "##vso[task.prependpath]$CONDA/bin"
      displayName: Add conda to PATH
      condition: startsWith(variables['DISTRIB'], 'conda')
    - bash: sudo chown -R $USER $CONDA
      displayName: Take ownership of conda installation
      condition: startsWith(variables['DISTRIB'], 'conda')
    - script: |
        build_tools/azure/install.sh
      displayName: 'Install'
    - script: |
        build_tools/azure/test_script.sh
      displayName: 'Test Library'
    - script: |
        build_tools/azure/test_docs.sh
      displayName: 'Test Docs'
      condition: eq(variables['TEST_DOCS'], 'true')
    - script: |
        build_tools/azure/test_docstring.sh
      displayName: "Numpydoc validation"
      condition: eq(variables['TEST_DOCSTRINGS'], 'true')
    - task: PublishTestResults@2
      inputs:
        testResultsFiles: '$(TEST_DIR)/$(JUNITXML)'
        testRunTitle: ${{ format('{0}-$(Agent.JobName)', parameters.name) }}
      displayName: 'Publish Test Results'
      condition: succeededOrFailed()
    - script: |
        build_tools/azure/upload_codecov.sh
      condition: and(succeeded(), eq(variables['COVERAGE'], 'true'))
      displayName: 'Upload To Codecov'
      env:
        CODECOV_TOKEN: $(CODECOV_TOKEN)
