-
Notifications
You must be signed in to change notification settings - Fork 228
Sandboxing changes: create apireview gen pipeline #3347
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
Merged
praveenkuttappan
merged 8 commits into
Azure:main
from
praveenkuttappan:feature/create_apireview_gen_pipeline
Jul 27, 2022
Merged
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
f2ff661
Pipeline yaml to generate api review file
praveenkuttappan 91426b2
Updated as per review comments
praveenkuttappan 2163a0e
Changes as per review comments
praveenkuttappan 47baf3f
Updated default value for review json param
praveenkuttappan 546521d
Update script param name
praveenkuttappan f6c6723
Update script param name
praveenkuttappan 6126e51
Fix script to create path correctly
praveenkuttappan bb37ea2
Fix python script running path
praveenkuttappan File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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,47 @@ | ||
| pr: none | ||
|
|
||
| trigger: none | ||
|
|
||
| pool: | ||
| name: azsdk-pool-mms-ubuntu-2004-general | ||
| vmImage: MMSUbuntu20.04 | ||
|
|
||
| parameters: | ||
| - name: Reviews | ||
| type: string | ||
| default: '[{"ReviewID":"<reviewid>","RevisionID":"<revisionId>","FileID":"<fileid>","FileName":"<fileName>"}]' | ||
| - name: APIViewURL | ||
| type: string | ||
| default: 'https://apiview.dev' | ||
| - name: StorageContainerUrl | ||
| type: string | ||
| default: '' | ||
|
|
||
| variables: | ||
| PythonIndexUrl: 'https://pkgs.dev.azure.com/azure-sdk/public/_packaging/azure-sdk-for-python/pypi/simple/' | ||
| PythonVersion: '3.10.2' | ||
| ApiStubVersion: '0.3.1' | ||
|
|
||
| jobs: | ||
| - job: CreatePythonReviewCodeFile | ||
| displayName: 'Create Python API review token file' | ||
|
|
||
| variables: | ||
| - template: /eng/pipelines/templates/variables/globals.yml | ||
praveenkuttappan marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| steps: | ||
| - template: /eng/pipelines/templates/steps/use-python-version.yml | ||
| parameters: | ||
| versionSpec: '$(PythonVersion)' | ||
|
|
||
| - script: | | ||
| pip install virtualenv aiohttp chardet trio | ||
| pip install api-stub-generator==$(ApiStubVersion) --index-url $(PythonIndexUrl) | ||
| displayName: 'Install api-stub-generator' | ||
|
|
||
| - template: /eng/pipelines/templates/steps/apiview-review-gen.yml | ||
| parameters: | ||
| Reviews: ${{ parameters.Reviews }} | ||
| APIViewURL: ${{ parameters.APIViewURL }} | ||
| StorageContainerUrl: ${{ parameters.StorageContainerUrl }} | ||
| ApiviewGenScript: './Create-Apiview-Token-Python.ps1' | ||
This file contains hidden or 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,40 @@ | ||
| parameters: | ||
| - name: Reviews | ||
| type: string | ||
| default: '' | ||
| - name: APIViewURL | ||
| type: string | ||
| default: '' | ||
| - name: StorageContainerUrl | ||
| type: string | ||
| default: '' | ||
| - name: ApiviewGenScript | ||
| type: string | ||
| default: '' | ||
|
|
||
| steps: | ||
| - task: Powershell@2 | ||
| displayName: 'Generate APIView Token files' | ||
| condition: succeededOrFailed() | ||
| inputs: | ||
| pwsh: true | ||
| filePath: $(Build.SourcesDirectory)/eng/scripts/Create-Apiview-Token-Files.ps1 | ||
| arguments: > | ||
| -ReviewDetailsJson "${{ parameters.Reviews }}" | ||
| -StagingPath "$(Build.ArtifactStagingDirectory)" | ||
| -WorkingDir "$(Pipeline.Workspace)" | ||
| -StorageBaseUrl "${{parameters.StorageContainerUrl}}" | ||
| -ApiviewGenScript "${{parameters.ApiviewGenScript}}" | ||
| -ContainerSas "$(apiview-originals-sas)" | ||
|
|
||
| - task: PublishBuildArtifacts@1 | ||
| inputs: | ||
| pathtoPublish: '$(Build.ArtifactStagingDirectory)/' | ||
| artifactName: 'apiview' | ||
|
|
||
| - pwsh: | | ||
| $requestUrl = ${{parameters.APIViewURL}}/reviewgen/update?path=apiview&buildId=$(Build.BuildId) | ||
| Write-Host $requestUrl | ||
| $resp = Invoke-RestMethod $requestUrl | ||
| Write-Host $resp | ||
| displayName: 'Send Request to APIView' |
This file contains hidden or 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,48 @@ | ||
| [CmdletBinding()] | ||
praveenkuttappan marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| param ( | ||
| [Parameter(Mandatory = $true)] | ||
| [string]$ReviewDetailsJson, | ||
| [Parameter(Mandatory = $true)] | ||
| [string]$StagingPath, | ||
| [Parameter(Mandatory = $true)] | ||
| [string]$WorkingDir, | ||
| [Parameter(Mandatory = $true)] | ||
| [string]$StorageBaseUrl, | ||
| [Parameter(Mandatory = $true)] | ||
| [string]$ContainerSas, | ||
| [Parameter(Mandatory = $true)] | ||
| [string]$ApiviewGenScript | ||
| ) | ||
|
|
||
|
|
||
| Write-Host "Review Details Json: $($ReviewDetailsJson)" | ||
| $reviews = ConvertFrom-Json $ReviewDetailsJson | ||
| Write-Host $reviews | ||
| if ($reviews -ne $null) | ||
| { | ||
| foreach($r in $reviews) | ||
| { | ||
| Write-Host "Review:$($r.ReviewID)" | ||
| Write-Host "Revision: $($r.RevisionID)" | ||
|
|
||
| $pkgWorkingDir = Join-Path -Path $WorkingDir $r.ReviewID | Join-Path -ChildPath $r.RevisionID | ||
| $codeDir = New-Item -Path $pkgWorkingDir -ItemType Directory | ||
| $sourcePath = $StorageBaseUrl + "/" + $r.FileID + $ContainerSas | ||
| Write-Host "Copying $($sourcePath)" | ||
| azcopy cp "$sourcePath" $codeDir/$($r.FileName) --recursive=true | ||
|
|
||
| #Create staging path for review and revision ID | ||
| $CodeFilePath = Join-Path -Path $StagingPath $r.ReviewID | Join-Path -ChildPath $r.RevisionID | ||
| if (-not (Test-Path -Path $CodeFilePath)) { | ||
| New-Item -Path $CodeFilePath -ItemType Directory | ||
| } | ||
|
|
||
| $reviewGenScriptPath = Join-Path $PSScriptRoot $ApiviewGenScript | ||
| &($reviewGenScriptPath) -SourcePath $codeDir/$($r.FileName) -OutPath $CodeFilePath | ||
| } | ||
| } | ||
| else | ||
| { | ||
| Write-Host "Invalid Input review details Json $($ReviewDetailsJson)" | ||
| exit 1; | ||
| } | ||
This file contains hidden or 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,10 @@ | ||
| [CmdletBinding()] | ||
| param ( | ||
| [Parameter(Mandatory = $true)] | ||
| [string]$SourcePath, | ||
| [Parameter(Mandatory = $true)] | ||
| [string]$OutPath | ||
| ) | ||
|
|
||
| Write-Host "Generating API review token file: $($SourcePath)" | ||
| python -m apistub --pkg-path $SourcePath --out-path $OutPath |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.