|
1 | | -Param( |
2 | | - [Parameter(Mandatory=$True)] |
3 | | - [string] $ServiceDirectory, |
4 | | - [Parameter(Mandatory=$True)] |
5 | | - [string] $OutPath, |
6 | | - [Parameter(Mandatory=$True)] |
7 | | - [string] $ApiKey, |
8 | | - [Parameter(Mandatory=$True)] |
9 | | - [string] $SourceBranch, |
10 | | - [Parameter(Mandatory=$True)] |
11 | | - [string] $DefaultBranch, |
12 | | - [Parameter(Mandatory=$True)] |
13 | | - [string] $ConfigFileDir, |
14 | | - [string] $RepoName, |
15 | | - [string] $BuildId, |
16 | | - [bool] $MarkPackageAsShipped = $false |
17 | | -) |
18 | | - |
19 | | - |
20 | 1 | Write-Host "$PSScriptRoot" |
21 | 2 | . (Join-Path $PSScriptRoot .. common scripts common.ps1) |
22 | | -$createReviewScript = (Join-Path $PSScriptRoot .. common scripts Create-APIReview.ps1) |
23 | | - |
24 | | -$artifactList = @() |
25 | | -foreach ($sdk in (Get-AllPackageInfoFromRepo $ServiceDirectory)) |
26 | | -{ |
27 | | - Write-Host "Creating API review artifact for $($sdk.Name)" |
28 | | - New-Item -ItemType Directory -Path $OutPath/$($sdk.Name) -force |
29 | | - $fileName = Split-Path -Path $sdk.Name -Leaf |
30 | | - Compress-Archive -Path $sdk.DirectoryPath -DestinationPath $outPath/$($sdk.Name)/$fileName -force |
31 | | - Rename-Item $outPath/$($sdk.Name)/$fileName.zip -NewName "$fileName.gosource" |
32 | | - |
33 | | - $artifactList += [PSCustomObject]@{ |
34 | | - name = $sdk.Name |
| 3 | + |
| 4 | +<# |
| 5 | +.DESCRIPTION |
| 6 | + Create .gosource APIVIew artifact for go |
| 7 | +.PARAMETER ServiceDirectory |
| 8 | + Thee name of the ServiceDirectory |
| 9 | +.PARAMETER ArtifactOutputDirectory |
| 10 | + Base output Directory path for the generated gosource artifacts |
| 11 | +.PARAMETER ArtifactName |
| 12 | + Name of the group of artifacts to be created |
| 13 | +#> |
| 14 | +function Create-APIViewArtifact { |
| 15 | + Param( |
| 16 | + [Parameter(Mandatory=$True)] |
| 17 | + [string] $ServiceDirectory, |
| 18 | + [Parameter(Mandatory=$True)] |
| 19 | + [string] $ArtifactOutputDirectory, |
| 20 | + [Parameter(Mandatory=$True)] |
| 21 | + [string] $ArtifactName |
| 22 | + ) |
| 23 | + |
| 24 | + $artifactList = @() |
| 25 | + |
| 26 | + $artifactsDirectoryPath = Join-Path -Path $ArtifactOutputDirectory $ArtifactName |
| 27 | + New-Item -ItemType Directory -Path $artifactsDirectoryPath -force |
| 28 | + |
| 29 | + foreach ($sdk in (Get-AllPackageInfoFromRepo $ServiceDirectory)) |
| 30 | + { |
| 31 | + Write-Host "Creating API review artifact for $($sdk.Name)" |
| 32 | + New-Item -ItemType Directory -Path $artifactsDirectoryPath/$($sdk.Name) -force |
| 33 | + $fileName = Split-Path -Path $sdk.Name -Leaf |
| 34 | + Compress-Archive -Path $sdk.DirectoryPath -DestinationPath $artifactsDirectoryPath/$($sdk.Name)/$fileName -force |
| 35 | + Rename-Item $artifactsDirectoryPath/$($sdk.Name)/$fileName.zip -NewName "$fileName.gosource" |
| 36 | + |
| 37 | + $artifactList += [PSCustomObject]@{ |
| 38 | + name = $sdk.Name |
| 39 | + } |
35 | 40 | } |
| 41 | + return $artifactList |
36 | 42 | } |
37 | 43 |
|
38 | | -Write-Host "Create Go APIView using generated artifacts" |
39 | | -&($createReviewScript) -ArtifactList $artifactList -ArtifactPath $outPath -APIKey $ApiKey -SourceBranch $SourceBranch -DefaultBranch $DefaultBranch -ConfigFileDir $ConfigFileDir -RepoName $RepoName -BuildId $BuildId -MarkPackageAsShipped $MarkPackageAsShipped |
| 44 | +<# |
| 45 | +.DESCRIPTION |
| 46 | + Create new automatic APIView from a CI run |
| 47 | +.PARAMETER ServiceDirectory |
| 48 | + Thee name of the ServiceDirectory |
| 49 | +.PARAMETER ArtifactOutputDirectory |
| 50 | + Base output Directory path for the generated gosource artifacts |
| 51 | +.PARAMETER ArtifactName |
| 52 | + Name of the group of artifacts to be created |
| 53 | +.PARAMETER ApiKey |
| 54 | + The APIview ApiKey |
| 55 | +.PARAMETER SourceBranch |
| 56 | + SourceBranch |
| 57 | +.PARAMETER DefaultBranch |
| 58 | + DefaultBranch |
| 59 | +.PARAMETER ConfigFileDir |
| 60 | + Path to the ConfigFileDir as published in the pipeline |
| 61 | +.PARAMETER RepoName |
| 62 | + The name of the repository |
| 63 | +.PARAMETER BuildId |
| 64 | + The build Id of the pipeline run |
| 65 | +.PARAMETER MarkPackageAsShipped |
| 66 | + Indicate weather to mark the package a s shipped |
| 67 | +#> |
| 68 | +function New-APIView-From-CI { |
| 69 | + Param( |
| 70 | + [Parameter(Mandatory=$True)] |
| 71 | + [string] $ServiceDirectory, |
| 72 | + [Parameter(Mandatory=$True)] |
| 73 | + [string] $ArtifactOutputDirectory, |
| 74 | + [string] $ArtifactName="APIViewArtifacts", |
| 75 | + [Parameter(Mandatory=$True)] |
| 76 | + [string] $ApiKey, |
| 77 | + [Parameter(Mandatory=$True)] |
| 78 | + [string] $SourceBranch, |
| 79 | + [Parameter(Mandatory=$True)] |
| 80 | + [string] $DefaultBranch, |
| 81 | + [Parameter(Mandatory=$True)] |
| 82 | + [string] $ConfigFileDir, |
| 83 | + [string] $RepoName, |
| 84 | + [string] $BuildId, |
| 85 | + [bool] $MarkPackageAsShipped = $false |
| 86 | + ) |
| 87 | + $artifactList = Create-APIViewArtifact -ServiceDirectory $ServiceDirectory -ArtifactOutputDirectory $ArtifactOutputDirectory -ArtifactName $ArtifactName |
| 88 | + $createReviewScript = (Join-Path $PSScriptRoot .. common scripts Create-APIReview.ps1) |
| 89 | + |
| 90 | + Write-Host "Create Go APIView using generated artifacts" |
| 91 | + Write-Host "ArtifactList: $artifactList" |
| 92 | + Write-Host "ApiKey: $ApiKey" |
| 93 | + Write-Host "SourceBranch: $SourceBranch" |
| 94 | + Write-Host "DefaultBranch: $DefaultBranch" |
| 95 | + Write-Host "ConfigFileDir: $ConfigFileDir" |
| 96 | + Write-Host "RepoName: $RepoName" |
| 97 | + Write-Host "BuildId: $BuildId" |
| 98 | + Write-Host "MarkPackageAsShipped: $MarkPackageAsShipped" |
| 99 | + Write-Host "createReviewScript: $createReviewScript" |
| 100 | + |
| 101 | + |
| 102 | + #&($createReviewScript) -ArtifactList $artifactList -ArtifactPath $outPath -APIKey $ApiKey -SourceBranch $SourceBranch -DefaultBranch $DefaultBranch -ConfigFileDir $ConfigFileDir -RepoName $RepoName -BuildId $BuildId -MarkPackageAsShipped $MarkPackageAsShipped |
| 103 | +} |
| 104 | + |
| 105 | +<# |
| 106 | +.DESCRIPTION |
| 107 | + Call APIView endpoint to detect changes in API surface and create APIView if required |
| 108 | +.PARAMETER ArtifactPath |
| 109 | + Path to the generated artifact |
| 110 | +.PARAMETER CommitSha |
| 111 | + Commist sha for the build |
| 112 | +.PARAMETER ArtifactName |
| 113 | + Name of the group of artifacts to be created |
| 114 | +.PARAMETER ApiKey |
| 115 | + The APIview ApiKey |
| 116 | +.PARAMETER SourceBranch |
| 117 | + SourceBranch |
| 118 | +.PARAMETER DefaultBranch |
| 119 | + DefaultBranch |
| 120 | +.PARAMETER ConfigFileDir |
| 121 | + Path to the ConfigFileDir as published in the pipeline |
| 122 | +.PARAMETER RepoName |
| 123 | + The name of the repository |
| 124 | +.PARAMETER BuildId |
| 125 | + The build Id of the pipeline run |
| 126 | +.PARAMETER MarkPackageAsShipped |
| 127 | + Indicate weather to mark the package a s shipped |
| 128 | +#> |
| 129 | +function New-APIView-From-PR { |
| 130 | + Param( |
| 131 | + [Parameter(Mandatory=$True)] |
| 132 | + [string] $ArtifactPath, |
| 133 | + [Parameter(Mandatory=$True)] |
| 134 | + [string] $CommitSha, |
| 135 | + [Parameter(Mandatory=$True)] |
| 136 | + [string] $BuildId, |
| 137 | + [Parameter(Mandatory=$True)] |
| 138 | + [string] $PullRequestNumber, |
| 139 | + [Parameter(Mandatory=$True)] |
| 140 | + [string] $RepoFullName, |
| 141 | + [Parameter(Mandatory=$True)] |
| 142 | + [string] $APIViewUri, |
| 143 | + [Parameter(Mandatory=$True)] |
| 144 | + [string] $ArtifactName, |
| 145 | + [Parameter(Mandatory=$True)] |
| 146 | + [string] $DevopsProject |
| 147 | + ) |
| 148 | + |
| 149 | + $detectApiChanges = (Join-Path $PSScriptRoot .. common scripts Detect-Api-Changes.ps1) |
| 150 | + |
| 151 | + Write-Host "Detect API changes and create Go APIView using generated artifacts" |
| 152 | + &($detectApiChanges) -ArtifactPath $ArtifactPath -CommitSha $CommitSha -BuildId $BuildId ` |
| 153 | + -PullRequestNumber $PullRequestNumber -RepoFullName $RepoFullName -APIViewUri $APIViewUri ` |
| 154 | + -ArtifactName $ArtifactName -DevopsProject $DevopsProject |
| 155 | +} |
| 156 | + |
| 157 | + |
0 commit comments