# This is used to test if the released version is in healthy state or not
# Runs everyday midnight UTC

pr: none

trigger: none

schedules:
- cron: "0 0 * * *"
  displayName: Daily midnight build
  branches:
    include:
    - release-0.16.0
  always: true

jobs:

- job: 'Build_Publish_Azure_CLI_Test_SDK'
  pool:
    vmImage: 'ubuntu-latest'

  steps:
  - task: UsePythonVersion@0
    inputs:
      versionSpec: '3.x'
      architecture: 'x64'

  - template: templates/setup-ci-machine.yml

  - template: templates/build-publish-azure-cli-test-sdk.yml

- job: 'Run_Test'
  dependsOn : Build_Publish_Azure_CLI_Test_SDK
  pool:
    vmImage: 'ubuntu-latest'

  steps:
    - task: UsePythonVersion@0
      inputs:
        versionSpec: '3.x'
        architecture: 'x64'

    - template: templates/install-azure-cli-edge.yml

    - template: templates/download-install-local-azure-test-sdk.yml

    - template: templates/setup-ci-machine.yml

    - task: CmdLine@2
      displayName: 'Install azure devops extension from azure cli index'
      inputs:
        script: 'az extension add -n azure-devops --debug'

    - script: pytest --junitxml "TEST-results.xml"
      displayName: 'Run Tests'
    
    - task: PublishTestResults@2
      displayName: 'Publish Test Results'
      inputs:
        testResultsFormat: 'JUnit'
        testResultsFiles: '**TEST-*.xml'
        searchFolder: '$(System.DefaultWorkingDirectory)/'
      condition: succeededOrFailed()