Skip to content
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

Enable API review gen in CI for Go #18235

Merged
merged 14 commits into from
May 26, 2022
30 changes: 30 additions & 0 deletions eng/pipelines/templates/steps/build-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,36 @@ steps:
inputs:
BuildDropPath: $(Build.ArtifactStagingDirectory)

- task: Powershell@2
inputs:
filePath: $(Build.SourcesDirectory)/eng/common/scripts/Save-Package-Properties.ps1
arguments: >
-ServiceDirectory ${{parameters.ServiceDirectory}}
-OutDirectory $(Build.ArtifactStagingDirectory)/PackageInfo
pwsh: true
workingDirectory: $(Pipeline.Workspace)
displayName: Dump Package properties
condition: succeeded()

- template: /eng/common/pipelines/templates/steps/set-default-branch.yml

- task: Powershell@2
inputs:
filePath: $(Build.SourcesDirectory)/eng/scripts/Create-ApiReview.ps1
arguments: >
-ServiceDirectory ${{parameters.ServiceDirectory}}
-OutPath $(Build.ArtifactStagingDirectory)
-ApiviewUri "$(azuresdk-apiview-uri)"
benbp marked this conversation as resolved.
Show resolved Hide resolved
-ApiKey "$(azuresdk-apiview-apikey)"
-ApiLabel "Auto Review - $(Build.SourceVersion)"
-SourceBranch $(Build.SourceBranchName)
-DefaultBranch $(DefaultBranch)
-ConfigFileDir $(Build.ArtifactStagingDirectory)/PackageInfo
pwsh: true
workingDirectory: $(Pipeline.Workspace)
displayName: Create API review for Go
condition: and(succeeded, ne(variables['Skip.CreateApiReview'], 'true') , ne(variables['Build.Reason'],'PullRequest'), eq(variables['System.TeamProject'], 'internal'))

- template: /eng/common/pipelines/templates/steps/publish-artifact.yml
parameters:
ArtifactPath: '$(Build.ArtifactStagingDirectory)/_manifest'
Expand Down
35 changes: 35 additions & 0 deletions eng/scripts/Create-ApiReview.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
Param(
[Parameter(Mandatory=$True)]
[string] $ServiceDirectory,
[Parameter(Mandatory=$True)]
[string] $OutPath,
[Parameter(Mandatory=$True)]
[string] $ApiviewUri,
[Parameter(Mandatory=$True)]
[string] $ApiKey,
[Parameter(Mandatory=$True)]
[string] $ApiLabel,
[Parameter(Mandatory=$True)]
[string] $SourceBranch,
[Parameter(Mandatory=$True)]
[string] $DefaultBranch,
[Parameter(Mandatory=$True)]
[string] $ConfigFileDir
)


Write-Host "$PSScriptRoot"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I assume this was just for debugging.

. (Join-Path $PSScriptRoot .. common scripts common.ps1)
$createReviewScript = (Join-Path $PSScriptRoot .. common scripts Create-APIReview.ps1)

foreach ($sdk in (Get-AllPackageInfoFromRepo $ServiceDirectory))
{
Write-Host "Creating API review artifact for $($sdk.Name)"
New-Item -ItemType Directory -Path $OutPath/$($sdk.Name) -force
$fileName = Split-Path -Path $sdk.Name -Leaf
Compress-Archive -Path $sdk.DirectoryPath -DestinationPath $outPath/$($sdk.Name)/$fileName -force
Rename-Item $outPath/$($sdk.Name)/$fileName.zip -NewName "$fileName.gosource"

Write-Host "Send request to APIView to create review for $($sdk.Name)"
&($createReviewScript) -ArtifactPath $outPath -APIViewUri $ApiviewUri -APIKey $ApiKey -APILabel $ApiLabel -PackageName $sdk.Name -SourceBranch $SourceBranch -DefaultBranch $DefaultBranch -ConfigFileDir $ConfigFileDir
}
14 changes: 14 additions & 0 deletions eng/scripts/Language-Settings.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -130,3 +130,17 @@ function SetPackageVersion ($PackageName, $Version, $ReleaseDate, $PackageProper
-ReleaseDate $ReleaseDate `
-ReplaceLatestEntryTitle $ReplaceLatestEntryTitle
}


function Find-Go-Artifacts-For-Apireview($ArtifactPath, $PackageName)
{
$artifact = Get-ChildItem -Path (Join-Path $ArtifactPath $PackageName) -Filter "*.gosource"
benbp marked this conversation as resolved.
Show resolved Hide resolved
if ($artifact)
{
$packages = @{
$artifact.FullName = $artifact.FullName
}
return $packages
}
return $null
}