From d1b0be5838c3923ab5e0fa5ccb1be1c642852143 Mon Sep 17 00:00:00 2001 From: praveenkuttappan Date: Mon, 26 Jul 2021 17:41:59 -0400 Subject: [PATCH] Verify API surface level against all approved revisions for GA releases --- eng/common/scripts/Create-APIReview.ps1 | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/eng/common/scripts/Create-APIReview.ps1 b/eng/common/scripts/Create-APIReview.ps1 index 456d249c9c186..3451cf7ab66b6 100644 --- a/eng/common/scripts/Create-APIReview.ps1 +++ b/eng/common/scripts/Create-APIReview.ps1 @@ -15,7 +15,7 @@ Param ( ) # Submit API review request and return status whether current revision is approved or pending or failed to create review -function Submit-APIReview($packagename, $filePath, $uri, $apiKey, $apiLabel) +function Submit-APIReview($packagename, $filePath, $uri, $apiKey, $apiLabel, $releaseStatus) { $multipartContent = [System.Net.Http.MultipartFormDataContent]::new() $FileStream = [System.IO.FileStream]::new($filePath, [System.IO.FileMode]::Open) @@ -33,6 +33,17 @@ function Submit-APIReview($packagename, $filePath, $uri, $apiKey, $apiLabel) $StringContent = [System.Net.Http.StringContent]::new($apiLabel) $StringContent.Headers.ContentDisposition = $stringHeader $multipartContent.Add($stringContent) + Write-Host "Request param, label: $apiLabel" + + if ($releaseStatus -and ($releaseStatus -ne "Unreleased")) + { + $compareAllParam = [System.Net.Http.Headers.ContentDispositionHeaderValue]::new("form-data") + $compareAllParam.Name = "compareAllRevisions" + $compareAllParamContent = [System.Net.Http.StringContent]::new($true) + $compareAllParamContent.Headers.ContentDisposition = $compareAllParam + $multipartContent.Add($compareAllParamContent) + Write-Host "Request param, compareAllRevisions: true" + } $headers = @{ "ApiKey" = $apiKey; @@ -103,13 +114,14 @@ if ($packages) Write-Host "Version: $($version)" Write-Host "SDK Type: $($pkgInfo.SdkType)" + Write-Host "Release Status: $($pkgInfo.ReleaseStatus)" # Run create review step only if build is triggered from main branch or if version is GA. # This is to avoid invalidating review status by a build triggered from feature branch if ( ($SourceBranch -eq $DefaultBranch) -or (-not $version.IsPrerelease)) { Write-Host "Submitting API Review for package $($pkg)" - $respCode = Submit-APIReview -packagename $pkg -filePath $pkgPath -uri $APIViewUri -apiKey $APIKey -apiLabel $APILabel + $respCode = Submit-APIReview -packagename $pkg -filePath $pkgPath -uri $APIViewUri -apiKey $APIKey -apiLabel $APILabel -releaseStatus $pkgInfo.ReleaseStatus Write-Host "HTTP Response code: $($respCode)" # HTTP status 200 means API is in approved status if ($respCode -eq '200')