|
| 1 | +name: 'Run and Publish VR Screenshot' |
| 2 | +description: 'Runs and publishes visual regression screenshots' |
| 3 | +inputs: |
| 4 | + fluentVersion: |
| 5 | + description: 'Fluent version' |
| 6 | + required: true |
| 7 | + default: 'v8' |
| 8 | + vrTestPackageName: |
| 9 | + description: 'VR test package name' |
| 10 | + required: true |
| 11 | + default: 'vr-tests' |
| 12 | + vrTestPackagePath: |
| 13 | + description: 'VR test package path' |
| 14 | + required: true |
| 15 | + default: 'apps/vr-tests' |
| 16 | + locationPrefix: |
| 17 | + description: 'Location prefix' |
| 18 | + required: true |
| 19 | + default: 'fluentuiv8' |
| 20 | + locationPostfix: |
| 21 | + description: 'Location postfix' |
| 22 | + required: true |
| 23 | + default: 'vrscreenshotv8' |
| 24 | + clientName: |
| 25 | + description: 'Client name' |
| 26 | + required: true |
| 27 | + default: 'fluentuiv8' |
| 28 | + |
| 29 | +runs: |
| 30 | + using: 'composite' |
| 31 | + steps: |
| 32 | + - uses: nrwl/nx-set-shas@v4 |
| 33 | + with: |
| 34 | + main-branch-name: 'master' |
| 35 | + |
| 36 | + - uses: actions/setup-node@v4 |
| 37 | + with: |
| 38 | + cache: 'yarn' |
| 39 | + node-version: '20' |
| 40 | + |
| 41 | + - run: yarn install --frozen-lockfile |
| 42 | + shell: bash |
| 43 | + |
| 44 | + - run: yarn playwright install --with-deps |
| 45 | + shell: bash |
| 46 | + |
| 47 | + - name: Check if vrTests should be skipped |
| 48 | + shell: bash |
| 49 | + run: | |
| 50 | + isPR=${{ github.event_name == 'pull_request' }} |
| 51 | + echo "isPR=$isPR" >> $GITHUB_ENV |
| 52 | + if [[ $isPR == true ]]; then |
| 53 | + packageAffected=$(yarn --silent check:affected --project ${{ inputs.vrTestPackageName }}) |
| 54 | + if [[ $packageAffected == false ]]; then |
| 55 | + echo "In PR pipeline but NOT affecting test package. Skipping test run" |
| 56 | + echo "vrTestSkip=yes" >> $GITHUB_ENV |
| 57 | + else |
| 58 | + echo "In PR pipeline and affecting test package. NOT Skipping test run" |
| 59 | + echo "vrTestSkip=no" >> $GITHUB_ENV |
| 60 | + fi |
| 61 | + else |
| 62 | + echo "Not in PR pipeline. NOT Skipping test run" |
| 63 | + echo "vrTestSkip=no" >> $GITHUB_ENV |
| 64 | + fi |
| 65 | +
|
| 66 | + - name: Run VR tests |
| 67 | + if: ${{ env.vrTestSkip == 'no' }} |
| 68 | + shell: bash |
| 69 | + run: yarn nx run ${{ inputs.vrTestPackageName }}:test-vr --nxBail |
| 70 | + |
| 71 | + - name: Collate Artifacts |
| 72 | + if: ${{ env.vrTestSkip == 'no' }} |
| 73 | + shell: bash |
| 74 | + run: | |
| 75 | + mkdir -p screenshots |
| 76 | + cp -rf ${{ inputs.vrTestPackagePath }}/dist/screenshots/*.png screenshots/ |
| 77 | +
|
| 78 | + - name: Upload VR screenshots |
| 79 | + if: ${{ env.vrTestSkip == 'no' }} |
| 80 | + uses: actions/upload-artifact@v4 |
| 81 | + with: |
| 82 | + name: vrscreenshot${{ inputs.fluentVersion }} |
| 83 | + path: screenshots |
| 84 | + |
| 85 | + # ========================================================== |
| 86 | + # STEPS BELOW WILL FAIL TO RUN ON GITHUB ACTIONS - see TODOs |
| 87 | + # ========================================================== |
| 88 | + |
| 89 | + # TODO: will need Federated Identity to be added to tool similarly like we have for monosize azure plugin https://github.com/microsoft/monosize/blob/main/packages/monosize-storage-azure/src/createTableClient.mts#L27 |
| 90 | + - name: VR App - Create Policy |
| 91 | + if: ${{ env.isPR == 'true' }} |
| 92 | + shell: bash |
| 93 | + run: | |
| 94 | + set -exuo pipefail |
| 95 | + npx [email protected] create-policy --nonBlockingPipelines '{"${{ env.pipelineId }}":{"pipelineStatus": "PENDING","pipelineName": "${{ env.pipelineName }}"}}' --clientType 'FLUENTUI' |
| 96 | + env: |
| 97 | + VR_APP_API_URL: ${{ secrets.VR_APP_API_URL }} |
| 98 | + TENANT_ID: ${{ secrets.TenantId }} |
| 99 | + PRINCIPAL_CLIENT_ID: ${{ secrets.PrincipalClientId }} |
| 100 | + SERVICE_CONNECTION_ID: ${{ secrets.ServiceConnectionId }} |
| 101 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 102 | + |
| 103 | + # TODO: will need azure/login@v2 to be added to the workflow {@ling file://./../../workflows/pr-website-deploy-comment.yml#49} |
| 104 | + - name: Run screenshotdiff |
| 105 | + if: ${{ env.isPR == 'true' && env.vrTestSkip == 'no' }} |
| 106 | + uses: azure/cli@v2 |
| 107 | + env: |
| 108 | + # 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 |
| 109 | + # TODO: not sure how this will be used on GHA cc @evancharlton @TristanWatanabe |
| 110 | + CI_DEFINITION_ID: 205 |
| 111 | + API_TOKEN: ${{ secrets.fabric-public-pipeline-access-PAT }} |
| 112 | + GITHUB_API_TOKEN: ${{ secrets.githubRepoStatusPAT }} |
| 113 | + VR_APP_API_URL: ${{ secrets.VR_APP_API_URL }} |
| 114 | + STORAGE_ACCOUNT_ID: ${{ secrets.StorageAccountId }} |
| 115 | + TENANT_ID: ${{ secrets.TenantId }} |
| 116 | + PRINCIPAL_CLIENT_ID: ${{ secrets.PrincipalClientId }} |
| 117 | + SERVICE_CONNECTION_ID: ${{ secrets.ServiceConnectionId }} |
| 118 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 119 | + with: |
| 120 | + azcliversion: latest |
| 121 | + inlineScript: | |
| 122 | + npx [email protected] run-diff --screenshotsDirectory ./screenshots --buildType pr --clientType "FLUENTUI" --ciDefinitionId ${{ env.CI_DEFINITION_ID }} --groupName ${{ env.pipelineName }} --locationPrefix ${{ inputs.locationPrefix }} --locationPostfix ${{ inputs.locationPostfix }} --pipelineId ${{ env.pipelineId }} --clientName ${{ inputs.clientName }} --threshold '0.04' --cumThreshold '1' |
| 123 | +
|
| 124 | + # TODO: will need azure/login@v2 to be added to the workflow {@ling file://./../../workflows/pr-website-deploy-comment.yml#49} |
| 125 | + - name: Run screenshotdiff - update baseline (non PR) |
| 126 | + if: ${{ github.event_name != 'pull_request' }} |
| 127 | + uses: azure/cli@v2 |
| 128 | + env: |
| 129 | + API_TOKEN: ${{ secrets.fabric-public-pipeline-access-PAT }} |
| 130 | + GITHUB_API_TOKEN: ${{ secrets.githubRepoStatusPAT }} |
| 131 | + VR_APP_API_URL: ${{ secrets.VR_APP_API_URL }} |
| 132 | + STORAGE_ACCOUNT_ID: ${{ secrets.StorageAccountId }} |
| 133 | + TENANT_ID: ${{ secrets.TenantId }} |
| 134 | + PRINCIPAL_CLIENT_ID: ${{ secrets.PrincipalClientId }} |
| 135 | + SERVICE_CONNECTION_ID: ${{ secrets.ServiceConnectionId }} |
| 136 | + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
| 137 | + with: |
| 138 | + azcliversion: latest |
| 139 | + inlineScript: | |
| 140 | + npx [email protected] run-diff --buildType release --screenshotsDirectory ./screenshots --clientType "FLUENTUI" --locationPrefix ${{ inputs.locationPrefix }} --locationPostfix ${{ inputs.locationPostfix }} --pipelineId ${{ env.pipelineId }} |
0 commit comments