-
Notifications
You must be signed in to change notification settings - Fork 865
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
APIView Creation from PR for Go #24000
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -101,13 +101,11 @@ function Get-AllPackageInfoFromRepo($serviceDirectory) | |
$searchPath = Join-Path $RepoRoot "sdk" | ||
$pkgFiles = @() | ||
if ($serviceDirectory) { | ||
$searchPath = Join-Path $searchPath $serviceDirectory "go.mod" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Previous code was not doing recursive search when service directory is passed. I think Go has sub modules which contains go.mod and that's probably the reason we don't do Recurse to find package in service directory. @benbp Can you please confirm if sub module also can have go.mod? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. In most cases the go.mod is not at the service directory level, which is why old logic did not work |
||
[array]$pkgFiles = @(Get-ChildItem $searchPath) | ||
} else { | ||
# If service directory is not passed in, find all modules | ||
[array]$pkgFiles = Get-ChildItem -Path $searchPath -Include "go.mod" -Recurse | ||
$searchPath = Join-Path $searchPath $serviceDirectory | ||
} | ||
|
||
[array]$pkgFiles = Get-ChildItem -Path $searchPath -Include "go.mod" -Recurse | ||
|
||
foreach ($pkgFile in $pkgFiles) | ||
{ | ||
$modPropertes = Get-GoModuleProperties $pkgFile.DirectoryName | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
Write-Host "$PSScriptRoot" | ||
. (Join-Path $PSScriptRoot .. common scripts common.ps1) | ||
|
||
<# | ||
.DESCRIPTION | ||
Create .gosource APIVIew artifact for go | ||
.PARAMETER ServiceDirectory | ||
Thee name of the ServiceDirectory | ||
.PARAMETER OutputDirectory | ||
Base output Directory path for the generated gosource artifacts | ||
.PARAMETER DirectoryToPublish | ||
Directory containing all artifacts to be publisehd to the pipeline | ||
#> | ||
function New-APIViewArtifacts { | ||
Param( | ||
[Parameter(Mandatory=$True)] | ||
[string] $ServiceDirectory, | ||
[Parameter(Mandatory=$True)] | ||
[string] $OutputDirectory, | ||
[Parameter(Mandatory=$True)] | ||
[string] $DirectoryToPublish | ||
) | ||
|
||
foreach ($sdk in (Get-AllPackageInfoFromRepo $ServiceDirectory)) | ||
{ | ||
Write-Host "Creating API review artifact for $($sdk.Name)" | ||
$sdkDirectoryPath = Join-Path -Path $OutputDirectory $sdk.Name | ||
New-Item -ItemType Directory -Path $sdkDirectoryPath -force | ||
$fileName = Split-Path -Path $sdk.Name -Leaf | ||
$compressedArchivePath = Join-Path $sdkDirectoryPath "$fileName.zip" | ||
Compress-Archive -Path $sdk.DirectoryPath -DestinationPath $compressedArchivePath -force | ||
Rename-Item $compressedArchivePath -NewName "$fileName.gosource" | ||
|
||
$artifactParentDirectory = $sdk.Name -Split "/" | Select-Object -First 1 | ||
Copy-Item "$OutputDirectory/$artifactParentDirectory" -Destination "$DirectoryToPublish/$artifactParentDirectory" -Recurse | ||
} | ||
} | ||
|
||
<# | ||
.DESCRIPTION | ||
Create new automatic APIView from a CI run | ||
.PARAMETER ServiceDirectory | ||
Thee name of the ServiceDirectory | ||
.PARAMETER ArtifactPath | ||
Directory containing the gosources artifact | ||
.PARAMETER ApiKey | ||
The APIview ApiKey | ||
.PARAMETER SourceBranch | ||
SourceBranch | ||
.PARAMETER DefaultBranch | ||
DefaultBranch | ||
.PARAMETER ConfigFileDir | ||
Path to the ConfigFileDir as published in the pipeline | ||
.PARAMETER RepoName | ||
The name of the repository | ||
.PARAMETER BuildId | ||
The build Id of the pipeline run | ||
.PARAMETER MarkPackageAsShipped | ||
Indicate weather to mark the package a s shipped | ||
#> | ||
function New-APIViewFromCI { | ||
Param( | ||
[Parameter(Mandatory=$True)] | ||
[string] $ServiceDirectory, | ||
[Parameter(Mandatory=$True)] | ||
[string] $ArtifactPath, | ||
[Parameter(Mandatory=$True)] | ||
[string] $ApiKey, | ||
[Parameter(Mandatory=$True)] | ||
[string] $SourceBranch, | ||
[Parameter(Mandatory=$True)] | ||
[string] $DefaultBranch, | ||
[Parameter(Mandatory=$True)] | ||
[string] $ConfigFileDir, | ||
[string] $RepoName, | ||
[string] $BuildId, | ||
[bool] $MarkPackageAsShipped = $false | ||
) | ||
$artifactList = @() | ||
|
||
Get-AllPackageInfoFromRepo $ServiceDirectory | ForEach-Object { | ||
$artifactList += [PSCustomObject]@{ | ||
name = $sdk.Name | ||
} | ||
} | ||
|
||
$createReviewScript = (Join-Path $PSScriptRoot .. common scripts Create-APIReview.ps1) | ||
|
||
Write-Host "Create Go APIView using generated artifacts" | ||
&($createReviewScript) ` | ||
-ArtifactList $artifactList ` | ||
-ArtifactPath $ArtifactPath ` | ||
-APIKey $ApiKey ` | ||
-SourceBranch $SourceBranch ` | ||
-DefaultBranch $DefaultBranch ` | ||
-ConfigFileDir $ConfigFileDir ` | ||
-RepoName $RepoName ` | ||
-BuildId $BuildId ` | ||
-MarkPackageAsShipped $MarkPackageAsShipped | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't we still need old PackageInfo for other EngSys tools?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think so. All calls to it are from the $(ArtifactStagingDirectory) where it is initially created.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually, It is being downloaded in the go release job
azure-sdk-for-go/eng/pipelines/templates/jobs/archetype-go-release.yml
Line 63 in d6bd6b7
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't see it being used though. However, I have added another publish step for PackageInfo artifact.