# ---------------------------------------------------------
# Copyright (c) Microsoft Corporation. All rights reserved.
# ---------------------------------------------------------

parameters:
- name: pythonVersion
  displayName: Python Version
  type: string
  default: 3.9
  values:
    - 3.7
    - 3.8
    - 3.9
- name: subscriptionName
  type: string
- name: cliSource
  displayName: Installation source for CLI
  type: string
  default: LatestRelease
  values:
    - LatestRelease
    - LatestDev
    - LatestTest
- name: sdkSource
  displayName: Installation source for Python SDK
  type: string
  default: LatestRelease
  values:
    - LatestRelease
    - LatestDev
    - LatestTest


steps:
  - checkout: self
    fetchDepth: 1
    clean: true

  - task: UsePythonVersion@0
    displayName: "Use Python ${{parameters.pythonVersion}}"
    inputs:
      versionSpec: ${{parameters.pythonVersion}}
      
  - powershell: |
      Set-PSDebug -Trace 0
      Install-Module powershell-yaml -Scope CurrentUser -Force
    displayName: Install YAML extension for Powershell

  - script: |
      echo "##[section]Upgrading pip and setuptools..."
      pip install --upgrade pip setuptools wheel
    failOnStderr: true
    displayName: Install pip etc.

  - task: PowerShell@2
    inputs:
      targetType: filePath
      filepath: scripts/Run-Pip.ps1
      arguments: -sdkVersionSelect ${{parameters.sdkSource}}
    displayName: Install pip requirements

  - script: pip install -r requirements-for-testing.txt
    displayName: Install pip testing requirements

  - task: AzureCLI@2
    displayName: Install AzureML CLI v2
    inputs:
      azureSubscription: "${{parameters.subscriptionName}}"
      scriptType: pscore
      scriptLocation: scriptPath
      scriptPath: scripts/Install-CLIv2.ps1
      failOnStandardError: false
      arguments: -sdkVersionSelect ${{parameters.cliSource}}
