Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
18 changes: 13 additions & 5 deletions eng/common/scripts/Create-APIReview.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ Set-StrictMode -Version 3
. (Join-Path $PSScriptRoot Helpers ApiView-Helpers.ps1)

# Submit API review request and return status whether current revision is approved or pending or failed to create review
function Upload-SourceArtifact($filePath, $apiLabel, $releaseStatus, $packageVersion)
function Upload-SourceArtifact($filePath, $apiLabel, $releaseStatus, $packageVersion, $packageType)
{
Write-Host "File path: $filePath"
$fileName = Split-Path -Leaf $filePath
Expand Down Expand Up @@ -61,6 +61,13 @@ function Upload-SourceArtifact($filePath, $apiLabel, $releaseStatus, $packageVer
$multipartContent.Add($releaseTagParamContent)
Write-Host "Request param, setReleaseTag: $MarkPackageAsShipped"

$packageTypeParam = [System.Net.Http.Headers.ContentDispositionHeaderValue]::new("form-data")
$packageTypeParam.Name = "packageType"
$packageTypeParamContent = [System.Net.Http.StringContent]::new($packageType)
$packageTypeParamContent.Headers.ContentDisposition = $packageTypeParam
$multipartContent.Add($packageTypeParamContent)
Write-Host "Request param, packageType: $packageType"

if ($releaseStatus -and ($releaseStatus -ne "Unreleased"))
{
$compareAllParam = [System.Net.Http.Headers.ContentDispositionHeaderValue]::new("form-data")
Expand Down Expand Up @@ -92,14 +99,14 @@ function Upload-SourceArtifact($filePath, $apiLabel, $releaseStatus, $packageVer
return $StatusCode
}

function Upload-ReviewTokenFile($packageName, $apiLabel, $releaseStatus, $reviewFileName, $packageVersion, $filePath)
function Upload-ReviewTokenFile($packageName, $apiLabel, $releaseStatus, $reviewFileName, $packageVersion, $filePath, $packageType)
{
Write-Host "Original File path: $filePath"
$fileName = Split-Path -Leaf $filePath
Write-Host "OriginalFile name: $fileName"

$params = "buildId=${BuildId}&artifactName=${ArtifactName}&originalFilePath=${fileName}&reviewFilePath=${reviewFileName}"
$params += "&label=${apiLabel}&repoName=${RepoName}&packageName=${packageName}&project=internal&packageVersion=${packageVersion}"
$params +="&label=${apiLabel}&repoName=${RepoName}&packageName=${packageName}&project=internal&packageVersion=${packageVersion}&packageType=${packageType}"
if($MarkPackageAsShipped) {
$params += "&setReleaseTag=true"
}
Expand Down Expand Up @@ -146,17 +153,18 @@ function Get-APITokenFileName($packageName)
function Submit-APIReview($packageInfo, $packagePath)
{
$apiLabel = "Source Branch:${SourceBranch}"
$packageType = $packageInfo.SdkType

# Get generated review token file if present
# APIView processes request using different API if token file is already generated
$reviewTokenFileName = Get-APITokenFileName $packageInfo.ArtifactName
if ($reviewTokenFileName) {
Write-Host "Uploading review token file $reviewTokenFileName to APIView."
return Upload-ReviewTokenFile $packageInfo.ArtifactName $apiLabel $packageInfo.ReleaseStatus $reviewTokenFileName $packageInfo.Version $packagePath
return Upload-ReviewTokenFile $packageInfo.ArtifactName $apiLabel $packageInfo.ReleaseStatus $reviewTokenFileName $packageInfo.Version $packagePath $packageType
}
else {
Write-Host "Uploading $packagePath to APIView."
return Upload-SourceArtifact $packagePath $apiLabel $packageInfo.ReleaseStatus $packageInfo.Version
return Upload-SourceArtifact $packagePath $apiLabel $packageInfo.ReleaseStatus $packageInfo.Version $packageType
}
}

Expand Down
6 changes: 4 additions & 2 deletions eng/common/scripts/Detect-Api-Changes.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ Param (
$configFileDir = Join-Path -Path $ArtifactPath "PackageInfo"

# Submit API review request and return status whether current revision is approved or pending or failed to create review
function Submit-Request($filePath, $packageName)
function Submit-Request($filePath, $packageName, $packageType)
{
$repoName = $RepoFullName
if (!$repoName) {
Expand All @@ -39,6 +39,7 @@ function Submit-Request($filePath, $packageName)
$query.Add('packageName', $packageName)
$query.Add('language', $LanguageShort)
$query.Add('project', $DevopsProject)
$query.Add('packageType', $packageType)
$reviewFileFullName = Join-Path -Path $ArtifactPath $packageName $reviewFileName
# If CI generates token file then it passes both token file name and original file (filePath) to APIView
# If both files are passed then APIView downloads the parent directory as a zip
Expand Down Expand Up @@ -126,6 +127,7 @@ foreach ($packageInfoFile in $packageInfoFiles)
{
$packageInfo = Get-Content $packageInfoFile | ConvertFrom-Json
$pkgArtifactName = $packageInfo.ArtifactName ?? $packageInfo.Name
$packageType = $packageInfo.SdkType

LogInfo "Processing $($pkgArtifactName)"

Expand Down Expand Up @@ -157,7 +159,7 @@ foreach ($packageInfoFile in $packageInfoFiles)
if ($isRequired -eq $True)
{
$filePath = $pkgPath.Replace($ArtifactPath , "").Replace("\", "/")
$respCode = Submit-Request -filePath $filePath -packageName $pkgArtifactName
$respCode = Submit-Request -filePath $filePath -packageName $pkgArtifactName -packageType $packageType
if ($respCode -ne '200')
{
$responses[$pkgArtifactName] = $respCode
Expand Down