# Starter pipeline
# Start with a minimal pipeline that you can customize to build and deploy your code.
# Add steps that build, run tests, deploy, and more:
# https://aka.ms/yaml

trigger:
  batch: true
  branches:
    include:
      - master

variables:
  skipComponentGovernanceDetection: true

pool: '1ES-Host-Ubuntu'

jobs:
  - job: VRToolUpdateBaseline_WebComponents
    variables:
      pipelineId: '315'
    workspace:
      clean: all
    steps:
      - template: .devops/templates/tools.yml
      - template: .devops/templates/runpublishvrscreenshot.yml
        parameters:
          fluentVersion: webcomponents
          vrTestPackageName: 'vr-tests-web-components'
          vrTestPackagePath: 'apps/vr-tests-web-components'

      - task: AzureCLI@2
        displayName: 'Run Screenshotdiff update baseline'
        env:
          API_TOKEN: $(fabric-public-pipeline-access-PAT)
          GITHUB_API_TOKEN: $(githubRepoStatusPAT)
          VR_APP_API_URL: $(VR_APP_API_URL)
          STORAGE_ACCOUNT_ID: $(StorageAccountId)
          TENANT_ID: $(TenantId)
          PRINCIPAL_CLIENT_ID: $(PrincipalClientId)
          SERVICE_CONNECTION_ID: $(ServiceConnectionId)
          SYSTEM_ACCESSTOKEN: $(System.AccessToken)
        inputs:
          azureSubscription: $(AzureSubscription)
          scriptType: bash
          scriptLocation: 'inlineScript'
          inlineScript: |
            npx vr-approval-cli@0.4.5 run-diff --buildType release --screenshotsDirectory ./screenshots --clientType "FLUENTUI" --locationPrefix 'FluentUI-web-components' --locationPostfix 'vrscreenshotwebcomponents' --pipelineId $(pipelineId)

  - job: VRToolUpdateBaseline_V9
    variables:
      pipelineId: '311'
    workspace:
      clean: all
    steps:
      - template: .devops/templates/tools.yml
      - template: .devops/templates/runpublishvrscreenshot.yml
        parameters:
          fluentVersion: v9
          vrTestPackageName: 'vr-tests-react-components'
          vrTestPackagePath: 'apps/vr-tests-react-components'

      - task: AzureCLI@2
        displayName: 'Run Screenshotdiff update baseline'
        env:
          API_TOKEN: $(fabric-public-pipeline-access-PAT)
          GITHUB_API_TOKEN: $(githubRepoStatusPAT)
          VR_APP_API_URL: $(VR_APP_API_URL)
          STORAGE_ACCOUNT_ID: $(StorageAccountId)
          TENANT_ID: $(TenantId)
          PRINCIPAL_CLIENT_ID: $(PrincipalClientId)
          SERVICE_CONNECTION_ID: $(ServiceConnectionId)
          SYSTEM_ACCESSTOKEN: $(System.AccessToken)
        inputs:
          azureSubscription: $(AzureSubscription)
          scriptType: bash
          scriptLocation: 'inlineScript'
          inlineScript: |
            npx vr-approval-cli@0.4.5 run-diff --buildType release --screenshotsDirectory ./screenshots --clientType "FLUENTUI" --locationPrefix 'fluentuiv9' --locationPostfix 'vrscreenshotv9' --pipelineId $(pipelineId)

  - job: VRToolUpdateBaseline_V8
    variables:
      pipelineId: '312'
    workspace:
      clean: all
    steps:
      - template: .devops/templates/tools.yml
      - template: .devops/templates/runpublishvrscreenshot.yml
        parameters:
          fluentVersion: v8
          vrTestPackageName: 'vr-tests'
          vrTestPackagePath: 'apps/vr-tests'

      - task: AzureCLI@2
        displayName: 'Run fluentui-screenshotdiff'
        env:
          API_TOKEN: $(fabric-public-pipeline-access-PAT)
          GITHUB_API_TOKEN: $(githubRepoStatusPAT)
          VR_APP_API_URL: $(VR_APP_API_URL)
          STORAGE_ACCOUNT_ID: $(StorageAccountId)
          TENANT_ID: $(TenantId)
          PRINCIPAL_CLIENT_ID: $(PrincipalClientId)
          SERVICE_CONNECTION_ID: $(ServiceConnectionId)
          SYSTEM_ACCESSTOKEN: $(System.AccessToken)
        inputs:
          azureSubscription: $(AzureSubscription)
          scriptType: bash
          scriptLocation: 'inlineScript'
          inlineScript: |
            npx vr-approval-cli@0.4.5 run-diff --screenshotsDirectory ./screenshots --buildType release --clientType "FLUENTUI" --locationPrefix 'fluentuiv8' --locationPostfix 'vrscreenshotv8' --pipelineId $(pipelineId)

  - job: VRToolUpdateBaseline_V0
    variables:
      pipelineId: '313'
    workspace:
      clean: all
    steps:
      - template: .devops/templates/tools.yml
      - template: .devops/templates/runpublishvrscreenshot.yml
        parameters:
          fluentVersion: v0
          vrTestPackageName: 'docs'
          vrTestPackagePath: 'packages/fluentui/docs'

      - task: AzureCLI@2
        displayName: 'Run fluentui-screenshotdiff'
        env:
          API_TOKEN: $(fabric-public-pipeline-access-PAT)
          GITHUB_API_TOKEN: $(githubRepoStatusPAT)
          VR_APP_API_URL: $(VR_APP_API_URL)
          STORAGE_ACCOUNT_ID: $(StorageAccountId)
          TENANT_ID: $(TenantId)
          PRINCIPAL_CLIENT_ID: $(PrincipalClientId)
          SERVICE_CONNECTION_ID: $(ServiceConnectionId)
          SYSTEM_ACCESSTOKEN: $(System.AccessToken)
        inputs:
          azureSubscription: $(AzureSubscription)
          scriptType: bash
          scriptLocation: 'inlineScript'
          inlineScript: |
            npx vr-approval-cli@0.4.5 run-diff --buildType release --screenshotsDirectory ./screenshots --clientType "FLUENTUI" --locationPrefix 'FluentUI-v0' --locationPostfix 'vrscreenshotv0' --pipelineId $(pipelineId)