Skip to content

Commit af5c730

Browse files
authored
Update archetype-sdk-mgmt.yml for Track1 pipeline (Azure#18164)
* Update archetype-sdk-mgmt.yml * Update archetype-sdk-mgmt.yml * Update Track1CodeCheck.ps1 * Update Track1CodeCheck.ps1
1 parent 1c234aa commit af5c730

File tree

2 files changed

+13
-35
lines changed

2 files changed

+13
-35
lines changed

eng/pipelines/templates/jobs/archetype-sdk-mgmt.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,18 @@ jobs:
99
- script: |
1010
if "$(BuildConfiguration)" == "Release" (set SkipTests=true) else (set SkipTests=false)
1111
dotnet msbuild mgmt.proj /v:m /t:CreateNugetPackage /p:Configuration=$(BuildConfiguration) /p:SkipTests=%SkipTests% /p:PackageOutputPath=$(Build.ArtifactStagingDirectory) /p:Scope=${{parameters.Scope}} /p:ForPublishing=$(ShouldPublish) $(loggingArgs) $(RPScopeArgs)"
12-
if ("$(BuildConfiguration)" NEQ "Release") (pwsh eng/scripts/Track1CodeCheck.ps1)
1312
displayName: "Build & Package"
1413
env:
1514
DOTNET_SKIP_FIRST_TIME_EXPERIENCE: 1
1615
DOTNET_CLI_TELEMETRY_OPTOUT: 1
16+
- task: PowerShell@2
17+
displayName: "Verify generated code"
18+
condition: and(succeeded(), ne(variables['System.TeamProject'],'internal'))
19+
inputs:
20+
filePath: "eng/scripts/Track1CodeCheck.ps1"
21+
pwsh: true
22+
failOnStderr: false
23+
env:
1724
REPOSITORY_NAME: $(Build.Repository.Name)
1825
PULLREQUEST_ID: $(System.PullRequest.PullRequestNumber)
1926
- task: PublishBuildArtifacts@1

eng/scripts/Track1CodeCheck.ps1

Lines changed: 5 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ try {
9494
$folderName = @()
9595
$changeList | ForEach-Object {
9696
$fileName = $_.filename
97-
if ($fileName -match 'eng/mgmt/mgmtmetadata') {
97+
if ($fileName -match '(?<!sdk)/eng/mgmt/mgmtmetadata') {
9898
$mataPath += $fileName
9999
}
100100
}
@@ -182,47 +182,18 @@ try {
182182
if ($item -notmatch 'SdkInfo_') {
183183
$exitCode ++
184184
}
185-
else {
186-
$changeContent = @()
187-
$content = git -c core.safecrlf=false diff -U0 HEAD --ignore-space-at-eol $diffResult[0]
188-
$content[4..($content.Length - 1)] | ForEach-Object {
189-
if ($_.StartsWith('+') -or $_.StartsWith('-')) {
190-
$changeContent += $_
191-
}
192-
}
193-
if ($changeContent.Length -ne 11) {
194-
$exitCode ++
195-
}
196-
197-
# metaDataContent doesn't contains 'AutoRestCmdExecuted' part since it can't be verified
198-
$metaDataContent = @('- // BEGIN: Code Generation Metadata Section',
199-
'- public static readonly String AutoRestVersion = "v2";',
200-
'- public static readonly String AutoRestBootStrapperVersion = "autorest@2.0.4413";',
201-
'- public static readonly String GithubForkName = "Azure";',
202-
'- public static readonly String GithubBranchName = "master";',
203-
'- public static readonly String GithubCommidId = "{0}";'.Replace('{0}', $commit),
204-
'- public static readonly String CodeGenerationErrors = "";',
205-
'- public static readonly String GithubRepoName = "azure-rest-api-specs";',
206-
'- // END: Code Generation Metadata Section'
207-
)
208-
foreach ($metaString in $metaDataContent) {
209-
if ($metaString -notin $changeContent) {
210-
Write-Output "Diff in" $metaString
211-
$exitCode ++
212-
break
213-
}
214-
}
215-
}
216185
}
217186

218187
if ($exitCode -ne 0) {
219188
Write-Output "Git Diff file is:"
220189
$diffResult | ForEach-Object {
221190
Write-Output $_
222191
}
223-
LogError "============================"
192+
Write-Output "Git Diff detail: "
193+
git -c core.safecrlf=false diff HEAD --ignore-space-at-eol
194+
Write-Host "============================"
224195
LogError "Discrepancy detected between generated code in PR and reference generation. Please note, the files in the Generated folder should not be modified OR adding/excluding files. You may need to re-run sdk<RP_Name>\generate.ps1."
225-
LogError "============================"
196+
Write-Host "============================"
226197
Write-Host "For reference, we are using this command for the code check: " -ForegroundColor red -BackgroundColor white
227198
Write-Host " autorest https://github.com/<Repo_Name>/azure-rest-api-specs/blob/<Commit_Id>/specification/<RP_Name>/resource-manager/readme.md --csharp --version=v2 --reflect-api-versions --csharp-sdks-folder=<SDK_Repo_Path>/sdk --use:@microsoft.azure/autorest.csharp@2.3.90" -ForegroundColor red -BackgroundColor white
228199
}

0 commit comments

Comments
 (0)