Skip to content

Commit 0df371a

Browse files
authored
sync main (#28116)
2 parents fc0911d + 06618c8 commit 0df371a

File tree

3,714 files changed

+526791
-168605
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

3,714 files changed

+526791
-168605
lines changed

.azure-pipelines/PipelineSteps/BatchGeneration/analyse-modules.ps1

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,9 +82,10 @@ foreach ($moduleName in $moduleGroup) {
8282
$result.Status = "Failed"
8383
$result.Error = $_.Exception.Message
8484
} finally {
85-
$endTine = Get-Date
86-
$result.DurationSeconds = ($endTine - $startTime).TotalSeconds
85+
$endTime = Get-Date
86+
$result.DurationSeconds = ($endTime - $startTime).TotalSeconds
8787
$results += $result
88+
$result | ConvertTo-Json -Depth 5 | Write-Output
8889
}
8990
}
9091

.azure-pipelines/PipelineSteps/BatchGeneration/batch-generate-modules.ps1

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ foreach ($moduleName in $sortedModuleNames) {
113113
$moduleEndTime = Get-Date
114114
$moduleResult.DurationSeconds = ($moduleEndTime - $moduleStartTime).TotalSeconds
115115
$results += $moduleResult
116+
$moduleResult | ConvertTo-Json -Depth 5 | Write-Output
116117
}
117118

118119
$ArtifactOutputDir = Join-Path $RepoRoot "artifacts"

.azure-pipelines/PipelineSteps/BatchGeneration/build-modules.ps1

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,9 +30,10 @@ foreach ($moduleName in $moduleGroup) {
3030
$result.Status = "Failed"
3131
$result.Error = $_.Exception.Message
3232
} finally {
33-
$endTine = Get-Date
34-
$result.DurationSeconds = ($endTine - $startTime).TotalSeconds
33+
$endTime = Get-Date
34+
$result.DurationSeconds = ($endTime - $startTime).TotalSeconds
3535
$results += $result
36+
$result | ConvertTo-Json -Depth 5 | Write-Output
3637
}
3738
}
3839

.azure-pipelines/PipelineSteps/BatchGeneration/filter.ps1

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,21 @@ $artifactsDir = Join-Path $RepoRoot 'artifacts'
1515

1616
$changedModulesDict = @{}
1717
$changedSubModulesDict = @{}
18-
if ($env:RUN_TEST_ON_ALL_MODULES -eq "True") {
18+
if ($env:TEST_CHANGED_MODULES_ONLY -eq "True") {
19+
Write-Host "Run test on generated folder changed modules"
20+
# Only generated folder change should trigger the test
21+
for ($i = 0; $i -lt $ChangedFiles.Count; $i++) {
22+
if ($ChangedFiles[$i] -match '^generated/([^/]+)/([^/]+\.Autorest)/') {
23+
$moduleName = $Matches[1]
24+
$subModuleName = $Matches[2]
25+
$subModule = "$moduleName/$subModuleName"
26+
27+
$changedModulesDict[$moduleName] = $true
28+
$changedSubModulesDict[$subModule] = $true
29+
}
30+
}
31+
}
32+
else {
1933
Write-Host "Run test on all modules"
2034
$V4ModulesFile = Join-Path $artifactsDir "generationTargets.json"
2135
$V4ModuleMaps = Get-Content -Raw -Path $V4ModulesFile | ConvertFrom-Json
@@ -31,20 +45,6 @@ if ($env:RUN_TEST_ON_ALL_MODULES -eq "True") {
3145
}
3246
}
3347
}
34-
else {
35-
Write-Host "Run test on generated folder changed modules"
36-
# Only generated folder change should trigger the test
37-
for ($i = 0; $i -lt $ChangedFiles.Count; $i++) {
38-
if ($ChangedFiles[$i] -match '^generated/([^/]+)/([^/]+\.autorest)/') {
39-
$moduleName = $Matches[2]
40-
$subModuleName = $Matches[3]
41-
$subModule = "$moduleName/$subModuleName"
42-
43-
$changedModulesDict[$moduleName] = $true
44-
$changedSubModulesDict[$subModule] = $true
45-
}
46-
}
47-
}
4848

4949
$changedModules = $changedModulesDict.Keys | Sort-Object
5050
$changedSubModules = $changedSubModulesDict.Keys | Sort-Object
@@ -63,6 +63,11 @@ foreach ($subModule in $changedSubModules) {
6363
Write-Host "##[endgroup]"
6464
Write-Host
6565

66+
$changedModulesRecordFile = Join-Path $artifactsDir 'filteredChangedModules.txt'
67+
$changedModules | Set-Content -Path $changedModulesRecordFile -Encoding UTF8
68+
$changedSubModulesRecordFile = Join-Path $artifactsDir 'filteredChangedSubModules.txt'
69+
$changedSubModules | Set-Content -Path $changedSubModulesRecordFile -Encoding UTF8
70+
6671
$groupedBuildModules = Group-Modules -Modules $changedModules -MaxParallelJobs $MaxParallelBuildJobs
6772
Write-Matrix -GroupedModules $groupedBuildModules -VariableName 'buildTargets' -RepoRoot $RepoRoot
6873

.azure-pipelines/PipelineSteps/BatchGeneration/prepare.ps1

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ $utilFilePath = Join-Path $RepoRoot '.azure-pipelines' 'PipelineSteps' 'BatchGen
88
Import-Module $utilFilePath -Force
99

1010
$srcPath = Join-Path $RepoRoot 'src'
11-
$moduleMap = Get-AutorestV4ModuleMap -srcPath $srcPath
11+
$moduleMap = Get-BatchGenerationModuleMap -srcPath $srcPath
1212
Write-Host "Total matched modules: $($moduleMap.Count)"
1313

1414
$modules = @($moduleMap.Keys | Sort-Object)
@@ -34,14 +34,17 @@ foreach ($moduleGroup in $groupedModules) {
3434
$index++
3535
}
3636

37-
$generationTargetsOutputDir = Join-Path $RepoRoot "artifacts"
38-
if (-not (Test-Path -Path $generationTargetsOutputDir)) {
39-
New-Item -ItemType Directory -Path $generationTargetsOutputDir
37+
$artifactsDir = Join-Path $RepoRoot "artifacts"
38+
if (-not (Test-Path -Path $artifactsDir)) {
39+
New-Item -ItemType Directory -Path $artifactsDir
4040
}
41-
$generationTargetsOutputFile = Join-Path $generationTargetsOutputDir "generationTargets.json"
41+
$generationTargetsOutputFile = Join-Path $artifactsDir "generationTargets.json"
4242
$generationTargets | ConvertTo-Json -Depth 5 | Out-File -FilePath $generationTargetsOutputFile -Encoding utf8
4343

4444
if ($MatrixStr -and $MatrixStr.Length -gt 1) {
4545
$MatrixStr = $MatrixStr.Substring(1)
4646
}
4747
Write-Host "##vso[task.setVariable variable=generationTargets;isOutput=true]{$MatrixStr}"
48+
49+
$V4ModulesRecordFile = Join-Path $artifactsDir 'preparedV4Modules.txt'
50+
$modules | Set-Content -Path $V4ModulesRecordFile -Encoding UTF8

.azure-pipelines/PipelineSteps/BatchGeneration/test-modules.ps1

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ foreach ($subModule in $subModuleGroup) {
5656
$endTime = Get-Date
5757
$result.DurationSeconds = ($endTime - $startTime).TotalSeconds
5858
$results += $result
59+
$result | ConvertTo-Json -Depth 5 | Write-Output
5960
}
6061
}
6162

.azure-pipelines/PipelineSteps/BatchGeneration/util.psm1

Lines changed: 22 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,26 @@
1-
function Get-AutorestV4ModuleMap {
1+
function Get-BatchGenerationModuleMap {
22
param (
33
[string]$srcPath
44
)
5-
5+
$skippedModules = $env:SKIPPED_MODULES -split ',' | ForEach-Object { $_.Trim() }
66
$result = @{}
7+
$modules = Get-ChildItem -Path $srcPath -Directory
78

8-
Get-ChildItem -Path $srcPath -Directory | ForEach-Object {
9-
$module = $_
10-
11-
Get-ChildItem -Path $module.FullName -Directory | Where-Object {
9+
foreach($module in $modules) {
10+
if ($skippedModules -contains $module.Name) {
11+
Write-Warning "Skipping module: $($module.Name) as it is in the skipped modules list."
12+
continue
13+
}
14+
$subModules = Get-ChildItem -Path $module.FullName -Directory | Where-Object {
1215
$_.Name -like '*.autorest'
13-
} | ForEach-Object {
14-
$subModule = $_
15-
16+
}
17+
foreach ($subModule in $subModules) {
18+
$tspPath = Join-Path $subModule.FullName 'tsp-location.yaml'
19+
if (Test-Path $tspPath){
20+
Write-Warning "tsp-location.yaml found in $($subModule.FullName), skipping."
21+
continue
22+
}
23+
1624
$readmePath = Join-Path $subModule.FullName 'README.md'
1725

1826
if (Test-Path $readmePath) {
@@ -66,18 +74,19 @@ function Write-Matrix {
6674
[string]$RepoRoot
6775
)
6876

69-
Write-Host "$VariableName module groups: $($GroupedModules.Count)"
70-
$GroupedModules | ForEach-Object { $_ -join ', ' } | ForEach-Object { Write-Host $_ }
71-
77+
Write-Host "##[group]$VariableName module groups: $($GroupedModules.Count)"
7278
$targets = @{}
7379
$MatrixStr = ""
7480
$index = 0
7581
foreach ($modules in $GroupedModules) {
7682
$key = ($index + 1).ToString() + "-" + $modules.Count
7783
$MatrixStr = "$MatrixStr,'$key':{'MatrixKey':'$key'}"
7884
$targets[$key] = $modules
85+
$moduleNamesStr = $modules -join ', '
86+
Write-Host "$key : $moduleNamesStr"
7987
$index++
8088
}
89+
Write-Host "##[endgroup]"
8190

8291
if ($MatrixStr -and $MatrixStr.Length -gt 1) {
8392
$MatrixStr = $MatrixStr.Substring(1)
@@ -91,6 +100,7 @@ function Write-Matrix {
91100
}
92101
$targetsOutputFile = Join-Path $targetsOutputDir "$VariableName.json"
93102
$targets | ConvertTo-Json -Depth 5 | Out-File -FilePath $targetsOutputFile -Encoding utf8
103+
Write-Host
94104
}
95105

96106
function Get-Targets {

.azure-pipelines/batch-generation.yml

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
parameters:
2+
- name: TestChangedModulesOnly
3+
displayName: 'Only run tests on modules that are changed by regeneration'
4+
type: string
5+
default: 'True'
6+
17
variables:
28
IntermediateStepTimeoutInMinutes: 30
39
GenerateTimeoutInMinutes: 120
@@ -78,6 +84,8 @@ stages:
7884
script: |
7985
$prepareModulesPath = Join-Path "$(Build.SourcesDirectory)" '.azure-pipelines' 'PipelineSteps' 'BatchGeneration' 'prepare.ps1'
8086
& $prepareModulesPath -RepoRoot "$(Build.SourcesDirectory)" -MaxParallelJobs "${{ variables.MaxParallelGenerateJobs }}"
87+
env:
88+
SKIPPED_MODULES: $(SkippedModules)
8189

8290
- task: PublishPipelineArtifact@1
8391
displayName: 'Upload generated targets'
@@ -212,7 +220,7 @@ stages:
212220
-ChangedFiles $changedFiles `
213221
-RepoRoot "$(Build.SourcesDirectory)"
214222
env:
215-
RUN_TEST_ON_ALL_MODULES: $(RUN_TEST_ON_ALL_MODULES)
223+
TEST_CHANGED_MODULES_ONLY: ${{ parameters.TestChangedModulesOnly }}
216224

217225
- task: PublishPipelineArtifact@1
218226
displayName: 'Upload filtered targets'

.azure-pipelines/live-test.yml

Lines changed: 27 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@ parameters:
1313
default: ' '
1414

1515
variables:
16-
os_windows_2019: windows-2019
17-
os_windows_2022: windows-2022
16+
os_windows: windows-latest
1817
os_linux: ubuntu-latest
1918
os_macos: macOS-latest
2019
win_ps_5_1: 5.1
@@ -36,8 +35,8 @@ stages:
3635
jobs:
3736
- template: util/live-test-steps.yml
3837
parameters:
39-
name: 'win_ps_5_1_win_2019'
40-
vmImage: ${{ variables.os_windows_2019 }}
38+
name: 'ps_5_1_windows'
39+
vmImage: ${{ variables.os_windows }}
4140
osType: 'Windows'
4241
psVersion: ${{ variables.win_ps_5_1 }}
4342
dotnetVersion: ${{ variables.dotnet_sdk_8 }}
@@ -46,18 +45,8 @@ stages:
4645

4746
- template: util/live-test-steps.yml
4847
parameters:
49-
name: 'win_ps_5_1_win_2022'
50-
vmImage: ${{ variables.os_windows_2022 }}
51-
osType: 'Windows'
52-
psVersion: ${{ variables.win_ps_5_1 }}
53-
dotnetVersion: ${{ variables.dotnet_sdk_8 }}
54-
galleryName: ${{ parameters.GalleryName }}
55-
pipelineBuildId: ${{ parameters.PipelineBuildId }}
56-
57-
- template: util/live-test-steps.yml
58-
parameters:
59-
name: 'ps_7_4_x_win_2019'
60-
vmImage: ${{ variables.os_windows_2019 }}
48+
name: 'ps_7_4_x_windows'
49+
vmImage: ${{ variables.os_windows }}
6150
osType: 'Windows'
6251
psVersion: ${{ variables.ps_7_4_x }}
6352
dotnetVersion: ${{ variables.dotnet_sdk_8 }}
@@ -66,8 +55,8 @@ stages:
6655

6756
- template: util/live-test-steps.yml
6857
parameters:
69-
name: 'ps_7_5_x_win_2019'
70-
vmImage: ${{ variables.os_windows_2019 }}
58+
name: 'ps_7_5_x_windows'
59+
vmImage: ${{ variables.os_windows }}
7160
osType: 'Windows'
7261
psVersion: ${{ variables.ps_7_5_x }}
7362
dotnetVersion: ${{ variables.dotnet_sdk_9 }}
@@ -76,8 +65,8 @@ stages:
7665

7766
- template: util/live-test-steps.yml
7867
parameters:
79-
name: 'ps_latest_win_2019'
80-
vmImage: ${{ variables.os_windows_2019 }}
68+
name: 'ps_latest_windows'
69+
vmImage: ${{ variables.os_windows }}
8170
osType: 'Windows'
8271
psVersion: ${{ variables.ps_latest }}
8372
dotnetVersion: ${{ variables.dotnet_sdk_9 }}
@@ -86,88 +75,64 @@ stages:
8675

8776
- template: util/live-test-steps.yml
8877
parameters:
89-
name: 'ps_7_4_x_win_2022'
90-
vmImage: ${{ variables.os_windows_2022 }}
91-
osType: 'Windows'
78+
name: 'ps_7_4_x_linux'
79+
vmImage: ${{ variables.os_linux }}
80+
osType: 'Linux'
9281
psVersion: ${{ variables.ps_7_4_x }}
9382
dotnetVersion: ${{ variables.dotnet_sdk_8 }}
9483
galleryName: ${{ parameters.GalleryName }}
9584
pipelineBuildId: ${{ parameters.PipelineBuildId }}
9685

9786
- template: util/live-test-steps.yml
9887
parameters:
99-
name: 'ps_7_5_x_win_2022'
100-
vmImage: ${{ variables.os_windows_2022 }}
101-
osType: 'Windows'
88+
name: 'ps_7_5_x_linux'
89+
vmImage: ${{ variables.os_linux }}
90+
osType: 'Linux'
10291
psVersion: ${{ variables.ps_7_5_x }}
10392
dotnetVersion: ${{ variables.dotnet_sdk_9 }}
10493
galleryName: ${{ parameters.GalleryName }}
10594
pipelineBuildId: ${{ parameters.PipelineBuildId }}
10695

10796
- template: util/live-test-steps.yml
10897
parameters:
109-
name: 'ps_latest_win_2022'
110-
vmImage: ${{ variables.os_windows_2022 }}
111-
osType: 'Windows'
98+
name: 'ps_latest_linux'
99+
vmImage: ${{ variables.os_linux }}
100+
osType: 'Linux'
112101
psVersion: ${{ variables.ps_latest }}
113102
dotnetVersion: ${{ variables.dotnet_sdk_9 }}
114103
galleryName: ${{ parameters.GalleryName }}
115104
pipelineBuildId: ${{ parameters.PipelineBuildId }}
116105

117106
- template: util/live-test-steps.yml
118107
parameters:
119-
name: 'ps_7_4_x_linux'
120-
vmImage: ${{ variables.os_linux }}
121-
osType: 'Linux'
108+
name: 'ps_7_4_x_macos'
109+
vmImage: ${{ variables.os_macos }}
110+
osType: 'MacOS'
122111
psVersion: ${{ variables.ps_7_4_x }}
123112
dotnetVersion: ${{ variables.dotnet_sdk_8 }}
124113
galleryName: ${{ parameters.GalleryName }}
125114
pipelineBuildId: ${{ parameters.PipelineBuildId }}
126115

127116
- template: util/live-test-steps.yml
128117
parameters:
129-
name: 'ps_7_5_x_linux'
130-
vmImage: ${{ variables.os_linux }}
131-
osType: 'Linux'
118+
name: 'ps_7_5_x_macos'
119+
vmImage: ${{ variables.os_macos }}
120+
osType: 'MacOS'
132121
psVersion: ${{ variables.ps_7_5_x }}
133122
dotnetVersion: ${{ variables.dotnet_sdk_9 }}
134123
galleryName: ${{ parameters.GalleryName }}
135124
pipelineBuildId: ${{ parameters.PipelineBuildId }}
136125

137126
- template: util/live-test-steps.yml
138127
parameters:
139-
name: 'ps_latest_linux'
140-
vmImage: ${{ variables.os_linux }}
141-
osType: 'Linux'
128+
name: 'ps_latest_macos'
129+
vmImage: ${{ variables.os_macos }}
130+
osType: 'MacOS'
142131
psVersion: ${{ variables.ps_latest }}
143132
dotnetVersion: ${{ variables.dotnet_sdk_9 }}
144133
galleryName: ${{ parameters.GalleryName }}
145134
pipelineBuildId: ${{ parameters.PipelineBuildId }}
146135

147-
# - template: util/live-test-steps.yml
148-
# parameters:
149-
# name: 'ps_7_4_x_macOS'
150-
# vmImage: ${{ variables.os_macos }}
151-
# osType: 'MacOS'
152-
# psVersion: ${{ variables.ps_7_4_x }}
153-
# dotnetVersion: ${{ variables.dotnet_sdk_8 }}
154-
155-
# - template: util/live-test-steps.yml
156-
# parameters:
157-
# name: 'ps_7_5_x_macOS'
158-
# vmImage: ${{ variables.os_macos }}
159-
# osType: 'MacOS'
160-
# psVersion: ${{ variables.ps_7_5_x }}
161-
# dotnetVersion: ${{ variables.dotnet_sdk_9 }}
162-
163-
# - template: util/live-test-steps.yml
164-
# parameters:
165-
# name: 'ps_latest_macOS'
166-
# vmImage: ${{ variables.os_macos }}
167-
# osType: 'MacOS'
168-
# psVersion: ${{ variables.ps_latest }}
169-
# dotnetVersion: ${{ variables.dotnet_sdk_9 }}
170-
171136
- stage: Report
172137
displayName: Send Report
173138
condition: always()

0 commit comments

Comments
 (0)