Skip to content

Commit 4a2df5a

Browse files
scbeddbenbp
andauthored
js - pullrequest (#31420)
This pullrequest adds a definition for an expanding and contracting build that will be used to replace all `js - <service> - ci` build definitions in the `public` devops project. This is an overall package selection change, where we find the targeted packages using `Save-Package-Properties.ps1` primarily. Analyze checks have also been updated to honor this new selection methodology, rather than the hardcoded artifactslist. Only `js - pullrequest` will actually honor the expand and contract for the packages that were changed in the PR. Meanwhile the `internal` versions of the `service`-specific definitions will still exist, still select packages for the service directory, and still be used to release as normal. `js - pullrequest` will run _alongside_ the existing builds for a short period while we identify any outstanding bugs or collection adjustments. After we're happy, we'll disable all public js builds in favor of the single `js - pullrequest` build. --------- Co-authored-by: Ben Broderick Phillips <[email protected]>
1 parent 2404c52 commit 4a2df5a

12 files changed

Lines changed: 353 additions & 84 deletions

File tree

.vscode/cspell.json

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -168,7 +168,11 @@
168168
"overrides": [
169169
{
170170
"filename": "eng/pipelines",
171-
"words": ["azuresdkartifacts", "gdnbaselines", "policheck"]
171+
"words": ["azuresdkartifacts", "gdnbaselines", "policheck", "issecret", "dlrw"]
172+
},
173+
{
174+
"filename": "eng/tools/rush-runner.js",
175+
"words": ["Jsons"]
172176
},
173177
{
174178
"filename": "sdk/apimanagement/api-management-custom-widgets-scaffolder/review/api-management-custom-widgets-scaffolder.api.md",

eng/pipelines/templates/jobs/ci.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,9 +74,16 @@ jobs:
7474
MatrixConfigs: ${{ parameters.MatrixConfigs }}
7575
MatrixFilters: ${{ parameters.MatrixFilters }}
7676
MatrixReplace: ${{ parameters.MatrixReplace }}
77+
SparseCheckoutPaths: [ "sdk/", ".vscode"]
7778
CloudConfig:
7879
Cloud: Public
7980
AdditionalParameters:
8081
ServiceDirectory: ${{ parameters.ServiceDirectory }}
8182
Artifacts: ${{ parameters.Artifacts }}
8283
TestProxy: ${{ parameters.TestProxy }}
84+
${{ if eq(parameters.ServiceDirectory, 'auto') }}:
85+
EnablePRGeneration: true
86+
PreGenerationSteps:
87+
- template: /eng/common/pipelines/templates/steps/save-package-properties.yml
88+
parameters:
89+
ServiceDirectory: ${{parameters.ServiceDirectory}}

eng/pipelines/templates/steps/analyze.yml

Lines changed: 20 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,22 @@ parameters:
44
TestPipeline: false
55

66
steps:
7+
- template: /eng/common/pipelines/templates/steps/save-package-properties.yml
8+
parameters:
9+
ServiceDirectory: ${{parameters.ServiceDirectory}}
10+
11+
- template: /eng/pipelines/templates/steps/set-artifact-packages.yml
12+
parameters:
13+
PackageInfo: $(Build.ArtifactStagingDirectory)/PackageInfo
14+
Artifacts: ${{ parameters.Artifacts }}
15+
716
- template: /eng/common/pipelines/templates/steps/check-spelling.yml
817

918
- task: PowerShell@2
1019
inputs:
1120
targetType: 'filePath'
12-
filePath: eng/scripts/spell-check-public-api.ps1
13-
arguments: -ServiceDirectory ${{ parameters.ServiceDirectory }}
21+
filePath: eng/scripts/spell-check-public-apis.ps1
22+
arguments: -ChangedServices "$(ChangedServices)"
1423
pwsh: true
1524
displayName: Spell check public API
1625

@@ -26,10 +35,9 @@ steps:
2635
ArtifactName: 'package-diffs'
2736
SbomEnabled: false
2837

29-
30-
- template: /eng/common/pipelines/templates/steps/verify-readme.yml
38+
- template: /eng/common/pipelines/templates/steps/verify-readmes.yml
3139
parameters:
32-
ScanPath: $(Build.SourcesDirectory)/sdk/${{ parameters.ServiceDirectory }}
40+
PackagePropertiesFolder: $(Build.ArtifactStagingDirectory)/PackageInfo
3341

3442
- template: /eng/common/pipelines/templates/steps/verify-path-length.yml
3543
parameters:
@@ -46,7 +54,7 @@ steps:
4654

4755
- template: /eng/common/pipelines/templates/steps/verify-samples.yml
4856
parameters:
49-
ServiceDirectory: ${{ parameters.ServiceDirectory }}
57+
ServiceDirectories: $(ChangedServicesCsv)
5058

5159
- script: |
5260
npm ci
@@ -62,28 +70,21 @@ steps:
6270
node common/scripts/install-run-rush.js install
6371
displayName: "Install dependencies"
6472
65-
- template: /eng/pipelines/templates/steps/set-artifact-packages.yml
66-
parameters:
67-
Artifacts: ${{ parameters.Artifacts }}
68-
6973
- script: |
70-
node eng/tools/rush-runner.js build "${{parameters.ServiceDirectory}}" -packages "$(ArtifactPackageNames)" --verbose -p max
74+
node eng/tools/rush-runner.js build $(ChangedServices) -packages "$(ArtifactPackageNames)" --verbose -p max
7175
displayName: "Build libraries"
7276
7377
- template: /eng/pipelines/templates/steps/run-eslint.yml
7478
parameters:
75-
ServiceDirectory: ${{ parameters.ServiceDirectory }}
79+
ServiceDirectories: $(ChangedServices)
7680

7781
- pwsh: |
78-
node eng/tools/rush-runner.js check-format "${{parameters.ServiceDirectory}}" -packages "$(ArtifactPackageNames)" --verbose
82+
node eng/tools/rush-runner.js check-format $(ChangedServices) -packages "$(ArtifactPackageNames)" --verbose
7983
displayName: "Check Format in Libraries"
8084
81-
- ${{ each artifact in parameters.Artifacts }}:
82-
- template: /eng/common/pipelines/templates/steps/verify-changelog.yml
83-
parameters:
84-
PackageName: ${{artifact.name}}
85-
ServiceName: ${{parameters.ServiceDirectory}}
86-
ForRelease: false
85+
- template: /eng/common/pipelines/templates/steps/verify-changelogs.yml
86+
parameters:
87+
PackagePropertiesFolder: $(Build.ArtifactStagingDirectory)/PackageInfo
8788

8889
- task: ms.vss-governance-buildtask.governance-build-task-component-detection.ComponentGovernanceComponentDetection@0
8990
# ComponentGovernance is currently unable to run on pull requests of public projects. Running on non-PR

eng/pipelines/templates/steps/build.yml

Lines changed: 26 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -13,32 +13,23 @@ steps:
1313

1414
- pwsh: |
1515
$folder = "${{parameters.ServiceDirectory}}"
16-
if ($folder -eq "*") { $folder = "" }
16+
if ($folder -eq "*" -or $folder -eq "auto") { $folder = "" }
1717
echo "##vso[task.setvariable variable=folder]$folder"
1818
displayName: "Set folder variable for readme links"
1919
20+
# we are not passing service directory, so we only ever set dev build to true
2021
- template: /eng/common/pipelines/templates/steps/daily-dev-build-variable.yml
21-
parameters:
22-
ServiceDirectory: ${{ parameters.ServiceDirectory }}
2322

2423
- script: |
2524
npm install ./eng/tools/versioning
26-
node eng/tools/versioning/set-dev.js --build-id "$(Build.BuildNumber)" --repo-root "$(Build.SourcesDirectory)" --service "$(folder)"
25+
node eng/tools/versioning/set-dev.js --build-id "$(Build.BuildNumber)" --repo-root "$(Build.SourcesDirectory)"
2726
node common/scripts/install-run-rush.js update
2827
condition: and(succeeded(),eq(variables['SetDevVersion'],'true'))
2928
displayName: "Update package versions for dev build"
3029
31-
- task: Powershell@2
32-
inputs:
33-
filePath: $(Build.SourcesDirectory)/eng/common/scripts/Save-Package-Properties.ps1
34-
arguments: >
35-
-ServiceDirectory ${{parameters.ServiceDirectory}}
36-
-OutDirectory $(Build.ArtifactStagingDirectory)/PackageInfo
37-
-AddDevVersion
38-
pwsh: true
39-
workingDirectory: $(Pipeline.Workspace)
40-
displayName: Update package properties with dev version
41-
condition: and(succeeded(),eq(variables['SetDevVersion'],'true'))
30+
- template: /eng/common/pipelines/templates/steps/save-package-properties.yml
31+
parameters:
32+
ServiceDirectory: ${{parameters.ServiceDirectory}}
4233

4334
- script: |
4435
node common/scripts/install-run-rush.js install
@@ -47,7 +38,9 @@ steps:
4738
4839
- template: /eng/pipelines/templates/steps/set-artifact-packages.yml
4940
parameters:
41+
PackageInfo: $(Build.ArtifactStagingDirectory)/PackageInfo
5042
Artifacts: ${{ parameters.Artifacts }}
43+
5144
- ${{ if and(eq(variables['System.TeamProject'], 'internal'), in(variables['Build.Reason'], 'IndividualCI', 'BatchedCI')) }}:
5245
- task: AzureCLI@2
5346
inputs:
@@ -60,26 +53,24 @@ steps:
6053
sasToken=$(az storage container generate-sas --account-name azuresdkartifacts --name azure-sdk-for-js-rush-cache --permissions dlrw --auth-mode login --as-user --expiry $expiry --https-only -o tsv)
6154
echo "##vso[task.setvariable variable=rushBuildCacheCred;issecret=true;]$sasToken"
6255
63-
# Option "-p max" ensures parallelism is set to the number of cores on all platforms, which improves build times.
64-
# The default on Windows is "cores - 1" (microsoft/rushstack#436).
65-
- script: |
66-
node eng/tools/rush-runner.js build "${{parameters.ServiceDirectory}}" -packages "$(ArtifactPackageNames)" --verbose -p max
56+
- pwsh: |
57+
node eng/tools/rush-runner.js build $(ChangedServices) -packages "$(ArtifactPackageNames)" --verbose -p max
6758
displayName: "Build libraries"
6859
env:
6960
${{ if and(eq(variables['System.TeamProject'], 'internal'), in(variables['Build.Reason'], 'IndividualCI', 'BatchedCI')) }}:
7061
RUSH_BUILD_CACHE_CREDENTIAL: $(rushBuildCacheCred)
7162
RUSH_BUILD_CACHE_WRITE_ALLOWED: 1
7263
7364
- script: |
74-
node eng/tools/rush-runner.js build:samples "${{parameters.ServiceDirectory}}" -packages "$(ArtifactPackageNames)" --verbose
75-
displayName: "Build samples"
65+
node eng/tools/rush-runner.js build:samples "$(ChangedServices)" -packages "$(ArtifactPackageNames)" --verbose
66+
displayName: "Build samples for PR"
7667
7768
- pwsh: |
7869
eng/tools/check-api-warning.ps1
7970
displayName: "Check api extractor output changes"
8071
8172
- script: |
82-
node eng/tools/rush-runner.js pack "${{parameters.ServiceDirectory}}" -packages "$(ArtifactPackageNames)" --verbose
73+
node eng/tools/rush-runner.js pack "$(ChangedServices)" -packages "$(ArtifactPackageNames)" --verbose
8374
displayName: "Pack libraries"
8475
8576
# Unlink node_modules folders to significantly improve performance of subsequent tasks
@@ -93,18 +84,22 @@ steps:
9384
ServiceDirectory: ${{parameters.ServiceDirectory}}
9485

9586
- pwsh: |
96-
$artifacts = '${{ convertToJson(parameters.Artifacts) }}' | ConvertFrom-Json
87+
$artifacts = Get-ChildItem -Recurse -Force "$(Build.ArtifactStagingDirectory)/PackageInfo/*.json" `
88+
| ForEach-Object { $_.Name.Replace(".json", "") }
89+
9790
foreach ($artifact in $artifacts)
9891
{
99-
$artifactName = $artifact.name
100-
Write-Host "Copying $artifactName artifacts to $(Build.ArtifactStagingDirectory)/$artifactName"
101-
New-Item -Type Directory -Name $artifactName -Path $(Build.ArtifactStagingDirectory) > $null
102-
Copy-Item sdk/${{parameters.ServiceDirectory}}/**/$artifactName-[0-9]*.[0-9]*.[0-9]*.tgz $(Build.ArtifactStagingDirectory)/$artifactName
103-
Copy-Item sdk/${{parameters.ServiceDirectory}}/**/browser/$artifactName-[0-9]*.[0-9]*.[0-9]*.zip $(Build.ArtifactStagingDirectory)/$artifactName
104-
if ($${{ parameters.IncludeRelease }} -eq $true -and $artifact.skipPublishDocMs -ne $true)
92+
$artifactDetails = Get-Content -Raw $(Build.ArtifactStagingDirectory)/PackageInfo/$artifact.json | ConvertFrom-Json
93+
94+
Write-Host "Copying $artifact artifacts to $(Build.ArtifactStagingDirectory)/$artifact"
95+
New-Item -Type Directory -Force -Name $artifact -Path $(Build.ArtifactStagingDirectory) > $null
96+
Copy-Item sdk/$($artifactDetails.Service)/**/$artifact-[0-9]*.[0-9]*.[0-9]*.tgz $(Build.ArtifactStagingDirectory)/$artifact
97+
Copy-Item sdk/$($artifactDetails.Service)/**/browser/$artifact-[0-9]*.[0-9]*.[0-9]*.zip $(Build.ArtifactStagingDirectory)/$artifact
98+
99+
if ($${{ parameters.IncludeRelease }} -eq $true -and $artifactDetails.ArtifactDetails.skipPublishDocMs -ne $true)
105100
{
106-
New-Item -Type Directory -Name documentation -Path $(Build.ArtifactStagingDirectory)/$artifactName > $null
107-
Copy-Item $(Build.SourcesDirectory)/docGen/$artifactName.zip $(Build.ArtifactStagingDirectory)/$artifactName/documentation
101+
New-Item -Type Directory -Force -Name documentation -Path $(Build.ArtifactStagingDirectory)/$artifact > $null
102+
Copy-Item $(Build.SourcesDirectory)/docGen/$artifact.zip $(Build.ArtifactStagingDirectory)/$artifact/documentation
108103
}
109104
}
110105
displayName: 'Copy Packages'

eng/pipelines/templates/steps/generate-doc.yml

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,17 @@ steps:
1515
- pwsh: |
1616
node $(Build.SourcesDirectory)/eng/tools/generate-doc/dist/index.js --serviceDir "${{parameters.ServiceDirectory}}"
1717
displayName: "Run Typedoc Docs"
18+
condition: and(succeeded(), ne(variables['Build.Reason'], 'PullRequest'))
19+
20+
- pwsh: |
21+
if ('$(ChangedServices)' -and '$(ChangedServices)' -notlike '*ChangedServices*') {
22+
foreach($service in '$(ChangedServices)'.Split(" ")) {
23+
node $(Build.SourcesDirectory)/eng/tools/generate-doc/dist/index.js --serviceDir "$service"
24+
}
25+
}
26+
displayName: "Run Typedocs for PR"
27+
condition: and(succeeded(), eq(variables['Build.Reason'], 'PullRequest'))
1828
1929
- pwsh: |
2030
$(Build.SourcesDirectory)/eng/tools/compress-subfolders.ps1 "$(Build.SourcesDirectory)/docGen" "$(Build.SourcesDirectory)/docGen"
21-
displayName: "Generate Typedoc Docs"
31+
displayName: "Compress generated docs"
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
parameters:
2-
ServiceDirectory: ''
2+
ServiceDirectories: ''
33

44
steps:
55
- script: |
@@ -8,5 +8,5 @@ steps:
88
99
- pwsh: |
1010
node common/scripts/install-run-rush.js build -t @azure/eslint-plugin-azure-sdk -t @azure/monitor-opentelemetry-exporter
11-
node eng/tools/rush-runner.js lint "${{parameters.ServiceDirectory}}" -p max
11+
node eng/tools/rush-runner.js lint "${{parameters.ServiceDirectories}}" -p max
1212
displayName: "Build ESLint Plugin and Lint Libraries"
Lines changed: 45 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,51 @@
11
parameters:
2+
PackageInfo: ''
23
Artifacts: []
34
steps:
5+
# Package-Properties folder contains the package properties for all discovered packages that were either A) affected by the PR or
6+
# B) explicitly present in the service directory. This repo splits the builds into two categories: "mgmt" and "dataplane". While
7+
# a given directory may contain both, there will be a separate build definition to release the management packages. Due to this
8+
# we need to artificially filter the packages to ensure that only the packages targeted for THAT ci.yml are built.
9+
# When we merge the PR adding js - pullrequest, this code will also merge, meaning the public - <service> - ci builds will still operate
10+
# EXACTLY the same as they did before the pipelinev3 change. This is important to ensure that we don't accidentally build the wrong packages
11+
# while in the integration period. After we disable all the public `js - <service> - ci` builds, only the `js - pullrequest` build WONT provide
12+
# an artifact list, which will allow the expand/contract. Meanwhile the internal builds will continue to provide the artifact list from their
13+
# individual ci.yml and ci.mgmt.yml files.
414
- pwsh: |
515
$artifacts = '${{ convertToJson(parameters.Artifacts) }}' | ConvertFrom-Json
6-
$packages = ""
7-
foreach ($artifact in $artifacts)
8-
{
9-
$packages += "$($artifact.name),"
16+
$knownArtifacts = @()
17+
if ($artifacts) {
18+
$knownArtifacts = $artifacts | ForEach-Object { $_.name }
1019
}
11-
echo "##vso[task.setvariable variable=ArtifactPackageNames]$packages"
12-
displayName: "Find Packages to build"
20+
21+
$packageProperties = Get-ChildItem -Recurse "${{ parameters.PackageInfo }}" *.json `
22+
| Where-Object { if($knownArtifacts) { $knownArtifacts -contains $_.Name.Replace(".json", "") } else { $true } }
23+
24+
$pkgNames = $packageProperties | ForEach-Object { $_.Name.Replace(".json", "") }
25+
26+
$setting = $pkgNames -join ","
27+
Write-Host "Setting ArtifactPackageNames to: `n$setting"
28+
Write-Host "##vso[task.setvariable variable=ArtifactPackageNames;]$setting"
29+
displayName: Resolve Targeted Packages
30+
condition: eq(variables['ArtifactPackageNames'], '')
31+
32+
- pwsh: |
33+
# set changed services given the set of changed packages, this will mean that
34+
# ChangedServices will be appropriate for the batched set of packages if that is indeed how
35+
# we set the targeted artifacts
36+
$packageProperties = Get-ChildItem -Recurse "${{ parameters.PackageInfo }}" *.json `
37+
| Foreach-Object { Get-Content -Raw -Path $_.FullName | ConvertFrom-Json }
38+
39+
$packageSet = "$(ArtifactPackageNames)" -split ","
40+
41+
$changedServicesArray = $packageProperties | Where-Object { $packageSet -contains $_.ArtifactName }
42+
| ForEach-Object { $_.ServiceDirectory } | Get-Unique
43+
44+
$changedServices = $changedServicesArray -join " "
45+
$commaChangedServices = $changedServicesArray -join ","
46+
Write-Host "##vso[task.setvariable variable=ChangedServices;]$changedServices"
47+
Write-Host "##vso[task.setvariable variable=ChangedServicesCsv;]$commaChangedServices"
48+
49+
Write-Host "This run is targeting: `n$(ArtifactPackageNames) in [$changedServices]"
50+
displayName: Resolve Targeted Packages
51+
condition: ne(variables['ArtifactPackageNames'], '')

eng/pipelines/templates/steps/test.yml

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -9,42 +9,47 @@ steps:
99
parameters:
1010
AgentImage: ${{ parameters.OSName}}
1111

12+
- template: /eng/common/pipelines/templates/steps/save-package-properties.yml
13+
parameters:
14+
ServiceDirectory: ${{parameters.ServiceDirectory}}
15+
1216
- script: |
1317
node common/scripts/install-run-rush.js install
1418
displayName: "Install dependencies"
1519
1620
- template: /eng/pipelines/templates/steps/set-artifact-packages.yml
1721
parameters:
22+
PackageInfo: $(Build.ArtifactStagingDirectory)/PackageInfo
1823
Artifacts: ${{ parameters.Artifacts }}
1924

2025
# Option "-p max" ensures parallelism is set to the number of cores on all platforms, which improves build times.
2126
# The default on Windows is "cores - 1" (microsoft/rushstack#436).
2227
- script: |
23-
node eng/tools/rush-runner.js build "${{parameters.ServiceDirectory}}" -packages "$(ArtifactPackageNames)" --verbose -p max
28+
node eng/tools/rush-runner.js build $(ChangedServices) -packages "$(ArtifactPackageNames)" --verbose -p max
2429
displayName: "Build libraries"
2530
2631
# Option "-p max" ensures parallelism is set to the number of cores on all platforms, which improves build times.
2732
# The default on Windows is "cores - 1" (microsoft/rushstack#436).
2833
- script: |
29-
node eng/tools/rush-runner.js build:test "${{parameters.ServiceDirectory}}" -packages "$(ArtifactPackageNames)" --verbose -p max
34+
node eng/tools/rush-runner.js build:test $(ChangedServices) -packages "$(ArtifactPackageNames)" --verbose -p max
3035
displayName: "Build test assets"
3136
3237
- template: ../steps/use-node-test-version.yml
3338

3439
- ${{ if eq(parameters.TestProxy, true) }}:
3540
- template: /eng/common/testproxy/test-proxy-standalone-tool.yml
36-
41+
3742
# Option "-p max" ensures parallelism is set to the number of cores on all platforms, which improves build times.
3843
# The default on Windows is "cores - 1" (microsoft/rushstack#436).
3944
- script: |
40-
node eng/tools/rush-runner.js unit-test:node "${{parameters.ServiceDirectory}}" -packages "$(ArtifactPackageNames)" --verbose -p max
45+
node eng/tools/rush-runner.js unit-test:node $(ChangedServices) -packages "$(ArtifactPackageNames)" --verbose -p max
4146
displayName: "Test libraries"
4247
condition: and(succeeded(),eq(variables['TestType'], 'node'))
4348
4449
# Option "-p max" ensures parallelism is set to the number of cores on all platforms, which improves build times.
4550
# The default on Windows is "cores - 1" (microsoft/rushstack#436).
4651
- script: |
47-
node eng/tools/rush-runner.js unit-test:browser "${{parameters.ServiceDirectory}}" -packages "$(ArtifactPackageNames)" --verbose -p max
52+
node eng/tools/rush-runner.js unit-test:browser $(ChangedServices) -packages "$(ArtifactPackageNames)" --verbose -p max
4853
displayName: "Test libraries"
4954
condition: and(succeeded(),eq(variables['TestType'], 'browser'))
5055
@@ -53,7 +58,7 @@ steps:
5358
copy $(Build.SourcesDirectory)/test-proxy.log $(Build.ArtifactStagingDirectory)
5459
displayName: 'Dump Test Proxy logs'
5560
condition: succeededOrFailed()
56-
61+
5762
# Unlink node_modules folders to significantly improve performance of subsequent tasks
5863
# which need to walk the directory tree (and are hardcoded to follow symlinks).
5964
# Retry for 30 seconds, since this command may fail with error "Another rush command is already

0 commit comments

Comments
 (0)