Skip to content

Commit cad2823

Browse files
authored
Sync eng/common directory with azure-sdk-tools for PR 1345 (Azure#13464)
* Enforce API approval status for GA and include SDK type in package properties
1 parent 36fdf0d commit cad2823

File tree

4 files changed

+79
-6
lines changed

4 files changed

+79
-6
lines changed

eng/common/pipelines/templates/steps/daily-dev-build-variable.yml

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,19 @@
11
# This script fragment is used across our repos to set a variable "SetDevVersion" which
22
# is used when this pipeline is going to be generating and publishing daily dev builds.
3-
3+
parameters:
4+
ServiceDirectory: ''
45
steps:
6+
- ${{if ne(parameters.ServiceDirectory, '')}}:
7+
- task: Powershell@2
8+
inputs:
9+
filePath: $(Build.SourcesDirectory)/eng/common/scripts/Save-Package-Properties.ps1
10+
arguments: >
11+
-ServiceDirectory ${{parameters.ServiceDirectory}}
12+
-OutDirectory $(Build.ArtifactStagingDirectory)/PackageInfo
13+
pwsh: true
14+
workingDirectory: $(Pipeline.Workspace)
15+
displayName: Dump Package properties
16+
condition: succeeded()
517
- pwsh: |
618
$setDailyDevBuild = "false"
719
if (('$(Build.Reason)' -eq 'Schedule') -and ('$(System.TeamProject)' -eq 'internal')) {

eng/common/scripts/Create-APIReview.ps1

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ function Submit-APIReview($packagename, $filePath, $uri, $apiKey, $apiLabel)
4040
try
4141
{
4242
$Response = Invoke-WebRequest -Method 'POST' -Uri $uri -Body $multipartContent -Headers $headers
43+
Write-Host "API Review: $($Response)"
4344
$StatusCode = $Response.StatusCode
4445
}
4546
catch
@@ -81,23 +82,47 @@ else
8182
}
8283

8384
$FoundFailure = $False
85+
$pkgInfoPath = Join-Path -Path $ArtifactPath "PackageInfo"
8486
foreach ($pkgName in $responses.Keys)
8587
{
8688
$respCode = $responses[$pkgName]
8789
if ($respCode -ne '200')
8890
{
89-
$FoundFailure = $True
90-
if ($respCode -eq '201')
91+
$pkgPropPath = Join-Path -Path $pkgInfoPath ($PackageName + ".json")
92+
if (-Not (Test-Path $pkgPropPath))
9193
{
92-
Write-Host "API Review is pending for package $pkgName"
94+
Write-Host " Package property file path $($pkgPropPath) is invalid."
95+
$FoundFailure = $True
9396
}
9497
else
9598
{
96-
Write-Host "Failed to create API Review for package $pkgName"
99+
$pkgInfo = Get-Content $pkgPropPath | ConvertFrom-Json
100+
$version = [AzureEngSemanticVersion]::ParseVersionString($pkgInfo.Version)
101+
if ($version.IsPrerelease)
102+
{
103+
Write-Host "Package version is not GA. Ignoring API view approval status"
104+
}
105+
elseif ($pkgInfo.SdkType -eq "client" -and $pkgInfo.IsNewSdk)
106+
{
107+
$FoundFailure = $True
108+
if ($respCode -eq '201')
109+
{
110+
Write-Error "Automatic API Review approval is pending for package $($PackageName)"
111+
}
112+
else
113+
{
114+
Write-Error "Failed to create API Review for package $($PackageName)"
115+
}
116+
}
117+
else
118+
{
119+
Write-Host "API review is not approved for package $($PackageName). Management and track1 package can be released without API review approval."
120+
}
97121
}
98122
}
99123
}
100124
if ($FoundFailure)
101125
{
102-
Write-Host "Atleast one API review is not yet approved"
126+
Write-Error "Automatic API review is not yet approved for package $($PackageName)"
127+
exit 1
103128
}

eng/common/scripts/Package-Properties.ps1

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,8 @@ class PackageProps
1010
[string]$ReadMePath
1111
[string]$ChangeLogPath
1212
[string]$Group
13+
[string]$SdkType
14+
[boolean]$IsNewSdk
1315

1416
PackageProps([string]$name, [string]$version, [string]$directoryPath, [string]$serviceDirectory)
1517
{
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
[CmdletBinding()]
2+
Param (
3+
[Parameter(Mandatory=$True)]
4+
[string] $serviceDirectory,
5+
[Parameter(Mandatory=$True)]
6+
[string] $outDirectory
7+
)
8+
9+
. (Join-Path $PSScriptRoot common.ps1)
10+
$allPackageProperties = Get-AllPkgProperties $serviceDirectory
11+
if ($allPackageProperties)
12+
{
13+
New-Item -ItemType Directory -Force -Path $outDirectory
14+
foreach($pkg in $allPackageProperties)
15+
{
16+
if ($pkg.IsNewSDK)
17+
{
18+
Write-Host "Package Name: $($pkg.Name)"
19+
Write-Host "Package Version: $($pkg.Version)"
20+
Write-Host "Package SDK Type: $($pkg.SdkType)"
21+
$outputPath = Join-Path -Path $outDirectory ($pkg.Name + ".json")
22+
$outputObject = $pkg | ConvertTo-Json
23+
Set-Content -Path $outputPath -Value $outputObject
24+
}
25+
}
26+
27+
Get-ChildItem -Path $outDirectory
28+
}
29+
else
30+
{
31+
Write-Error "Package properties are not available for service directory $($serviceDirectory)"
32+
exit 1
33+
}
34+

0 commit comments

Comments
 (0)