Skip to content

Commit f37a4c8

Browse files
azure-sdkhelen229
andauthored
update scripts (Azure#43527)
Co-authored-by: helen229 <[email protected]>
1 parent 2c429df commit f37a4c8

File tree

2 files changed

+17
-7
lines changed

2 files changed

+17
-7
lines changed

eng/common/scripts/Create-APIReview.ps1

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ Set-StrictMode -Version 3
2424
. (Join-Path $PSScriptRoot Helpers ApiView-Helpers.ps1)
2525

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

64+
$packageTypeParam = [System.Net.Http.Headers.ContentDispositionHeaderValue]::new("form-data")
65+
$packageTypeParam.Name = "packageType"
66+
$packageTypeParamContent = [System.Net.Http.StringContent]::new($packageType)
67+
$packageTypeParamContent.Headers.ContentDisposition = $packageTypeParam
68+
$multipartContent.Add($packageTypeParamContent)
69+
Write-Host "Request param, packageType: $packageType"
70+
6471
if ($releaseStatus -and ($releaseStatus -ne "Unreleased"))
6572
{
6673
$compareAllParam = [System.Net.Http.Headers.ContentDispositionHeaderValue]::new("form-data")
@@ -92,14 +99,14 @@ function Upload-SourceArtifact($filePath, $apiLabel, $releaseStatus, $packageVer
9299
return $StatusCode
93100
}
94101

95-
function Upload-ReviewTokenFile($packageName, $apiLabel, $releaseStatus, $reviewFileName, $packageVersion, $filePath)
102+
function Upload-ReviewTokenFile($packageName, $apiLabel, $releaseStatus, $reviewFileName, $packageVersion, $filePath, $packageType)
96103
{
97104
Write-Host "Original File path: $filePath"
98105
$fileName = Split-Path -Leaf $filePath
99106
Write-Host "OriginalFile name: $fileName"
100107

101108
$params = "buildId=${BuildId}&artifactName=${ArtifactName}&originalFilePath=${fileName}&reviewFilePath=${reviewFileName}"
102-
$params += "&label=${apiLabel}&repoName=${RepoName}&packageName=${packageName}&project=internal&packageVersion=${packageVersion}"
109+
$params +="&label=${apiLabel}&repoName=${RepoName}&packageName=${packageName}&project=internal&packageVersion=${packageVersion}&packageType=${packageType}"
103110
if($MarkPackageAsShipped) {
104111
$params += "&setReleaseTag=true"
105112
}
@@ -146,17 +153,18 @@ function Get-APITokenFileName($packageName)
146153
function Submit-APIReview($packageInfo, $packagePath)
147154
{
148155
$apiLabel = "Source Branch:${SourceBranch}"
156+
$packageType = $packageInfo.SdkType
149157

150158
# Get generated review token file if present
151159
# APIView processes request using different API if token file is already generated
152160
$reviewTokenFileName = Get-APITokenFileName $packageInfo.ArtifactName
153161
if ($reviewTokenFileName) {
154162
Write-Host "Uploading review token file $reviewTokenFileName to APIView."
155-
return Upload-ReviewTokenFile $packageInfo.ArtifactName $apiLabel $packageInfo.ReleaseStatus $reviewTokenFileName $packageInfo.Version $packagePath
163+
return Upload-ReviewTokenFile $packageInfo.ArtifactName $apiLabel $packageInfo.ReleaseStatus $reviewTokenFileName $packageInfo.Version $packagePath $packageType
156164
}
157165
else {
158166
Write-Host "Uploading $packagePath to APIView."
159-
return Upload-SourceArtifact $packagePath $apiLabel $packageInfo.ReleaseStatus $packageInfo.Version
167+
return Upload-SourceArtifact $packagePath $apiLabel $packageInfo.ReleaseStatus $packageInfo.Version $packageType
160168
}
161169
}
162170

eng/common/scripts/Detect-Api-Changes.ps1

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ Param (
2222
$configFileDir = Join-Path -Path $ArtifactPath "PackageInfo"
2323

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

130132
LogInfo "Processing $($pkgArtifactName)"
131133

@@ -157,7 +159,7 @@ foreach ($packageInfoFile in $packageInfoFiles)
157159
if ($isRequired -eq $True)
158160
{
159161
$filePath = $pkgPath.Replace($ArtifactPath , "").Replace("\", "/")
160-
$respCode = Submit-Request -filePath $filePath -packageName $pkgArtifactName
162+
$respCode = Submit-Request -filePath $filePath -packageName $pkgArtifactName -packageType $packageType
161163
if ($respCode -ne '200')
162164
{
163165
$responses[$pkgArtifactName] = $respCode

0 commit comments

Comments
 (0)