Skip to content

Commit

Permalink
Detect API changes using pre-generated code file by CI approach (#3735)
Browse files Browse the repository at this point in the history
Create API review from pull request using code file created by CI. APIView will use this approach instead of converting artifact to code file within server if review file name is passed as a parameter.
  • Loading branch information
praveenkuttappan authored Jul 25, 2022
1 parent 7605ead commit 7ba34eb
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions eng/common/scripts/Detect-Api-Changes.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ function Submit-Request($filePath, $packageName)
if (!$repoName) {
$repoName = "azure/azure-sdk-for-$LanguageShort"
}
$reviewFileName = "$($packageName)_$($LanguageShort).json"
$query = [System.Web.HttpUtility]::ParseQueryString('')
$query.Add('artifactName', $ArtifactName)
$query.Add('buildId', $BuildId)
Expand All @@ -35,6 +36,12 @@ function Submit-Request($filePath, $packageName)
$query.Add('repoName', $repoName)
$query.Add('pullRequestNumber', $PullRequestNumber)
$query.Add('packageName', $packageName)
$query.Add('language', $LanguageShort)
$reviewFileFullName = Join-Path -Path $ArtifactPath $packageName $reviewFileName
if (Test-Path $reviewFileFullName)
{
$query.Add('codeFile', $reviewFileName)
}
$uri = [System.UriBuilder]$APIViewUri
$uri.query = $query.toString()
Write-Host "Request URI: $($uri.Uri.OriginalString)"
Expand Down Expand Up @@ -65,7 +72,7 @@ function Should-Process-Package($pkgPath, $packageName)
# Get package info from json file created before updating version to daily dev
$pkgInfo = Get-Content $pkgPropPath | ConvertFrom-Json
$packagePath = $pkgInfo.DirectoryPath
$modifiedFiles = Get-ChangedFiles -DiffPath "$packagePath/*" -DiffFilterType ''
$modifiedFiles = @(Get-ChangedFiles -DiffPath "$packagePath/*" -DiffFilterType '')
$filteredFileCount = $modifiedFiles.Count
Write-Host "Number of modified files for package: $filteredFileCount"
return ($filteredFileCount -gt 0 -and $pkgInfo.IsNewSdk)
Expand All @@ -80,7 +87,6 @@ function Log-Input-Params()
Write-Host "Language: $($Language)"
Write-Host "Commit SHA: $($CommitSha)"
Write-Host "Repo Name: $($RepoFullName)"
Write-Host "Package Name: $($PackageName)"
}

Log-Input-Params
Expand Down

0 comments on commit 7ba34eb

Please sign in to comment.