Skip to content

Commit 2f74a20

Browse files
APIView Creation from PR for Go
Changes in Template for testing Update go Language Settings and Detect-Api-Changes test Changes manually Update Go Analyze Step
1 parent d9d7f1b commit 2f74a20

6 files changed

Lines changed: 140 additions & 61 deletions

File tree

eng/pipelines/templates/steps/analyze.yml

Lines changed: 34 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ parameters:
55
NonShipping: false
66
LicenseCheck: true
77
IsSdkLibrary: true
8-
8+
ArtifactName: packages
99

1010
steps:
1111
- task: Powershell@2
@@ -19,6 +19,25 @@ steps:
1919
displayName: Dump Package properties
2020
condition: and(succeeded(), ${{ parameters.IsSdkLibrary }})
2121

22+
- pwsh: |
23+
. $(Build.SourcesDirectory)/eng/scripts/apiview-helpers.ps1
24+
$directoryToPublish = Join-Path -Path $(Build.ArtifactStagingDirectory) ${{ parameters.ArtifactName }}
25+
26+
New-APIViewArtifacts `
27+
-ServiceDirectory '${{ parameters.ServiceDirectory }}' `
28+
-OutputDirectory $(Build.ArtifactStagingDirectory) `
29+
-DirectoryToPublish $directoryToPublish
30+
31+
Copy-Item "$(Build.ArtifactStagingDirectory)/PackageInfo" -Destination $directoryToPublish -Recurse
32+
displayName: 'Create Go APIView Artifact'
33+
34+
- template: /eng/common/pipelines/templates/steps/publish-1es-artifact.yml
35+
parameters:
36+
ArtifactName: ${{ parameters.ArtifactName }}
37+
ArtifactPath: "$(Build.ArtifactStagingDirectory)/${{ parameters.ArtifactName }}"
38+
CustomCondition: and(succeeded(), ${{ parameters.IsSdkLibrary }})
39+
40+
# Second publish of PackageInfo to avoid breakng release pipeline, should be cleaned up once release pipeline is updated
2241
- template: /eng/common/pipelines/templates/steps/publish-1es-artifact.yml
2342
parameters:
2443
ArtifactName: "PackageInfo"
@@ -27,23 +46,24 @@ steps:
2746

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

30-
- task: Powershell@2
31-
inputs:
32-
filePath: $(Build.SourcesDirectory)/eng/scripts/Create-ApiReview.ps1
33-
arguments: >
34-
-ServiceDirectory '${{parameters.ServiceDirectory}}'
35-
-OutPath '$(Build.ArtifactStagingDirectory)'
36-
-ApiKey '$(azuresdk-apiview-apikey)'
37-
-SourceBranch '$(Build.SourceBranchName)'
38-
-DefaultBranch '$(DefaultBranch)'
39-
-ConfigFileDir '$(Build.ArtifactStagingDirectory)/PackageInfo'
40-
-BuildId $(Build.BuildId)
49+
- pwsh: |
50+
. $(Build.SourcesDirectory)/eng/scripts/apiview-helpers.ps1
51+
New-APIViewFromCI `
52+
-ServiceDirectory '${{parameters.ServiceDirectory}}' `
53+
-ArtifactPath '$(Build.ArtifactStagingDirectory)' `
54+
-ApiKey '$(azuresdk-apiview-apikey)' `
55+
-SourceBranch '$(Build.SourceBranchName)' `
56+
-DefaultBranch '$(DefaultBranch)' `
57+
-ConfigFileDir '$(Build.ArtifactStagingDirectory)/PackageInfo' `
58+
-BuildId $(Build.BuildId) `
4159
-RepoName '$(Build.Repository.Name)'
42-
pwsh: true
43-
workingDirectory: $(Pipeline.Workspace)
4460
displayName: Create API review for Go
61+
workingDirectory: $(Pipeline.Workspace)
4562
condition: and(succeeded(), ne(variables['Skip.CreateApiReview'], 'true') , ne(variables['Build.Reason'],'PullRequest'), eq(variables['System.TeamProject'], 'internal'))
4663
64+
- ${{ if eq(variables['Build.Reason'],'PullRequest') }}:
65+
- template: /eng/common/pipelines/templates/steps/detect-api-changes.yml
66+
4767
- ${{ if and(ne(variables['Skip.PackageValidation'], 'true'), eq(variables['System.TeamProject'], 'internal')) }}:
4868
- pwsh: |
4969
. ./eng/common/scripts/common.ps1

eng/scripts/Create-ApiReview.ps1

Lines changed: 0 additions & 39 deletions
This file was deleted.

eng/scripts/Language-Settings.ps1

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -101,13 +101,11 @@ function Get-AllPackageInfoFromRepo($serviceDirectory)
101101
$searchPath = Join-Path $RepoRoot "sdk"
102102
$pkgFiles = @()
103103
if ($serviceDirectory) {
104-
$searchPath = Join-Path $searchPath $serviceDirectory "go.mod"
105-
[array]$pkgFiles = @(Get-ChildItem $searchPath)
106-
} else {
107-
# If service directory is not passed in, find all modules
108-
[array]$pkgFiles = Get-ChildItem -Path $searchPath -Include "go.mod" -Recurse
104+
$searchPath = Join-Path $searchPath $serviceDirectory
109105
}
110106

107+
[array]$pkgFiles = Get-ChildItem -Path $searchPath -Include "go.mod" -Recurse
108+
111109
foreach ($pkgFile in $pkgFiles)
112110
{
113111
$modPropertes = Get-GoModuleProperties $pkgFile.DirectoryName

eng/scripts/apiview-helpers.ps1

Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
Write-Host "$PSScriptRoot"
2+
. (Join-Path $PSScriptRoot .. common scripts common.ps1)
3+
4+
<#
5+
.DESCRIPTION
6+
Create .gosource APIVIew artifact for go
7+
.PARAMETER ServiceDirectory
8+
Thee name of the ServiceDirectory
9+
.PARAMETER OutputDirectory
10+
Base output Directory path for the generated gosource artifacts
11+
.PARAMETER DirectoryToPublish
12+
Directory containing all artifacts to be publisehd to the pipeline
13+
#>
14+
function New-APIViewArtifacts {
15+
Param(
16+
[Parameter(Mandatory=$True)]
17+
[string] $ServiceDirectory,
18+
[Parameter(Mandatory=$True)]
19+
[string] $OutputDirectory,
20+
[Parameter(Mandatory=$True)]
21+
[string] $DirectoryToPublish
22+
)
23+
24+
foreach ($sdk in (Get-AllPackageInfoFromRepo $ServiceDirectory))
25+
{
26+
Write-Host "Creating API review artifact for $($sdk.Name)"
27+
$sdkDirectoryPath = Join-Path -Path $OutputDirectory $sdk.Name
28+
New-Item -ItemType Directory -Path $sdkDirectoryPath -force
29+
$fileName = Split-Path -Path $sdk.Name -Leaf
30+
$compressedArchivePath = Join-Path $sdkDirectoryPath "$fileName.zip"
31+
Compress-Archive -Path $sdk.DirectoryPath -DestinationPath $compressedArchivePath -force
32+
Rename-Item $compressedArchivePath -NewName "$fileName.gosource"
33+
34+
$artifactParentDirectory = $sdk.Name -Split "/" | Select-Object -First 1
35+
Copy-Item "$OutputDirectory/$artifactParentDirectory" -Destination "$DirectoryToPublish/$artifactParentDirectory" -Recurse
36+
}
37+
}
38+
39+
<#
40+
.DESCRIPTION
41+
Create new automatic APIView from a CI run
42+
.PARAMETER ServiceDirectory
43+
Thee name of the ServiceDirectory
44+
.PARAMETER ArtifactPath
45+
Directory containing the gosources artifact
46+
.PARAMETER ApiKey
47+
The APIview ApiKey
48+
.PARAMETER SourceBranch
49+
SourceBranch
50+
.PARAMETER DefaultBranch
51+
DefaultBranch
52+
.PARAMETER ConfigFileDir
53+
Path to the ConfigFileDir as published in the pipeline
54+
.PARAMETER RepoName
55+
The name of the repository
56+
.PARAMETER BuildId
57+
The build Id of the pipeline run
58+
.PARAMETER MarkPackageAsShipped
59+
Indicate weather to mark the package a s shipped
60+
#>
61+
function New-APIViewFromCI {
62+
Param(
63+
[Parameter(Mandatory=$True)]
64+
[string] $ServiceDirectory,
65+
[Parameter(Mandatory=$True)]
66+
[string] $ArtifactPath,
67+
[Parameter(Mandatory=$True)]
68+
[string] $ApiKey,
69+
[Parameter(Mandatory=$True)]
70+
[string] $SourceBranch,
71+
[Parameter(Mandatory=$True)]
72+
[string] $DefaultBranch,
73+
[Parameter(Mandatory=$True)]
74+
[string] $ConfigFileDir,
75+
[string] $RepoName,
76+
[string] $BuildId,
77+
[bool] $MarkPackageAsShipped = $false
78+
)
79+
$artifactList = @()
80+
81+
Get-AllPackageInfoFromRepo $ServiceDirectory | ForEach-Object {
82+
$artifactList += [PSCustomObject]@{
83+
name = $sdk.Name
84+
}
85+
}
86+
87+
$createReviewScript = (Join-Path $PSScriptRoot .. common scripts Create-APIReview.ps1)
88+
89+
Write-Host "Create Go APIView using generated artifacts"
90+
&($createReviewScript) `
91+
-ArtifactList $artifactList `
92+
-ArtifactPath $ArtifactPath `
93+
-APIKey $ApiKey `
94+
-SourceBranch $SourceBranch `
95+
-DefaultBranch $DefaultBranch `
96+
-ConfigFileDir $ConfigFileDir `
97+
-RepoName $RepoName `
98+
-BuildId $BuildId `
99+
-MarkPackageAsShipped $MarkPackageAsShipped
100+
}

sdk/template/aztemplate/internal/response_types.go

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

sdk/template/aztemplate/internal/template_client.go

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)