Skip to content

Commit faaa193

Browse files
authored
[Pipeline] Update GeneratedSDK verification pipeline (Azure#23634)
* Update SDKGeneratedCodeVerify.ps1 * Update SDKGeneratedCodeVerify.ps1 * Update SDKGeneratedCodeVerify.ps1 * Update SDKGeneratedCodeVerify.ps1 * fix bug * fix bug * Update SDKGeneratedCodeVerify.ps1
1 parent 5b585ff commit faaa193

File tree

1 file changed

+24
-4
lines changed

1 file changed

+24
-4
lines changed

tools/StaticAnalysis/GeneratedSdkAnalyzer/SDKGeneratedCodeVerify.ps1

+24-4
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ $ExceptionList = @()
3030
$SavePath = $PWD
3131

3232
$MissReadMe = 9000
33+
$AutorestCSharpDetected = 9080
3334
$GenSdkChanged = 9090
3435

3536
function EnsureModuleName {
@@ -47,7 +48,8 @@ function Get-NonExceptionSdkRecord{
4748
)
4849
$exceptionPaths = "$PSScriptRoot\..\..\..\tools\StaticAnalysis\Exceptions"
4950
$errors = @()
50-
foreach($record in $records){
51+
foreach($record in $records){
52+
$needAdd = $true
5153
$exceptionPath = Join-Path -Path $exceptionPaths -ChildPath (EnsureModuleName($record.Module)) -AdditionalChildPath "GeneratedSdkIssues.csv"
5254
if(Test-Path -Path $exceptionPath){
5355
$exceptionContents = Import-Csv -Path $exceptionPath
@@ -72,7 +74,7 @@ try {
7274
# Collect Sdk paths whose files under Generated folder change.
7375
$ChangedSdks = New-Object System.Collections.Generic.List[System.Object]
7476
foreach ($_ in $FilesChanged) {
75-
$ChangedSdks.Add($_.Substring(0,$_.IndexOf('.Sdk'))+'.Sdk')
77+
$ChangedSdks.Add($_.Substring(0,$_.IndexOf('.Sdk', [System.StringComparison]::OrdinalIgnoreCase))+'.Sdk')
7678
}
7779
# Remove duplicated Sdks.
7880
$ChangedSdks = $ChangedSdks | select -unique
@@ -107,10 +109,27 @@ try {
107109
Write-Host "Using autorest powershell v4:`nRe-generating SDK under Generated folder for $ModuleName..."
108110
npx autorest
109111
}
112+
elseif ([regex]::Matches($readMeContent, '\s*csharp\s*:\s*true\s*'))
113+
{
114+
$ExceptionList += [GeneratedSdkIssue]@{
115+
Module = $ModuleName;
116+
Sdk = $_;
117+
Severity = 1;
118+
ProblemId = $AutorestCSharpDetected
119+
Description = "Do not support updating SDK using autorest csharp v3."
120+
Remediation = "Please update the Readme.md to generate code by autorest powershell v4."
121+
}
122+
}
110123
else
111124
{
112-
Write-Host "Using autorest csharp v3:`nRe-generating SDK under Generated folder for $ModuleName..."
113-
npx autorest --use:@microsoft.azure/autorest.csharp@2.3.90 --memory=16g
125+
$ExceptionList += [GeneratedSdkIssue]@{
126+
Module = $ModuleName;
127+
Sdk = $_;
128+
Severity = 1;
129+
ProblemId = $GenSdkChanged
130+
Description = "Do not find correct autorest version, please check Readme.md"
131+
Remediation = "Please determine autorest v4 in Readme file."
132+
}
114133
}
115134

116135
If (($LASTEXITCODE -ne 0) -and ($LASTEXITCODE -ne $null))
@@ -148,6 +167,7 @@ try {
148167
}
149168
}
150169

170+
151171
# See if the code is completely the same as we generated
152172
$changes = git status ".\Generated" --porcelain
153173
if ($changes -ne $null){

0 commit comments

Comments
 (0)