Skip to content

Commit

Permalink
Sync eng/common directory with azure-sdk-tools for PR 7988 (#22672)
Browse files Browse the repository at this point in the history
* Pass valid original artifact file name in request to APIView
  • Loading branch information
azure-sdk committed Apr 2, 2024
1 parent 9e78ee2 commit 53f73ad
Showing 1 changed file with 10 additions and 6 deletions.
16 changes: 10 additions & 6 deletions eng/common/scripts/Create-APIReview.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,13 @@ function Upload-SourceArtifact($filePath, $apiLabel, $releaseStatus, $packageVer
return $StatusCode
}

function Upload-ReviewTokenFile($packageName, $apiLabel, $releaseStatus, $reviewFileName, $packageVersion)
function Upload-ReviewTokenFile($packageName, $apiLabel, $releaseStatus, $reviewFileName, $packageVersion, $filePath)
{
$params = "buildId=${BuildId}&artifactName=${ArtifactName}&originalFilePath=${packageName}&reviewFilePath=${reviewFileName}"
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}"
if($MarkPackageAsShipped) {
$params += "&setReleaseTag=true"
Expand Down Expand Up @@ -135,17 +139,17 @@ function Get-APITokenFileName($packageName)
}
}

function Submit-APIReview($packageInfo, $packagePath)
function Submit-APIReview($packageInfo, $packagePath, $packageArtifactName)
{
$packageName = $packageInfo.Name
$apiLabel = "Source Branch:${SourceBranch}"

# Get generated review token file if present
# APIView processes request using different API if token file is already generated
$reviewTokenFileName = Get-APITokenFileName $packageName
$reviewTokenFileName = Get-APITokenFileName $packageArtifactName
if ($reviewTokenFileName) {
Write-Host "Uploading review token file $reviewTokenFileName to APIView."
return Upload-ReviewTokenFile $packageName $apiLabel $packageInfo.ReleaseStatus $reviewTokenFileName $packageInfo.Version
return Upload-ReviewTokenFile $packageName $apiLabel $packageInfo.ReleaseStatus $reviewTokenFileName $packageInfo.Version $packagePath
}
else {
Write-Host "Uploading $packagePath to APIView."
Expand Down Expand Up @@ -205,7 +209,7 @@ function ProcessPackage($packageName)
if ( ($SourceBranch -eq $DefaultBranch) -or (-not $version.IsPrerelease) -or $MarkPackageAsShipped)
{
Write-Host "Submitting API Review request for package $($pkg), File path: $($pkgPath)"
$respCode = Submit-APIReview $pkgInfo $pkgPath
$respCode = Submit-APIReview $pkgInfo $pkgPath $packageName
Write-Host "HTTP Response code: $($respCode)"

# no need to check API review status when marking a package as shipped
Expand Down

0 comments on commit 53f73ad

Please sign in to comment.