Skip to content

Commit

Permalink
ci(vrt): upgrade VR tool to be security compliant (microsoft#31997)
Browse files Browse the repository at this point in the history
  • Loading branch information
TristanWatanabe authored Jul 19, 2024
1 parent bae6b88 commit 651b92e
Show file tree
Hide file tree
Showing 3 changed files with 113 additions and 34 deletions.
57 changes: 48 additions & 9 deletions azure-pipelines.vrt-baseline.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,25 @@ jobs:
vrTestPackageName: '@fluentui/vr-tests-web-components'
vrTestPackagePath: 'apps/vr-tests-web-components'

- bash: vr-app run-diff --buildType release --screenshotsDirectory ./screenshots --clientType "FLUENTUI" --locationPrefix 'FluentUI-web-components' --locationPostfix 'vrscreenshotwebcomponents' --pipelineId $(pipelineId)
- task: AzureCLI@2
displayName: 'Run Screenshotdiff update baseline'
env:
API_TOKEN: $(fabric-public-pipeline-access-PAT)
GITHUB_API_TOKEN: $(githubRepoStatusPAT)
STORAGE_CONNECTION_STRING: $(BLOB-CONNECTION-STRING)
VR_APP_CLIENT_SECRET: $(VR-APPROVAL-CLIENT-SECRET)
VR_APP_CLIENT_ID: $(VR_APP_CLIENT_ID)
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: |
vr-app run-diff --buildType release --screenshotsDirectory ./screenshots --clientType "FLUENTUI" --locationPrefix 'FluentUI-web-components' --locationPostfix 'vrscreenshotwebcomponents' --pipelineId $(pipelineId)
- job: VRToolUpdateBaseline_V9
variables:
Expand All @@ -53,15 +63,25 @@ jobs:
vrTestPackageName: '@fluentui/vr-tests-react-components'
vrTestPackagePath: 'apps/vr-tests-react-components'

- bash: vr-app run-diff --buildType release --screenshotsDirectory ./screenshots --clientType "FLUENTUI" --locationPrefix 'fluentuiv9' --locationPostfix 'vrscreenshotv9' --pipelineId $(pipelineId)
- task: AzureCLI@2
displayName: 'Run Screenshotdiff update baseline'
env:
API_TOKEN: $(fabric-public-pipeline-access-PAT)
GITHUB_API_TOKEN: $(githubRepoStatusPAT)
STORAGE_CONNECTION_STRING: $(BLOB-CONNECTION-STRING)
VR_APP_CLIENT_SECRET: $(VR-APPROVAL-CLIENT-SECRET)
VR_APP_CLIENT_ID: $(VR_APP_CLIENT_ID)
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: |
vr-app run-diff --buildType release --screenshotsDirectory ./screenshots --clientType "FLUENTUI" --locationPrefix 'fluentuiv9' --locationPostfix 'vrscreenshotv9' --pipelineId $(pipelineId)
- job: VRToolUpdateBaseline_V8
variables:
Expand All @@ -77,16 +97,25 @@ jobs:
vrTestPackageName: '@fluentui/vr-tests'
vrTestPackagePath: 'apps/vr-tests'

- bash: vr-app run-diff --screenshotsDirectory ./screenshots --buildType release --clientType "FLUENTUI" --locationPrefix 'fluentuiv8' --locationPostfix 'vrscreenshotv8' --pipelineId $(pipelineId)
- task: AzureCLI@2
displayName: 'Run fluentui-screenshotdiff'
env:
API_TOKEN: $(fabric-public-pipeline-access-PAT)
GITHUB_API_TOKEN: $(githubRepoStatusPAT)
STORAGE_CONNECTION_STRING: $(BLOB-CONNECTION-STRING)
VR_APP_CLIENT_SECRET: $(VR-APPROVAL-CLIENT-SECRET)
VR_APP_CLIENT_ID: $(VR_APP_CLIENT_ID)
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: |
vr-app run-diff --screenshotsDirectory ./screenshots --buildType release --clientType "FLUENTUI" --locationPrefix 'fluentuiv8' --locationPostfix 'vrscreenshotv8' --pipelineId $(pipelineId)
- job: VRToolUpdateBaseline_V0
variables:
pipelineId: '313'
Expand All @@ -101,12 +130,22 @@ jobs:
vrTestPackageName: '@fluentui/docs'
vrTestPackagePath: 'packages/fluentui/docs'

- bash: vr-app run-diff --buildType release --screenshotsDirectory ./screenshots --clientType "FLUENTUI" --locationPrefix 'FluentUI-v0' --locationPostfix 'vrscreenshotv0' --pipelineId $(pipelineId)
- task: AzureCLI@2
displayName: 'Run fluentui-screenshotdiff'
env:
API_TOKEN: $(fabric-public-pipeline-access-PAT)
GITHUB_API_TOKEN: $(githubRepoStatusPAT)
STORAGE_CONNECTION_STRING: $(BLOB-CONNECTION-STRING)
VR_APP_CLIENT_SECRET: $(VR-APPROVAL-CLIENT-SECRET)
VR_APP_CLIENT_ID: $(VR_APP_CLIENT_ID)
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: |
vr-app run-diff --buildType release --screenshotsDirectory ./screenshots --clientType "FLUENTUI" --locationPrefix 'FluentUI-v0' --locationPostfix 'vrscreenshotv0' --pipelineId $(pipelineId)
88 changes: 64 additions & 24 deletions azure-pipelines.vrt-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,10 +30,10 @@ jobs:

- bash: |
postPolicy="true";
response=$(curl --request POST ${VR_APP_CLIENT_URL} --header 'Content-Type: application/x-www-form-urlencoded' --data-urlencode 'grant_type=client_credentials' --data-urlencode 'client_id='${VR_APP_CLIENT_ID} --data-urlencode 'client_secret='${VR_APPROVAL_CLIENT_SECRET} )
response=$(curl --request POST ${VR_APP_CLIENT_URL} --header 'Content-Type: application/x-www-form-urlencoded' --data-urlencode 'grant_type=client_credentials' --data-urlencode 'client_id='${VR_APP_CLIENT_ID} --data-urlencode 'client_secret='${VR_APPROVAL_CLIENT_SECRET})
parsedResponse=${response/*"access_token"/}
token=${parsedResponse:3:${#parsedResponse}-5}
curl --location --request POST 'https://vrapprovalfunction-prod.azurewebsites.net/api/policyStateV2' \
curl --location --request POST 'https://vrtfunctionappv0.azurewebsites.net/api/policyStateV2' \
--header 'Authorization: Bearer '"$token" \
--header 'Content-Type: application/json' \
--data-raw ' {
Expand All @@ -56,26 +56,36 @@ jobs:
}'
displayName: 'Call policy State Api'
env:
VR_APPROVAL_CLIENT_SECRET: $(VR-APPROVAL-CLIENT-SECRET)
VR_APPROVAL_HOST: $(VR_APPROVAL_HOST)
VR_APP_CLIENT_ID: $(VR_APP_CLIENT_ID)
VR_APPROVAL_CLIENT_SECRET: $(VR-APPROVAL-CLIENT-SECRET)
VR_APP_CLIENT_URL: $(VR_APP_CLIENT_URL)
- template: .devops/templates/runpublishvrscreenshot.yml
parameters:
fluentVersion: webcomponents
vrTestPackageName: '@fluentui/vr-tests-web-components'
vrTestPackagePath: 'apps/vr-tests-web-components'
# ciDefinitionId is set to 205 because that is the ID of the baseline pipeline (https://uifabric.visualstudio.com/fabricpublic/_build?definitionId=205) used by the master branch
- bash: vr-app run-diff --screenshotsDirectory ./screenshots --buildType pr --clientType "FLUENTUI" --ciDefinitionId 205 --groupName $(pipelineName) --locationPrefix 'FluentUI-web-components' --locationPostfix 'vrscreenshotwebcomponents' --pipelineId $(pipelineId) --clientName 'fluentui-web-components-v3' --threshold '0.04' --cumThreshold '1'

- task: AzureCLI@2
displayName: 'Run fluentui-screenshotdiff'
env:
API_TOKEN: $(fabric-public-pipeline-access-PAT)
GITHUB_API_TOKEN: $(githubRepoStatusPAT)
STORAGE_CONNECTION_STRING: $(BLOB-CONNECTION-STRING)
VR_APP_CLIENT_SECRET: $(VR-APPROVAL-CLIENT-SECRET)
VR_APP_CLIENT_ID: $(VR_APP_CLIENT_ID)
VR_APP_API_URL: $(VR_APP_API_URL)
VR_APP_API_URL: $(VR_APP_API_URL_NEW)
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: |
vr-app run-diff --screenshotsDirectory ./screenshots --buildType pr --clientType "FLUENTUI" --ciDefinitionId 205 --groupName $(pipelineName) --locationPrefix 'FluentUI-web-components' --locationPostfix 'vrscreenshotwebcomponents' --pipelineId $(pipelineId) --clientName 'fluentui-web-components-v3' --threshold '0.04' --cumThreshold '1'
condition: eq(variables['vrTestSkip'], 'no')

- job: VisualRegressionTest_V9
Expand All @@ -98,7 +108,7 @@ jobs:
response=$(curl --request POST ${VR_APP_CLIENT_URL} --header 'Content-Type: application/x-www-form-urlencoded' --data-urlencode 'grant_type=client_credentials' --data-urlencode 'client_id='${VR_APP_CLIENT_ID} --data-urlencode 'client_secret='${VR_APPROVAL_CLIENT_SECRET} )
parsedResponse=${response/*"access_token"/}
token=${parsedResponse:3:${#parsedResponse}-5}
curl --location --request POST 'https://vrapprovalfunction-prod.azurewebsites.net/api/policyStateV2' \
curl --location --request POST 'https://vrtfunctionappv0.azurewebsites.net/api/policyStateV2' \
--header 'Authorization: Bearer '"$token" \
--header 'Content-Type: application/json' \
--data-raw ' {
Expand All @@ -121,9 +131,9 @@ jobs:
}'
displayName: 'Call policy State Api'
env:
VR_APPROVAL_CLIENT_SECRET: $(VR-APPROVAL-CLIENT-SECRET)
VR_APPROVAL_HOST: $(VR_APPROVAL_HOST)
VR_APP_CLIENT_ID: $(VR_APP_CLIENT_ID)
VR_APPROVAL_CLIENT_SECRET: $(VR-APPROVAL-CLIENT-SECRET)
VR_APP_CLIENT_URL: $(VR_APP_CLIENT_URL)
- template: .devops/templates/runpublishvrscreenshot.yml
Expand All @@ -132,15 +142,25 @@ jobs:
vrTestPackageName: '@fluentui/vr-tests-react-components'
vrTestPackagePath: 'apps/vr-tests-react-components'

- bash: vr-app run-diff --buildType pr --screenshotsDirectory ./screenshots --clientType "FLUENTUI" --ciDefinitionId 205 --groupName $(pipelineName) --locationPrefix 'fluentuiv9' --locationPostfix 'vrscreenshotv9' --pipelineId $(pipelineId) --clientName 'fluentuiv9' --threshold '0.04' --cumThreshold '1'
- task: AzureCLI@2
displayName: 'Run fluentui-screenshotdiff'
env:
API_TOKEN: $(fabric-public-pipeline-access-PAT)
GITHUB_API_TOKEN: $(githubRepoStatusPAT)
STORAGE_CONNECTION_STRING: $(BLOB-CONNECTION-STRING)
VR_APP_CLIENT_SECRET: $(VR-APPROVAL-CLIENT-SECRET)
VR_APP_CLIENT_ID: $(VR_APP_CLIENT_ID)
VR_APP_API_URL: $(VR_APP_API_URL)
VR_APP_API_URL: $(VR_APP_API_URL_NEW)
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: |
vr-app run-diff --buildType pr --screenshotsDirectory ./screenshots --clientType "FLUENTUI" --ciDefinitionId 205 --groupName $(pipelineName) --locationPrefix 'fluentuiv9' --locationPostfix 'vrscreenshotv9' --pipelineId $(pipelineId) --clientName 'fluentuiv9' --threshold '0.04' --cumThreshold '1'
condition: eq(variables['vrTestSkip'], 'no')

- job: VisualRegressionTest_V8
Expand All @@ -159,10 +179,10 @@ jobs:

- bash: |
postPolicy="true";
response=$(curl --request POST ${VR_APP_CLIENT_URL} --header 'Content-Type: application/x-www-form-urlencoded' --data-urlencode 'grant_type=client_credentials' --data-urlencode 'client_id='${VR_APP_CLIENT_ID} --data-urlencode 'client_secret='${VR_APPROVAL_CLIENT_SECRET} )
response=$(curl --request POST ${VR_APP_CLIENT_URL} --header 'Content-Type: application/x-www-form-urlencoded' --data-urlencode 'grant_type=client_credentials' --data-urlencode 'client_id='${VR_APP_CLIENT_ID} --data-urlencode 'client_secret='${VR_APPROVAL_CLIENT_SECRET})
parsedResponse=${response/*"access_token"/}
token=${parsedResponse:3:${#parsedResponse}-5}
curl --location --request POST 'https://vrapprovalfunction-prod.azurewebsites.net/api/policyStateV2' \
curl --location --request POST 'https://vrtfunctionappv0.azurewebsites.net/api/policyStateV2' \
--header 'Authorization: Bearer '"$token" \
--header 'Content-Type: application/json' \
--data-raw ' {
Expand All @@ -185,9 +205,9 @@ jobs:
}'
displayName: 'Call policy State Api'
env:
VR_APPROVAL_CLIENT_SECRET: $(VR-APPROVAL-CLIENT-SECRET)
VR_APPROVAL_HOST: $(VR_APPROVAL_HOST)
VR_APP_CLIENT_ID: $(VR_APP_CLIENT_ID)
VR_APPROVAL_CLIENT_SECRET: $(VR-APPROVAL-CLIENT-SECRET)
VR_APP_CLIENT_URL: $(VR_APP_CLIENT_URL)
- template: .devops/templates/runpublishvrscreenshot.yml
Expand All @@ -196,15 +216,25 @@ jobs:
vrTestPackageName: '@fluentui/vr-tests'
vrTestPackagePath: 'apps/vr-tests'

- bash: vr-app run-diff --screenshotsDirectory ./screenshots --buildType pr --clientType "FLUENTUI" --ciDefinitionId 205 --groupName $(pipelineName) --locationPrefix 'fluentuiv8' --locationPostfix 'vrscreenshotv8' --pipelineId $(pipelineId) --clientName 'fluentuiv8' --threshold '0.04' --cumThreshold '1'
- task: AzureCLI@2
displayName: 'Run fluentui-screenshotdiff'
env:
API_TOKEN: $(fabric-public-pipeline-access-PAT)
GITHUB_API_TOKEN: $(githubRepoStatusPAT)
STORAGE_CONNECTION_STRING: $(BLOB-CONNECTION-STRING)
VR_APP_CLIENT_SECRET: $(VR-APPROVAL-CLIENT-SECRET)
VR_APP_CLIENT_ID: $(VR_APP_CLIENT_ID)
VR_APP_API_URL: $(VR_APP_API_URL)
VR_APP_API_URL: $(VR_APP_API_URL_NEW)
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: |
vr-app run-diff --screenshotsDirectory ./screenshots --buildType pr --clientType "FLUENTUI" --ciDefinitionId 205 --groupName $(pipelineName) --locationPrefix 'fluentuiv8' --locationPostfix 'vrscreenshotv8' --pipelineId $(pipelineId) --clientName 'fluentuiv8' --threshold '0.04' --cumThreshold '1'
condition: eq(variables['vrTestSkip'], 'no')

- job: VisualRegressionTest_V0
Expand All @@ -224,10 +254,10 @@ jobs:

- bash: |
postPolicy="true";
response=$(curl --request POST ${VR_APP_CLIENT_URL} --header 'Content-Type: application/x-www-form-urlencoded' --data-urlencode 'grant_type=client_credentials' --data-urlencode 'client_id='${VR_APP_CLIENT_ID} --data-urlencode 'client_secret='${VR_APPROVAL_CLIENT_SECRET} )
response=$(curl --request POST ${VR_APP_CLIENT_URL} --header 'Content-Type: application/x-www-form-urlencoded' --data-urlencode 'grant_type=client_credentials' --data-urlencode 'client_id='${VR_APP_CLIENT_ID} --data-urlencode 'client_secret='${VR_APPROVAL_CLIENT_SECRET})
parsedResponse=${response/*"access_token"/}
token=${parsedResponse:3:${#parsedResponse}-5}
curl --location --request POST 'https://vrapprovalfunction-prod.azurewebsites.net/api/policyStateV2' \
curl --location --request POST 'https://vrtfunctionappv0.azurewebsites.net/api/policyStateV2' \
--header 'Authorization: Bearer '"$token" \
--header 'Content-Type: application/json' \
--data-raw ' {
Expand All @@ -250,8 +280,8 @@ jobs:
}'
displayName: 'Call policy State Api'
env:
VR_APPROVAL_CLIENT_SECRET: $(VR-APPROVAL-CLIENT-SECRET)
VR_APP_CLIENT_ID: $(VR_APP_CLIENT_ID)
VR_APPROVAL_CLIENT_SECRET: $(VR-APPROVAL-CLIENT-SECRET)
VR_APP_CLIENT_URL: $(VR_APP_CLIENT_URL)
- template: .devops/templates/runpublishvrscreenshot.yml
Expand All @@ -260,13 +290,23 @@ jobs:
vrTestPackageName: '@fluentui/docs'
vrTestPackagePath: 'packages/fluentui/docs'

- bash: vr-app run-diff --buildType pr --screenshotsDirectory ./screenshots --clientType "FLUENTUI" --ciDefinitionId 205 --groupName $(pipelineName) --locationPrefix 'FluentUI-v0' --locationPostfix 'vrscreenshotv0' --pipelineId $(pipelineId) --clientName 'FluentUIV0' --threshold '0.04' --cumThreshold '1'
- task: AzureCLI@2
displayName: 'Run fluentui-screenshotdiff'
env:
API_TOKEN: $(fabric-public-pipeline-access-PAT)
GITHUB_API_TOKEN: $(githubRepoStatusPAT)
STORAGE_CONNECTION_STRING: $(BLOB-CONNECTION-STRING)
VR_APP_CLIENT_SECRET: $(VR-APPROVAL-CLIENT-SECRET)
VR_APP_CLIENT_ID: $(VR_APP_CLIENT_ID)
VR_APP_API_URL: $(VR_APP_API_URL)
VR_APP_API_URL: $(VR_APP_API_URL_NEW)
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: |
vr-app run-diff --buildType pr --screenshotsDirectory ./screenshots --clientType "FLUENTUI" --ciDefinitionId 205 --groupName $(pipelineName) --locationPrefix 'FluentUI-v0' --locationPostfix 'vrscreenshotv0' --pipelineId $(pipelineId) --clientName 'FluentUIV0' --threshold '0.04' --cumThreshold '1'
condition: eq(variables['vrTestSkip'], 'no')
2 changes: 1 addition & 1 deletion download-vr-cli.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
steps:
- bash: |
set -exuo pipefail
npm install -g vr-approval-cli@0.0.168
npm install -g vr-approval-cli@0.4.3
displayName: Download VR App CLI
retryCountOnTaskFailure: 3

0 comments on commit 651b92e

Please sign in to comment.