Skip to content

Sync eng/common directory with azure-sdk-tools for PR 10286 #41255

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
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
Original file line number Diff line number Diff line change
Expand Up @@ -24,5 +24,5 @@ steps:
-ArtifactName ${{ parameters.ArtifactName }}
-DevopsProject $(System.TeamProject)
pwsh: true
displayName: Detect API changes
displayName: Create APIView if API has changes
condition: and(${{ parameters.Condition }}, succeededOrFailed(), eq(variables['Build.Reason'],'PullRequest'))
11 changes: 10 additions & 1 deletion eng/common/scripts/Detect-Api-Changes.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,20 @@ function Submit-Request($filePath, $packageName)
}
$uri = [System.UriBuilder]$APIViewUri
$uri.query = $query.toString()

$correlationId = [System.Guid]::NewGuid().ToString()
$headers = @{
"Content-Type" = "application/json"
"x-correlation-id" = $correlationId
}
LogInfo "Request URI: $($uri.Uri.OriginalString)"
LogInfo "Correlation ID: $correlationId"
try
{
$Response = Invoke-WebRequest -Method 'GET' -Uri $uri.Uri -MaximumRetryCount 3
$Response = Invoke-WebRequest -Method 'GET' -Uri $uri.Uri -Headers $headers -MaximumRetryCount 3
$StatusCode = $Response.StatusCode
$responseContent = $Response.Content | ConvertFrom-Json | ConvertTo-Json -Depth 10
LogSuccess $responseContent
}
catch
{
Expand Down
14 changes: 11 additions & 3 deletions eng/common/scripts/Helpers/ApiView-Helpers.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -168,10 +168,16 @@ function Set-ApiViewCommentForPR {
$apiviewEndpoint = "$APIViewHost/api/pullrequests?pullRequestNumber=$PrNumber&repoName=$repoFullName&commitSHA=$HeadCommitish"
LogDebug "Get APIView information for PR using endpoint: $apiviewEndpoint"

$correlationId = [System.Guid]::NewGuid().ToString()
$headers = @{
"x-correlation-id" = $correlationId
}
LogInfo "Correlation ID: $correlationId"

$commentText = @()
$commentText += "## API Change Check"
try {
$response = Invoke-WebRequest -Uri $apiviewEndpoint -Method Get -MaximumRetryCount 3
$response = Invoke-WebRequest -Uri $apiviewEndpoint -Method Get -Headers $headers -MaximumRetryCount 3
LogInfo "OperationId: $($response.Headers['X-Operation-Id'])"
if ($response.StatusCode -ne 200) {
LogInfo "API changes are not detected in this pull request."
Expand Down Expand Up @@ -272,10 +278,12 @@ function Create-API-Review {
{
$response = Invoke-WebRequest -Method 'GET' -Uri $requestUri.Uri -Headers $headers -MaximumRetryCount 3
if ($response.StatusCode -eq 201) {
LogSuccess "Status Code: $($response.StatusCode)`nAPI review request created successfully.`n$($response.Content)"
$responseContent = $Response.Content | ConvertFrom-Json | ConvertTo-Json -Depth 10
LogSuccess "Status Code: $($response.StatusCode)`nAPI review request created successfully.`n$($responseContent)"
}
elseif ($response.StatusCode -eq 208) {
LogSuccess "Status Code: $($response.StatusCode)`nThere is no API change compared with the previous version."
$responseContent = $Response.Content | ConvertFrom-Json | ConvertTo-Json -Depth 10
LogSuccess "Status Code: $($response.StatusCode)`nThere is no API change compared with the previous version.`n$($responseContent)"
}
else {
LogError "Failed to create API review request. $($response)"
Expand Down
Loading