99
1010parameters :
1111 - name : ContinueOnError
12- type : string
12+ type : boolean
1313 default : true
1414 - name : CspellConfigPath
1515 type : string
1616 default : ./.vscode/cspell.json
1717 - name : EnableCspellUpgradeVerification
1818 type : boolean
1919 default : false
20- - name : CspellUpgradePublicApiCheckoutExpression
21- type : string
22- default : /sdk/**
23- - name : CspellUpgradeArtifactDirectory
24- type : string
25- default : $(Build.ArtifactStagingDirectory)/spelling-upgrade-check
2620
2721steps :
2822 - ${{ if eq(variables['Build.Reason'], 'PullRequest') }} :
@@ -42,14 +36,15 @@ steps:
4236 # If the repo has a spell-check-public-api.ps1 script and there is a change
4337 # to the cspell package-lock.json, verify the upgrade.
4438 - pwsh : |
45- if ('true' -eq '$(Skip.SpellCheck)') {
39+ if ('true' -eq '$(Skip.SpellCheck)') {
4640 Write-Host "Spell check is skipped in this build. Skipping cspell upgrade verification."
4741 Write-Host "##vso[task.setvariable variable=RunCspellUpgradeVerification]false"
4842 exit 0
4943 }
5044 $publicApiCheckExists = Test-Path 'eng/scripts/spell-check-public-api.ps1'
5145 if (!$publicApiCheckExists) {
5246 Write-Host "Public API spell check script not found. Skipping upgrade checks."
47+ exit 0
5348 }
5449 Write-Host "Changed Files:"
5550 ./eng/common/scripts/Generate-PR-Diff.ps1 `
@@ -58,62 +53,11 @@ steps:
5853 $changedFiles = (Get-Content '$(ArtifactStagingDirectory)/diff.json' | ConvertFrom-Json).ChangedFiles
5954 Write-Host $changedFiles
6055
61- if ($changedFiles -contains 'eng/common/spelling/package-lock.json') {
62- Write-Host "Detected change to cspell package-lock.json. Setting variables to run cspell upgrade verification."
63- New-Item -ItemType Directory -Path '${{ parameters.CspellUpgradeArtifactDirectory }}' -Force | Out-Null
64- Write-Host "##vso[task.setvariable variable=RunCspellUpgradeVerification]true"
65- } else {
56+ if ($changedFiles -notcontains 'eng/common/spelling/package-lock.json') {
6657 Write-Host "No changes to cspell package-lock.json detected."
67- Write-Host "##vso[task.setvariable variable=RunCspellUpgradeVerification]false"
58+ exit 0
6859 }
69- displayName: Determine if cspell upgrade verification is needed
70-
71- # Using the checkout task interferes with the job's existing checkout.
72- # sparse-checkout.yml cannot be used here because it doesn't use runtime
73- # conditions to determine if it should run
74- - pwsh : |
75- git clone `
76- --no-checkout `
77- --filter=tree:0 `
78- --branch $(System.PullRequest.TargetBranch) `
79- $(Build.Repository.Uri) `
80- $(Pipeline.Workspace)/public-api-before
81-
82- Set-Location $(Pipeline.Workspace)/public-api-before
83- git sparse-checkout init
84- git sparse-checkout set --no-cone '/*' '!/*/' '/eng' '/.vscode' '${{ parameters.CspellUpgradePublicApiCheckoutExpression }}'
85- git checkout $(System.PullRequest.TargetBranch)
86- condition: and(succeeded(), eq(variables['RunCspellUpgradeVerification'], 'true'))
87- displayName: Sparse checkout before state of public API surface area
88-
89- - pwsh : |
90- ./eng/scripts/spell-check-public-api.ps1 > '${{ parameters.CspellUpgradeArtifactDirectory }}/spelling-after.txt'
91- Get-Content '${{ parameters.CspellUpgradeArtifactDirectory }}/spelling-after.txt'
92- condition: and(succeeded(), eq(variables['RunCspellUpgradeVerification'], 'true'))
93- displayName: Get public API spelling errors after cspell upgrade
94- # It's possible that cspell found errors, don't fail the build
95- ignoreLASTEXITCODE: true
96-
97- - pwsh : |
98- ./eng/scripts/spell-check-public-api.ps1 > '${{ parameters.CspellUpgradeArtifactDirectory }}/spelling-before.txt'
99- Get-Content '${{ parameters.CspellUpgradeArtifactDirectory }}/spelling-before.txt'
100- condition: and(succeeded(), eq(variables['RunCspellUpgradeVerification'], 'true'))
101- displayName: Get public API spelling errors before cspell upgrade
102- # It's possible that cspell found errors, don't fail the build
103- ignoreLASTEXITCODE: true
104- workingDirectory: $(Pipeline.Workspace)/public-api-before
105-
106- # On Linux the diff command exits with a nonzero exit code if there is a
107- # diff. This step will fail if there are differences.
108- - pwsh : |
109- diff --unified `
110- ${{ parameters.CspellUpgradeArtifactDirectory }}/spelling-before.txt `
111- ${{ parameters.CspellUpgradeArtifactDirectory }}/spelling-after.txt | Tee-Object -FilePath ${{ parameters.CspellUpgradeArtifactDirectory }}/spelling-diff.txt
112- condition: and(succeeded(), eq(variables['RunCspellUpgradeVerification'], 'true'))
113- displayName: Compare public API spelling errors before and after cspell upgrade
11460
115- - template : /eng/common/pipelines/templates/steps/publish-1es-artifact.yml
116- parameters :
117- ArtifactName : cspell-upgrade-check
118- ArtifactPath : ${{ parameters.CspellUpgradeArtifactDirectory }}
119- CustomCondition : and(succeededOrFailed(), eq(variables['RunCspellUpgradeVerification'], 'true'))
61+ Write-Host "Detected change to cspell package-lock.json. Running upgrade verification."
62+ ./eng/scripts/spell-check-public-api.ps1
63+ displayName: Verify cspell upgrade
0 commit comments