Skip to content

Commit 5e96016

Browse files
Sync eng/common directory with azure-sdk-tools for PR 10286 (#45434)
* Remove PR commenting variable * use staging url for testing * Switch back to prod endpoint --------- Co-authored-by: Chidozie Ononiwu <chononiw@microsoft.com>
1 parent d88b976 commit 5e96016

File tree

3 files changed

+22
-5
lines changed

3 files changed

+22
-5
lines changed

eng/common/pipelines/templates/steps/detect-api-changes.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,5 +24,5 @@ steps:
2424
-ArtifactName ${{ parameters.ArtifactName }}
2525
-DevopsProject $(System.TeamProject)
2626
pwsh: true
27-
displayName: Detect API changes
27+
displayName: Create APIView if API has changes
2828
condition: and(${{ parameters.Condition }}, succeededOrFailed(), eq(variables['Build.Reason'],'PullRequest'))

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

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,20 @@ function Submit-Request($filePath, $packageName)
5555
}
5656
$uri = [System.UriBuilder]$APIViewUri
5757
$uri.query = $query.toString()
58+
59+
$correlationId = [System.Guid]::NewGuid().ToString()
60+
$headers = @{
61+
"Content-Type" = "application/json"
62+
"x-correlation-id" = $correlationId
63+
}
5864
LogInfo "Request URI: $($uri.Uri.OriginalString)"
65+
LogInfo "Correlation ID: $correlationId"
5966
try
6067
{
61-
$Response = Invoke-WebRequest -Method 'GET' -Uri $uri.Uri -MaximumRetryCount 3
68+
$Response = Invoke-WebRequest -Method 'GET' -Uri $uri.Uri -Headers $headers -MaximumRetryCount 3
6269
$StatusCode = $Response.StatusCode
70+
$responseContent = $Response.Content | ConvertFrom-Json | ConvertTo-Json -Depth 10
71+
LogSuccess $responseContent
6372
}
6473
catch
6574
{

eng/common/scripts/Helpers/ApiView-Helpers.ps1

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -168,10 +168,16 @@ function Set-ApiViewCommentForPR {
168168
$apiviewEndpoint = "$APIViewHost/api/pullrequests?pullRequestNumber=$PrNumber&repoName=$repoFullName&commitSHA=$HeadCommitish"
169169
LogDebug "Get APIView information for PR using endpoint: $apiviewEndpoint"
170170

171+
$correlationId = [System.Guid]::NewGuid().ToString()
172+
$headers = @{
173+
"x-correlation-id" = $correlationId
174+
}
175+
LogInfo "Correlation ID: $correlationId"
176+
171177
$commentText = @()
172178
$commentText += "## API Change Check"
173179
try {
174-
$response = Invoke-WebRequest -Uri $apiviewEndpoint -Method Get -MaximumRetryCount 3
180+
$response = Invoke-WebRequest -Uri $apiviewEndpoint -Method Get -Headers $headers -MaximumRetryCount 3
175181
LogInfo "OperationId: $($response.Headers['X-Operation-Id'])"
176182
if ($response.StatusCode -ne 200) {
177183
LogInfo "API changes are not detected in this pull request."
@@ -272,10 +278,12 @@ function Create-API-Review {
272278
{
273279
$response = Invoke-WebRequest -Method 'GET' -Uri $requestUri.Uri -Headers $headers -MaximumRetryCount 3
274280
if ($response.StatusCode -eq 201) {
275-
LogSuccess "Status Code: $($response.StatusCode)`nAPI review request created successfully.`n$($response.Content)"
281+
$responseContent = $Response.Content | ConvertFrom-Json | ConvertTo-Json -Depth 10
282+
LogSuccess "Status Code: $($response.StatusCode)`nAPI review request created successfully.`n$($responseContent)"
276283
}
277284
elseif ($response.StatusCode -eq 208) {
278-
LogSuccess "Status Code: $($response.StatusCode)`nThere is no API change compared with the previous version."
285+
$responseContent = $Response.Content | ConvertFrom-Json | ConvertTo-Json -Depth 10
286+
LogSuccess "Status Code: $($response.StatusCode)`nThere is no API change compared with the previous version.`n$($responseContent)"
279287
}
280288
else {
281289
LogError "Failed to create API review request. $($response)"

0 commit comments

Comments
 (0)