-
Notifications
You must be signed in to change notification settings - Fork 183
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'upstream/main' into feature/artifact-re…
…lease-attach
- Loading branch information
Showing
87 changed files
with
5,272 additions
and
557 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
pr: none | ||
|
||
trigger: none | ||
|
||
parameters: | ||
- name: Reviews | ||
type: string | ||
default: '[{"ReviewID":"<reviewid>","RevisionID":"<revisionId>","SourceRepoName":"<RepoName>","FileName":"<fileName>","SourceBranchName":"<SourceBranchName>"}]' | ||
- name: APIViewURL | ||
type: string | ||
default: 'https://apiview.dev' | ||
|
||
pool: | ||
name: azsdk-pool-mms-ubuntu-2004-general | ||
vmImage: MMSUbuntu20.04 | ||
|
||
variables: | ||
NodeVersion: '16.x' | ||
|
||
jobs: | ||
- job: CreateSwaggerReviewCodeFile | ||
displayName: 'Create Swagger API review token file' | ||
|
||
variables: | ||
- template: /eng/pipelines/templates/variables/globals.yml | ||
|
||
steps: | ||
- task: NodeTool@0 | ||
inputs: | ||
versionSpec: $(NodeVersion) | ||
displayName: "Use Node $(NodeVersion)" | ||
|
||
- pwsh: | | ||
$reviews = "${{ parameters.Reviews }}" | ||
Write-Host "Reviews: $($reviews)" | ||
echo "##vso[task.setvariable variable=Reviews]$reviews" | ||
displayName: "Setup Reviews Variable" | ||
condition: eq(variables['Reviews'], '') | ||
- pwsh: | | ||
$url = "${{parameters.APIViewURL}}" | ||
echo "##vso[task.setvariable variable=APIViewURL]$url" | ||
displayName: "Setup APIViewURL Variable" | ||
condition: eq(variables['APIViewURL'], '') | ||
- pwsh: | | ||
npm install -g @cadl-lang/compiler@0.37.0 | ||
npm install -g @azure-tools/cadl-apiview@0.3.0 | ||
npm list -g | ||
displayName: "Install npm packages" | ||
- task: Powershell@2 | ||
displayName: 'Generate APIView Token files' | ||
inputs: | ||
pwsh: true | ||
filePath: $(Build.SourcesDirectory)/eng/scripts/Create-Apiview-Token-Cadl.ps1 | ||
arguments: > | ||
-Reviews "$(Reviews)" | ||
-OutputDir "$(Build.ArtifactStagingDirectory)" | ||
-WorkingDir "$(Pipeline.Workspace)" | ||
- task: PublishBuildArtifacts@1 | ||
inputs: | ||
pathtoPublish: '$(Build.ArtifactStagingDirectory)' | ||
artifactName: 'apiview' | ||
|
||
- task: Powershell@2 | ||
displayName: 'Send Request to APIView to Update Token files' | ||
condition: succeededOrFailed() | ||
inputs: | ||
pwsh: true | ||
filePath: $(Build.SourcesDirectory)/eng/scripts/Apiview-Update-Generated-Review.ps1 | ||
arguments: > | ||
-BuildId $(Build.BuildId) | ||
-ApiviewUpdateUrl "$(APIViewURL)/review/UpdateApiReview" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,105 @@ | ||
[CmdletBinding()] | ||
param ( | ||
[ValidateNotNullOrEmpty()] | ||
[string] $Reviews, | ||
[ValidateNotNullOrEmpty()] | ||
[string] $WorkingDir, | ||
[ValidateNotNullOrEmpty()] | ||
[string] $OutputDir | ||
) | ||
|
||
Set-StrictMode -Version 3 | ||
$sparseCheckoutFile = ".git/info/sparse-checkout" | ||
|
||
|
||
function Sparse-Checkout($branchName, $packagePath) | ||
{ | ||
if (Test-Path $sparseCheckoutFile) | ||
{ | ||
Remove-Item $sparseCheckoutFile -Force | ||
} | ||
git sparse-checkout init --cone | ||
git sparse-checkout set $packagePath | ||
git checkout $BranchName | ||
} | ||
|
||
function Generate-Apiview-File($packagePath) | ||
{ | ||
Write-Host "Generating API review token file from path '$($packagePath)'" | ||
Push-Location $packagePath | ||
try | ||
{ | ||
npm install | ||
cadl compile . --emit=@azure-tools/cadl-apiview | ||
} | ||
finally | ||
{ | ||
Pop-Location | ||
} | ||
} | ||
|
||
function Stage-Apiview-File($packagePath, $reviewId, $revisionId) | ||
{ | ||
$tokenFilePath = Join-Path $packagePath "cadl-output" | ||
$stagingReviewPath = Join-Path $OutputDir $reviewId | ||
$stagingPath = Join-Path $stagingReviewPath $revisionId | ||
Write-Host "Copying APIView file from '$($tokenFilePath)' to '$($stagingPath)'" | ||
New-Item $stagingPath -ItemType Directory -Force | ||
Copy-Item -Destination $stagingPath -Path "$tokenFilePath/*" | ||
} | ||
|
||
|
||
Write-Host "Review Details Json: $($Reviews)" | ||
$revs = ConvertFrom-Json $Reviews | ||
if ($revs) | ||
{ | ||
$prevRepo = "" | ||
foreach ($r in $revs) | ||
{ | ||
$reviewId = $r.ReviewID | ||
$revisionId = $r.RevisionID | ||
$packagePath = $r.FileName | ||
$GitRepoName = $r.SourceRepoName | ||
$branchName = $r.SourceBranchName | ||
|
||
if ($packagePath.StartsWith("/")) | ||
{ | ||
$packagePath = $packagePath.Substring(1) | ||
} | ||
Write-Host "Generating API review for Review ID: '$($reviewId), Revision ID: '$($revisionId)" | ||
Write-Host "URL to Repo: '$($GitRepoName), Branch name: '$($branchName), Package Path: '$($packagePath)" | ||
|
||
$repoDirectory = Split-Path $GitRepoName -leaf | ||
if (Test-Path $repoDirectory) | ||
{ | ||
Write-Host "Destination path '$($repoDirectory)' already exists in working directory and is not an empty directory." | ||
exit 1 | ||
} | ||
# initialize git clone if current review is generated from different repo than previous one | ||
if ($GitRepoName -ne $prevRepo) | ||
{ | ||
git clone --no-checkout --filter=tree:0 "https://github.com/$GitRepoName" | ||
if ($LASTEXITCODE) { exit $LASTEXITCODE } | ||
$prevRepo = $GitRepoName | ||
} | ||
|
||
$repoDirectory = Split-Path $GitRepoName -leaf | ||
Push-Location $repoDirectory | ||
try | ||
{ | ||
Write-Host "GitHub Repo Name: '$($repoDirectory)" | ||
# Sparse checkout package root path | ||
Sparse-Checkout -branchName $branchName -packagePath $packagePath | ||
# Generate API code file | ||
Generate-Apiview-File -packagePath $packagePath | ||
#Copy generated code file to stagin location | ||
Stage-Apiview-File -packagePath $packagePath -reviewId $reviewId -revisionId $revisionId | ||
} | ||
finally | ||
{ | ||
Pop-Location | ||
} | ||
} | ||
|
||
Write-Host "Generated and copied Api review token file to output directory" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
src/dotnet/APIView/APIViewIntegrationTests/APIViewIntegrationTests.csproj
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 0 additions & 16 deletions
16
src/dotnet/APIView/APIViewWeb/Account/PullRequestPermissionRequirement.cs
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.