Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enforce API approval status for GA and include SDK type in package pr… #1345

Merged
5 commits merged into from
Jan 29, 2021
Merged
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,7 +1,18 @@
# This script fragment is used across our repos to set a variable "SetDevVersion" which
# is used when this pipeline is going to be generating and publishing daily dev builds.

parameters:
ServiceDirectory: ''
steps:
- task: Powershell@2
inputs:
filePath: $(Build.SourcesDirectory)/eng/common/scripts/Save-Package-Properties.ps1
arguments: >
-ServiceName ${{parameters.ServiceDirectory}}
praveenkuttappan marked this conversation as resolved.
Show resolved Hide resolved
-OutDirectory $(Build.ArtifactStagingDirectory)/PackageInfo
pwsh: true
workingDirectory: $(Pipeline.Workspace)
displayName: Dump Package properties
condition: succeededOrFailed()
praveenkuttappan marked this conversation as resolved.
Show resolved Hide resolved
- pwsh: |
$setDailyDevBuild = "false"
if (('$(Build.Reason)' -eq 'Schedule') -and ('$(System.TeamProject)' -eq 'internal')) {
Expand Down
35 changes: 30 additions & 5 deletions eng/common/scripts/Create-APIReview.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ function Submit-APIReview($packagename, $filePath, $uri, $apiKey, $apiLabel)
try
{
$Response = Invoke-WebRequest -Method 'POST' -Uri $uri -Body $multipartContent -Headers $headers
Write-Host "API Review: $($Response)"
$StatusCode = $Response.StatusCode
}
catch
Expand Down Expand Up @@ -81,23 +82,47 @@ else
}

$FoundFailure = $False
$pkgInfoPath = Join-Path -Path $ArtifactPath "PackageInfo"
foreach ($pkgName in $responses.Keys)
{
$respCode = $responses[$pkgName]
if ($respCode -ne '200')
{
$FoundFailure = $True
if ($respCode -eq '201')
$pkgPropPath = Join-Path -Path $pkgInfoPath ($PackageName + ".json")
if (-Not (Test-Path $pkgPropPath))
{
Write-Host "API Review is pending for package $pkgName"
Write-Host " Package property file path $($pkgPropPath) is invalid."
$FoundFailure = $True
}
else
{
Write-Host "Failed to create API Review for package $pkgName"
$pkgInfo = Get-Content $pkgPropPath | ConvertFrom-Json
$version = [AzureEngSemanticVersion]::ParseVersionString($pkgInfo.Version)
if ($version.IsPrerelease)
{
Write-Host "Package version is not GA. Ignoring API view approval status"
}
elseif ($pkgInfo.SdkType -eq "client" -and $pkgInfo.IsNewSdk)
{
$FoundFailure = $True
if ($respCode -eq '201')
{
Write-Host "API Review is pending for package $($PackageName)"
praveenkuttappan marked this conversation as resolved.
Show resolved Hide resolved
}
else
{
Write-Host "Failed to create API Review for package $($PackageName)"
}
}
else
{
Write-Host "API review is not approved for package $($PackageName). Management and track1 package can be released without API review approval."
}
}
}
}
if ($FoundFailure)
{
Write-Host "Atleast one API review is not yet approved"
Write-Host "Automatic API review is not yet approved for package $($PackageName)"
exit(1)
}
2 changes: 2 additions & 0 deletions eng/common/scripts/Package-Properties.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ class PackageProps
[string]$ReadMePath
[string]$ChangeLogPath
[string]$Group
[string]$SdkType
praveenkuttappan marked this conversation as resolved.
Show resolved Hide resolved
[boolean]$IsNewSdk

PackageProps([string]$name, [string]$version, [string]$directoryPath, [string]$serviceDirectory)
{
Expand Down
31 changes: 31 additions & 0 deletions eng/common/scripts/Save-Package-Properties.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
[CmdletBinding()]
Param (
[Parameter(Mandatory=$True)]
[string] $serviceName,
praveenkuttappan marked this conversation as resolved.
Show resolved Hide resolved
[Parameter(Mandatory=$True)]
[string] $OutDirectory
praveenkuttappan marked this conversation as resolved.
Show resolved Hide resolved
)

. (Join-Path $PSScriptRoot common.ps1)
$allPackageProperties = Get-AllPkgProperties $serviceName
if ($allPackageProperties)
{
New-Item -ItemType Directory -Force -Path $OutDirectory
foreach($pkg in $allPackageProperties)
{
Write-Host "Package Name: $($pkg.Name)"
Write-Host "Package Version: $($pkg.Version)"
Write-Host "Package SDK Type: $($pkg.SdkType)"
$outputPath = Join-Path -Path $OutDirectory ($pkg.Name + ".json")
praveenkuttappan marked this conversation as resolved.
Show resolved Hide resolved
$outputObject = $pkg | ConvertTo-Json
Set-Content -Path $outputPath -Value $outputObject
}

Get-ChildItem -Path $OutDirectory
}
else
{
Write-Host "Package properties are not available for service directory $($serviceName)"
praveenkuttappan marked this conversation as resolved.
Show resolved Hide resolved
exit(1)
weshaggard marked this conversation as resolved.
Show resolved Hide resolved
}