Sync eng/common directory with azure-sdk-tools for PR 17383 (#4020)

* Add package name and package version to logs.

* Pass dummy hash when no hash is provided.

* Revert "Pass dummy hash when no hash is provided."

This reverts commit 3449133ed429c799db553ea5e2a96a69aa7cc5ed.

---------

Co-authored-by: Travis Prescott <trpresco@microsoft.com>
This commit is contained in:
azure-sdk-automation[bot]andTravis Prescott authored and GitHub committed 2026-10-22 14:35:07 -06:00
1 parent b3f862be67
commit 154e3a1dda
2 files changed
+32 -9

No files matched your search

@@ -4,6 +4,7 @@ Checks whether a package is approved for release.
.DESCRIPTION
Invokes the centralized Azure SDK CLI API review release gate and fails unless its structured result approves the package.
Approval summary headings include the package name and version to distinguish packages in CI logs.
.PARAMETER PackageInfoFiles
Package-info JSON files containing the package name, version, and optional API hash.
@@ -58,25 +59,25 @@ function Write-BackendStatus([string] $Name, [object] $Status) {
}
}
function Write-ApprovalSummary([object] $Response) {
function Write-ApprovalSummary([object] $Response, [string] $PackageName, [string] $PackageVersion) {
$result = $Response.result
$source = if ($result.PSObject.Properties["finalSource"]) { $result.finalSource } else { "unknown" }
$reason = if ($result.PSObject.Properties["reason"]) { $result.reason } else { "none" }
Write-Host ""
Write-Host "Approval results"
Write-Host "Approval Results ($PackageName $PackageVersion)"
Write-Host "----------------"
if ($result.PSObject.Properties["reviewHub"]) {
Write-BackendStatus "API Review Hub" $result.reviewHub
Write-BackendStatus "API Review Hub ($PackageName $PackageVersion)" $result.reviewHub
}
if ($result.PSObject.Properties["apiView"]) {
Write-Host ""
Write-BackendStatus "APIView" $result.apiView
Write-BackendStatus "APIView ($PackageName $PackageVersion)" $result.apiView
}
$approval = if ($result.isApproved) { "APPROVED" } else { "NOT APPROVED" }
Write-Host ""
Write-Host "Overall"
Write-Host "Overall ($PackageName $PackageVersion)"
Write-Host " Status: $approval"
Write-Host " Source: $source"
Write-Host " Reason: $reason"
@@ -120,7 +121,7 @@ function Test-PackageApproval([string] $PackageName, [string] $PackageVersion, [
$null -ne $response.result -and
$response.result.PSObject.Properties["isApproved"] -and
$response.result.isApproved -is [bool]) {
Write-ApprovalSummary $response
Write-ApprovalSummary $response $PackageName $PackageVersion
}
if ($exitCode -ne 0) {
@@ -125,9 +125,31 @@ Describe "Get-PackageApprovalStatus.ps1" {
$messages = @(& $scriptPath -PackageInfoFiles $packageInfoPath 6>&1) |
ForEach-Object { "$_" }
[Array]::IndexOf($messages, "API Review Hub") | Should BeLessThan ([Array]::IndexOf($messages, "APIView"))
[Array]::IndexOf($messages, "APIView") | Should BeLessThan ([Array]::IndexOf($messages, "Overall"))
($messages -join [Environment]::NewLine) | Should Match "Overall\r?\n Status: APPROVED\r?\n Source: APIView\r?\n Reason: approved"
foreach ($heading in @("Approval Results", "API Review Hub", "APIView", "Overall")) {
@($messages | Where-Object { $_ -eq "$heading (azure-test 1.0.0)" }).Count | Should Be 1
}
[Array]::IndexOf($messages, "API Review Hub (azure-test 1.0.0)") | Should BeLessThan ([Array]::IndexOf($messages, "APIView (azure-test 1.0.0)"))
[Array]::IndexOf($messages, "APIView (azure-test 1.0.0)") | Should BeLessThan ([Array]::IndexOf($messages, "Overall (azure-test 1.0.0)"))
($messages -join [Environment]::NewLine) | Should Match "Overall \(azure-test 1\.0\.0\)\r?\n Status: APPROVED\r?\n Source: APIView\r?\n Reason: approved"
}
It "includes each package name and version in all summary headings when checking multiple packages" {
$secondPackageInfoPath = Join-Path $TestDrive "azure-other.json"
@{
Name = "azure-other"
Version = "2.0.0b1"
} | ConvertTo-Json | Set-Content $secondPackageInfoPath
$global:AzSdkOutput = '{"operation_status":"Succeeded","result":{"isApproved":true,"finalSource":"APIView","reason":"approved","reviewHub":{"isApproved":false,"reason":"repositoryNotSupported","statusCode":200},"apiView":{"isApproved":true,"reason":"approved","statusCode":200}}}'
$messages = @(& $scriptPath -PackageInfoFiles @($packageInfoPath, $secondPackageInfoPath) 6>&1) |
ForEach-Object { "$_" }
foreach ($package in @("azure-test 1.0.0", "azure-other 2.0.0b1")) {
foreach ($heading in @("Approval Results", "API Review Hub", "APIView", "Overall")) {
@($messages | Where-Object { $_ -eq "$heading ($package)" }).Count | Should Be 1
}
}
$global:CapturedAzSdkInvocations.Count | Should Be 2
}
It "includes raw output when azsdk returns malformed output" {