Skip to content

Commit 0c0bcc3

Browse files
authored
Sync back pipeline tools from generation branch. (#15386)
Co-authored-by: wyunchi-ms <[email protected]>
1 parent 743a3ca commit 0c0bcc3

File tree

9 files changed

+108
-33
lines changed

9 files changed

+108
-33
lines changed

.azure-pipelines/powershell-core.yml

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ variables:
99
TestTarget: Test
1010
Configuration: Debug
1111
DebugLocalBuildTasks: true
12+
IsGenerateBased: $[eq(variables['system.pullRequest.targetBranch'], 'generation')]
13+
BuildTimeoutInMinutes: 120
14+
AnalysisTimeoutInMinutes: 120
1215

1316
trigger: none
1417

@@ -23,6 +26,7 @@ jobs:
2326
- job: Build
2427
displayName: Build
2528
condition: succeeded()
29+
timeoutInMinutes: ${{ variables.BuildTimeoutInMinutes }}
2630
strategy:
2731
matrix:
2832
windows:
@@ -31,8 +35,8 @@ jobs:
3135
linux:
3236
OSName: ${{ variables.LinuxName }}
3337
ImageName: ${{ variables.LinuxImage }}
34-
macOS:
35-
OSName: ${{ variables.MacOSName }}
38+
macOS:
39+
OSName: ${{ variables.MacOSName }}
3640
ImageName: ${{ variables.MacOSImage }}
3741
pool:
3842
vmImage: $(ImageName)
@@ -48,7 +52,7 @@ jobs:
4852
displayName: Analyze
4953
dependsOn: Build
5054
condition: succeeded()
51-
timeoutInMinutes: 90
55+
timeoutInMinutes: ${{ variables.AnalysisTimeoutInMinutes }}
5256
strategy:
5357
matrix:
5458
windows:

.azure-pipelines/util/analyze-steps.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,21 @@ steps:
66
- template: download-build-steps.yml
77
parameters:
88
osName: ${{ parameters.osName }}
9+
- task: NodeTool@0
10+
condition: eq(variables.IsGenerateBased, true)
11+
displayName: Install autorest
12+
inputs:
13+
versionSpec: '14.17.1'
14+
command: custom
15+
verbose: false
16+
customCommand: install autorest@latest
17+
- task: PowerShell@2
18+
condition: eq(variables.IsGenerateBased, true)
19+
displayName: Setup environment for autorest
20+
inputs:
21+
targetType: inline
22+
script: "$env:NODE_OPTIONS=\"--max-old-space-size=65536\""
23+
pwsh: true
924

1025
- task: UseDotNet@2
1126
displayName: 'Use .NET Core sdk'

.azure-pipelines/util/build-steps.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,21 @@ parameters:
44
configuration: ''
55

66
steps:
7+
- task: NodeTool@0
8+
condition: eq(variables.IsGenerateBased, true)
9+
displayName: Install autorest
10+
inputs:
11+
versionSpec: '14.17.1'
12+
command: custom
13+
verbose: false
14+
customCommand: install autorest@latest
15+
- task: PowerShell@2
16+
condition: eq(variables.IsGenerateBased, true)
17+
displayName: Setup environment for autorest
18+
inputs:
19+
targetType: inline
20+
script: "$env:NODE_OPTIONS=\"--max-old-space-size=65536\""
21+
pwsh: true
722
- task: PowerShell@2
823
displayName: 'Check Ingored File'
924
inputs:

.azure-pipelines/util/test-steps.yml

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,21 @@ steps:
88
- template: download-build-steps.yml
99
parameters:
1010
osName: ${{ parameters.osName }}
11+
- task: NodeTool@0
12+
condition: eq(variables.IsGenerateBased, true)
13+
displayName: Install autorest
14+
inputs:
15+
versionSpec: '14.17.1'
16+
command: custom
17+
verbose: false
18+
customCommand: install autorest@latest
19+
- task: PowerShell@2
20+
condition: eq(variables.IsGenerateBased, true)
21+
displayName: Setup environment for autorest
22+
inputs:
23+
targetType: inline
24+
script: "$env:NODE_OPTIONS=\"--max-old-space-size=65536\""
25+
pwsh: true
1126

1227
- task: UseDotNet@2
1328
displayName: 'Use .NET Core sdk'

.azure-pipelines/windows-powershell.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ variables:
55
TestTarget: Test
66
Configuration: Debug
77
DebugLocalBuildTasks: true
8+
IsGenerateBased: $[eq(variables['system.pullRequest.targetBranch'], 'generation')]
89

910
trigger: none
1011

@@ -18,7 +19,7 @@ pr:
1819
jobs:
1920
- job: Build
2021
displayName: Build
21-
condition: succeeded()
22+
condition: and(eq(variables.IsGenerateBased, false), succeeded())
2223
pool:
2324
vmImage: ${{ variables.WindowsImage }}
2425

@@ -35,7 +36,7 @@ jobs:
3536
- job: Analyze
3637
displayName: Analyze
3738
dependsOn: Build
38-
condition: succeeded()
39+
condition: and(eq(variables.IsGenerateBased, false), succeeded())
3940
timeoutInMinutes: 90
4041
pool:
4142
vmImage: ${{ variables.WindowsImage }}
@@ -66,7 +67,7 @@ jobs:
6667
- job: Test
6768
displayName: Test
6869
dependsOn: Build
69-
condition: succeeded()
70+
condition: and(eq(variables.IsGenerateBased, false), succeeded())
7071
timeoutInMinutes: 180
7172
pool:
7273
vmImage: ${{ variables.WindowsImage }}

tools/Gen2Master/MoveFromGeneration2Master.ps1

Lines changed: 28 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Function Move-Generation2Master {
99
process {
1010
#Region Handle the hybrid module whoes folder is a subfolder of the module folder.
1111
$ModuleName = $SourcePath.Replace('/', '\').Split('\src\')[1].Split('\')[0]
12-
$SourcePsd1Path = Get-ChildItem -path $ModuleFolder -filter Az.$ModuleName.psd1 -Recurse
12+
$SourcePsd1Path = Get-ChildItem -path $SourcePath -filter Az.$ModuleName.psd1 -Recurse
1313
$FolderPathRelativeToSrc = $SourcePsd1Path.Directory.FullName.Replace('/', '\').Split('\src\')[1]
1414
if ($FolderPathRelativeToSrc -eq $ModuleName)
1515
{
@@ -23,6 +23,20 @@ Function Move-Generation2Master {
2323
If (-not ($DestPath.Trim("\").Split("\")[-1] -eq $ModuleName)) {
2424
$DestPath = Join-Path -Path $DestPath -ChildPath $FolderPathRelativeToSrc
2525
}
26+
27+
$DestParentPath = $DestPath
28+
While ("" -ne $DestParentPath)
29+
{
30+
$DestAccountsPath = Join-Path -Path $DestParentPath -ChildPath Accounts
31+
if (-not (Test-Path -Path $DestAccountsPath))
32+
{
33+
$DestParentPath = Split-Path -path $DestParentPath -Parent
34+
}
35+
else
36+
{
37+
Break
38+
}
39+
}
2640
#EndRegion
2741
If (-not (Test-Path $DestPath)) {
2842
New-Item -ItemType Directory -Path $DestPath -Force
@@ -35,13 +49,16 @@ Function Move-Generation2Master {
3549
Remove-Item -Path $DestItem -Recurse
3650
}
3751
Write-Host "Copying folder: $SourceItem." -ForegroundColor Yellow
38-
Copy-Item -Recurse -Path $SourceItem -Destination $DestItem
52+
if (Test-Path -Path $SourceItem)
53+
{
54+
Copy-Item -Recurse -Path $SourceItem -Destination $DestItem
55+
}
3956
}
4057
#Region Clean Local Modules
4158
$LocalModulesPath = Join-Path -Path (Join-Path -Path $DestPath -ChildPath 'generated') -ChildPath 'modules'
4259
If (Test-Path $LocalModulesPath) {
4360
Write-Host "Removing local modules: $LocalModulesPath." -ForegroundColor Yellow
44-
Remove-Item -Path $LocalModulesPath -Recurse
61+
Remove-Item -Path $LocalModulesPath -Recurse -Force
4562
}
4663
#EndRegion
4764
#Region copy docs
@@ -85,8 +102,7 @@ Function Move-Generation2Master {
85102
$Psd1Metadata.GUID = $ModuleGuid
86103
}
87104
If ($Null -eq $RequiredModule) {
88-
$FullDestPath = Resolve-Path -path $DestPath
89-
$AccountsModulePath = [System.IO.Path]::Combine($FullDestPath, '..', 'Accounts', 'Accounts')
105+
$AccountsModulePath = [System.IO.Path]::Combine($DestParentPath, 'Accounts', 'Accounts')
90106
$AccountsMetadata = Import-LocalizedData -BaseDirectory $AccountsModulePath -FileName "Az.Accounts.psd1"
91107
$RequiredModule = @(@{ModuleName = 'Az.Accounts'; ModuleVersion = $AccountsMetadata.ModuleVersion; })
92108
}
@@ -97,7 +113,7 @@ Function Move-Generation2Master {
97113
If ($Psd1Metadata.FunctionsToExport -Contains "*") {
98114
$Psd1Metadata.FunctionsToExport = ($Psd1Metadata.FunctionsToExport | Where-Object {$_ -ne "*"})
99115
}
100-
Update-ModuleManifest -Path (Join-Path -Path $SourcePath -ChildPath "Az.$ModuleName.psd1") @Psd1Metadata
116+
Update-ModuleManifest -Path $SourcePsd1Path @Psd1Metadata
101117
Copy-Item -Path $SourcePsd1Path -Destination $DestPsd1Path
102118
#EndRegion
103119

@@ -128,6 +144,10 @@ Function Move-Generation2Master {
128144
$generateInfo.Add("autorest", ($autorest_info[$autorest_info.count - 2]).trim())
129145
$extensions = ls ~/.autorest
130146
ForEach ($ex in $extensions) {
147+
if ($Null -eq $ex.Name)
148+
{
149+
continue
150+
}
131151
$info = $ex.Name.Split('@')
132152
$packageName = $info[1]
133153
$version = $info[2]
@@ -170,25 +190,13 @@ Function Move-Generation2Master {
170190
}
171191
Copy-Template -SourceName Changelog.md -DestPath $DestPath -DestName Changelog.md
172192
#Region create a solution file for module and add the related csproj files to this solution.
173-
dotnet new sln -n $ModuleName -o $DestPath
174-
$DestParentPath = $DestPath
175-
While ("" -eq $DestParentPath)
176-
{
177-
$DestAccountsPath = Get-ChildItem -Path $DestParentPath -Filter Accounts
178-
if ($Null -eq $DestAccountsPath)
179-
{
180-
$DestParentPath = Split-Path -path $DestParentPath -Parent
181-
}
182-
else
183-
{
184-
Break
185-
}
186-
}
193+
dotnet new sln -n $ModuleName -o $DestPath --force
187194
$SolutionPath = Join-Path -Path $DestPath -ChildPath $ModuleName.sln
188195
foreach ($DependenceCsproj in (Get-ChildItem -path $DestAccountsPath -Recurse -Filter *.csproj -Exclude *test*))
189196
{
190197
dotnet sln $SolutionPath add $DependenceCsproj
191198
}
199+
dotnet sln $SolutionPath add (Join-Path -Path $DestPath -ChildPath Az.$ModuleName.csproj)
192200
#EndRegion
193201

194202
$PropertiesPath = Join-Path -Path $DestPath -ChildPath "Properties"

tools/GenerateHelp.ps1

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Param(
1111
[string]$FilteredModules
1212
)
1313

14-
$ResourceManagerFolders = Get-ChildItem -Directory -Path "$PSScriptRoot\..\src" | Where-Object { $_.Name -ne 'lib' -and $_.Name -ne 'Package' -and $_.Name -ne 'packages' }
14+
$ResourceManagerFolders = Get-ChildItem -Directory -Path "$PSScriptRoot\..\src" | Where-Object { $_.Name -ne 'lib' -and $_.Name -ne 'Package' -and $_.Name -ne 'packages' } | Where-Object { (Get-ChildItem -Directory -Path $_ -Filter *.psd1).Count -ne 0 }
1515
Import-Module "$PSScriptRoot\HelpGeneration\HelpGeneration.psm1"
1616

1717
.($PSScriptRoot + "\PreloadToolDll.ps1")

tools/HelpGeneration/Exceptions/ValidateHelpIssues.csv

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,4 +137,6 @@ Reset-AzWebAppPublishingProfile.md,No synopsis found
137137
Reset-AzWebAppSlotPublishingProfile.md,No synopsis found
138138
Restart-AzWebAppSlot.md,No synopsis found
139139
Restore-AzWebAppBackup.md,No synopsis found
140-
Add-AzHDInsightSecurityProfile.md,No examples found
140+
Add-AzHDInsightSecurityProfile.md,No examples found
141+
Find-AzDataProtectionRestorableTimeRange.md,No synopsis found
142+
Find-AzDataProtectionRestorableTimeRange.md,No description found

tools/PrepareAutorestModule.ps1

Lines changed: 20 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ $ChangedFiles = Get-Content -Path "$PSScriptRoot\..\FilesChanged.txt"
2121

2222
$ALL_MODULE = "ALL_MODULE"
2323

24+
$SKIP_MODULES = @("Aks", "AppService", "Billing", "Compute", "ContainerInstance", "ConnectedMachine", "ContainerRegistry", "Dns", "DnsResolver", "KeyVault", "Media", "Monitor", "Network", "Resources", "ServiceBus", "Storage")
25+
2426
#Region Detect which module should be processed
2527
$ModuleSet = New-Object System.Collections.Generic.HashSet[string]
2628
foreach ($file in $ChangedFiles)
@@ -44,11 +46,11 @@ foreach ($file in $ChangedFiles)
4446
}
4547
if ($ModuleSet.Contains($ALL_MODULE))
4648
{
47-
$ModuleList = (Get-ChildItem "$PSScriptRoot\..\src\" -Directory).Name
49+
$ModuleList = (Get-ChildItem "$PSScriptRoot\..\src\" -Directory -Exclude helpers,lib).Name | Where-Object { $SKIP_MODULES -notcontains $_ }
4850
}
4951
else
5052
{
51-
$ModuleList = $ModuleSet | Where-Object { $_ }
53+
$ModuleList = $ModuleSet | Where-Object { $SKIP_MODULES -notcontains $_ }
5254
}
5355
#EndRegion
5456

@@ -65,6 +67,11 @@ git config core.sparseCheckout true
6567
Add-Content -Path .git/info/sparse-checkout -Value "src/Accounts/"
6668
git pull origin main
6769
Move-Item -Path "$TmpFolder\src\Accounts" -Destination "$TmpFolder\Accounts"
70+
Copy-Item "$TmpFolder\Accounts" "$PSScriptRoot\..\src" -Recurse -Force
71+
Remove-Item -Path "$TmpFolder\src" -Recurse -Force
72+
Install-Module Az.Accounts -Repository PSGallery -Force
73+
Import-Module Az.Accounts
74+
Copy-Item "$PSScriptRoot\..\src\*.props" $TmpFolder
6875
#EndRegion
6976

7077
#Region generate the code and make the struture same with main branch.
@@ -77,10 +84,18 @@ foreach ($Module in $ModuleList)
7784
Throw "Cannot find Az.$Module.psd1 in $ModuleFolder."
7885
}
7986
Set-Location -Path $ModuleFolder
80-
autorest
87+
try
88+
{
89+
npx autorest --max-memory-size=8192
90+
}
91+
catch
92+
{
93+
Write-Host "Generating $currentModule with m3"
94+
npx autorest --use:@autorest/powershell@2.1.401 --max-memory-size=8192
95+
}
8196
./build-module.ps1
8297
Move-Generation2Master -SourcePath "$PSScriptRoot\..\src\$Module\" -DestPath $TmpFolder
83-
Remove-Item "$ModuleFolder\*" -Recurse
98+
Remove-Item "$ModuleFolder\*" -Recurse -Force
8499
}
85100
#EndRegion
86-
Copy-Item "$TmpFolder\*" "$PSScriptRoot\..\src" -Recurse -Force
101+
Copy-Item "$TmpFolder\*" "$PSScriptRoot\..\src" -Recurse -Force

0 commit comments

Comments
 (0)