Skip to content

Commit e970e0b

Browse files
authored
Migrate Code-Gen pipeline from UI based to yaml (Azure#19398)
Co-authored-by: wyunchi-ms <[email protected]>
1 parent ce00802 commit e970e0b

File tree

1 file changed

+95
-0
lines changed

1 file changed

+95
-0
lines changed

.azure-pipelines/code-gen.yml

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
# Variable 'BaseBranch' was defined in the Variables tab
2+
# Variable 'BotAccessToken' was defined in the Variables tab
3+
# Variable 'ServiceName' was defined in the Variables tab
4+
# Multi-job configuration must be converted to matrix strategy: https://docs.microsoft.com/en-us/azure/devops/pipelines/process/phases?view=azure-devops&tabs=yaml#multi-job-configuration
5+
resources:
6+
repositories:
7+
- repository: self
8+
type: git
9+
ref: refs/heads/generation
10+
jobs:
11+
- job: Job_1
12+
displayName: 'Service: '
13+
timeoutInMinutes: 90
14+
pool:
15+
name: pool-windows-2019
16+
steps:
17+
- checkout: self
18+
- task: NodeTool@0
19+
displayName: Use Node 14.15.5
20+
inputs:
21+
versionSpec: 14.15.5
22+
- task: Npm@1
23+
displayName: Install autorest
24+
inputs:
25+
command: custom
26+
verbose: false
27+
customCommand: install -g autorest@latest
28+
- task: PowerShell@2
29+
displayName: Generate
30+
inputs:
31+
targetType: inline
32+
script: >-
33+
$subModuleFolders = Get-ChildItem -Directory -Filter *.Autorest
34+
35+
if ($subModuleFolders -eq $null) {
36+
autorest --max-memory-size=8192
37+
} else {
38+
$subModuleFolders | foreach-object { cd $_.FullName; autorest --max-memory-size=8192}
39+
}
40+
pwsh: true
41+
workingDirectory: src/$(ServiceName)/
42+
- task: PowerShell@2
43+
displayName: Build
44+
condition: eq(variables.ServiceSubmoduleName, '')
45+
inputs:
46+
targetType: inline
47+
script: >-
48+
$subModuleFolders = Get-ChildItem -Directory -Filter *.Autorest
49+
50+
if ($subModuleFolders -eq $null) {
51+
./build-module.ps1
52+
} else {
53+
$subModuleFolders | foreach-object { cd $_.FullName; ./build-module.ps1; cd ..}
54+
}
55+
56+
mkdir ../../artifacts/src/$env:SERVICENAME
57+
58+
cp -r ./* ../../artifacts/src/$env:SERVICENAME
59+
pwsh: true
60+
workingDirectory: src/$(ServiceName)
61+
- task: CmdLine@2
62+
displayName: Checkout main branch
63+
inputs:
64+
script: >
65+
RMDIR /Q/S src\%SERVICENAME%
66+
git checkout src\%SERVICENAME%
67+
git checkout -b codegen/%SERVICENAME% origin/%BaseBranch%
68+
- task: PowerShell@2
69+
displayName: Move code to main
70+
condition: eq(variables.ServiceSubmoduleName, '')
71+
inputs:
72+
targetType: inline
73+
script: >-
74+
#Uninstall-Module -Name PackageManagement -AllVersions
75+
Install-Module -Name PowerShellGet -RequiredVersion 2.2.3 -Force
76+
Install-Module -Name platyPS -RequiredVersion 0.14.2 -Force
77+
Install-Module -Name Az.Accounts -Force
78+
Import-Module .\tools\Gen2Master\MoveFromGeneration2Master.ps1
79+
80+
$subModuleFolders = Get-ChildItem .\artifacts\src\$env:SERVICENAME -Directory -Filter *.Autorest
81+
if ($subModuleFolders -eq $null) {
82+
Move-Generation2Master -SourcePath .\artifacts\src\$env:SERVICENAME -DestPath .\src\$env:SERVICENAME
83+
} else {
84+
Move-Generation2MasterHybrid -SourcePath .\artifacts\src\$env:SERVICENAME -DestPath .\src\$env:SERVICENAME
85+
}
86+
87+
git config user.email "[email protected]"
88+
git config user.name "azure-powershell-bot"
89+
git add ./src
90+
git add tools/CreateMappings_rules.json
91+
git commit -m "Move $env:SERVICENAME to $env:BaseBranch"
92+
git remote set-url origin https://azure-powershell-bot:$(BotAccessToken)@github.com/Azure/azure-powershell.git
93+
git push origin codegen/$env:SERVICENAME
94+
pwsh: true
95+

0 commit comments

Comments
 (0)