Sync eng/common directory with azure-sdk-tools for PR 1611 (#2349)

* Add API status check

* Revert temp change

* Update as per review comments

* Removed blank line

* Review comments to use az cli

* Changes to move az cli commands to caller script and other review comments

* Skip languages that's not supported in APIView

* Fix bug in language mapping

Co-authored-by: praveenkuttappan <prmarott@microsoft.com>
This commit is contained in:
Azure SDK Bot 2021-06-01 14:22:44 -04:00 committed by GitHub
parent 32944b61a7
commit dfd2933a66
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 76 additions and 0 deletions

View File

@ -0,0 +1,55 @@
function MapLanguageName($language)
{
$lang = $language
# Update language name to match those in API cosmos DB. Cosmos SQL is case sensitive and handling this within the query makes it slow.
if($lang -eq 'javascript'){
$lang = "JavaScript"
}
elseif ($lang -eq "dotnet"){
$lang = "C#"
}
elseif ($lang -eq "java"){
$lang = "Java"
}
elseif ($lang -eq "python"){
$lang = "Python"
}
else{
$lang = $null
}
return $lang
}
function Check-ApiReviewStatus($packageName, $packageVersion, $language, $url, $apiKey)
{
# Get API view URL and API Key to check status
Write-Host "Checking API review status"
$lang = MapLanguageName -language $language
if ($lang -eq $null) {
return
}
$headers = @{ "ApiKey" = $apiKey }
$body = @{
language = $lang
packageName = $packageName
packageVersion = $packageVersion
}
try
{
$response = Invoke-WebRequest $url -Method 'GET' -Headers $headers -Body $body
if ($response.StatusCode -eq '200')
{
Write-Host "API Review is approved for package $($packageName)"
}
else
{
Write-Warning "API Review is not approved for package $($packageName). Release pipeline will fail if API review is not approved."
Write-Host "You can check http://aka.ms/azsdk/engsys/apireview/faq for more details on API Approval."
}
}
catch
{
Write-Warning "Failed to check API review status for package $($PackageName). You can check http://aka.ms/azsdk/engsys/apireview/faq for more details on API Approval."
}
}

View File

@ -49,6 +49,7 @@ param(
Set-StrictMode -Version 3
. ${PSScriptRoot}\common.ps1
. ${PSScriptRoot}\Helpers\ApiView-Helpers.ps1
function Get-ReleaseDay($baseDate)
{
@ -141,6 +142,26 @@ if ($LASTEXITCODE -ne 0) {
exit 1
}
# Check API status if version is GA
if (!$newVersionParsed.IsPrerelease)
{
try
{
az account show *> $null
if (!$?) {
Write-Host 'Running az login...'
az login *> $null
}
$url = az keyvault secret show --name "APIURL" --vault-name "AzureSDKPrepRelease-KV" --query "value" --output "tsv"
$apiKey = az keyvault secret show --name "APIKEY" --vault-name "AzureSDKPrepRelease-KV" --query "value" --output "tsv"
Check-ApiReviewStatus -PackageName $packageProperties.Name -packageVersion $newVersion -Language $LanguageDisplayName -url $url -apiKey $apiKey
}
catch
{
Write-Warning "Failed to get APIView URL and API Key from Keyvault AzureSDKPrepRelease-KV. Please check and ensure you have access to this Keyvault as reader."
}
}
if ($releaseTrackingOnly)
{
Write-Host