Skip to content

Commit 69b0093

Browse files
Sync eng/common directory with azure-sdk-tools for PR 1611 (Azure#18956)
* 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>
1 parent 5fb689e commit 69b0093

File tree

2 files changed

+76
-0
lines changed

2 files changed

+76
-0
lines changed
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
function MapLanguageName($language)
2+
{
3+
$lang = $language
4+
# Update language name to match those in API cosmos DB. Cosmos SQL is case sensitive and handling this within the query makes it slow.
5+
if($lang -eq 'javascript'){
6+
$lang = "JavaScript"
7+
}
8+
elseif ($lang -eq "dotnet"){
9+
$lang = "C#"
10+
}
11+
elseif ($lang -eq "java"){
12+
$lang = "Java"
13+
}
14+
elseif ($lang -eq "python"){
15+
$lang = "Python"
16+
}
17+
else{
18+
$lang = $null
19+
}
20+
return $lang
21+
}
22+
23+
function Check-ApiReviewStatus($packageName, $packageVersion, $language, $url, $apiKey)
24+
{
25+
# Get API view URL and API Key to check status
26+
Write-Host "Checking API review status"
27+
$lang = MapLanguageName -language $language
28+
if ($lang -eq $null) {
29+
return
30+
}
31+
$headers = @{ "ApiKey" = $apiKey }
32+
$body = @{
33+
language = $lang
34+
packageName = $packageName
35+
packageVersion = $packageVersion
36+
}
37+
38+
try
39+
{
40+
$response = Invoke-WebRequest $url -Method 'GET' -Headers $headers -Body $body
41+
if ($response.StatusCode -eq '200')
42+
{
43+
Write-Host "API Review is approved for package $($packageName)"
44+
}
45+
else
46+
{
47+
Write-Warning "API Review is not approved for package $($packageName). Release pipeline will fail if API review is not approved."
48+
Write-Host "You can check http://aka.ms/azsdk/engsys/apireview/faq for more details on API Approval."
49+
}
50+
}
51+
catch
52+
{
53+
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."
54+
}
55+
}

eng/common/scripts/Prepare-Release.ps1

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ param(
4949
Set-StrictMode -Version 3
5050

5151
. ${PSScriptRoot}\common.ps1
52+
. ${PSScriptRoot}\Helpers\ApiView-Helpers.ps1
5253

5354
function Get-ReleaseDay($baseDate)
5455
{
@@ -141,6 +142,26 @@ if ($LASTEXITCODE -ne 0) {
141142
exit 1
142143
}
143144

145+
# Check API status if version is GA
146+
if (!$newVersionParsed.IsPrerelease)
147+
{
148+
try
149+
{
150+
az account show *> $null
151+
if (!$?) {
152+
Write-Host 'Running az login...'
153+
az login *> $null
154+
}
155+
$url = az keyvault secret show --name "APIURL" --vault-name "AzureSDKPrepRelease-KV" --query "value" --output "tsv"
156+
$apiKey = az keyvault secret show --name "APIKEY" --vault-name "AzureSDKPrepRelease-KV" --query "value" --output "tsv"
157+
Check-ApiReviewStatus -PackageName $packageProperties.Name -packageVersion $newVersion -Language $LanguageDisplayName -url $url -apiKey $apiKey
158+
}
159+
catch
160+
{
161+
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."
162+
}
163+
}
164+
144165
if ($releaseTrackingOnly)
145166
{
146167
Write-Host

0 commit comments

Comments
 (0)