Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main' into feature/artifact-re…
Browse files Browse the repository at this point in the history
…lease-attach
  • Loading branch information
scbedd committed Dec 12, 2022
2 parents 794a012 + 20c909b commit 5cdc4fc
Show file tree
Hide file tree
Showing 87 changed files with 5,272 additions and 557 deletions.
17 changes: 3 additions & 14 deletions .azure-pipelines/apiview.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ pr:
- tools/apiview/parsers/js-api-parser

variables:
DotNetRuntimeVersion: '3.1.x'
DotNetRuntimeVersion: '6.x'
PythonVersion: '3.10.5'
WebClientProjectDirectory: 'src/dotnet/APIView/APIViewWeb/Client'
WebProjectPath: 'src/dotnet/APIView/APIViewWeb/APIViewWeb.csproj'
Expand Down Expand Up @@ -183,20 +183,9 @@ stages:
pwsh: true
displayName: 'Start Azurite'

- task: DotNetCoreInstaller@2
displayName: 'Use .NET Core sdk 3.1.x'
- task: UseDotNet@2
displayName: 'Install .NET'
inputs:
version: '3.1.x'

- task: DotNetCoreInstaller@2
displayName: 'Use .NET Core sdk 5.x'
inputs:
version: '5.x'

- task: DotNetCoreInstaller@2
displayName: 'Use .NET Core $(DotNetRuntimeVersion)'
inputs:
packageType: runtime
version: '$(DotNetRuntimeVersion)'

- task: DotNetCoreCLI@2
Expand Down
15 changes: 15 additions & 0 deletions eng/common/pipelines/templates/jobs/perf.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ parameters:
- name: Iterations
type: number
default: '5'
- name: Profile
type: boolean
default: false
- name: AdditionalArguments
type: string
default: ''
Expand All @@ -77,6 +80,11 @@ jobs:
MatrixName: 'Windows'
variables:
- ${{ parameters.Variables }}
- name: Profile
${{ if parameters.Profile }}:
value: '--profile'
${{ else }}:
value: ''
pool:
name: $(Pool)
vmImage: $(OSVmImage)
Expand Down Expand Up @@ -125,6 +133,7 @@ jobs:
--tests "${{ parameters.Tests }}"
--arguments "${{ parameters.Arguments }}"
--iterations ${{ parameters.Iterations }}
$(Profile)
${{ parameters.AdditionalArguments }}
workingDirectory: azure-sdk-tools/tools/perf-automation/Azure.Sdk.Tools.PerfAutomation
env:
Expand Down Expand Up @@ -162,6 +171,12 @@ jobs:
artifactName: results-${{ parameters.Language }}-$(MatrixName)
condition: always()

- task: PublishPipelineArtifact@1
inputs:
targetPath: $(System.DefaultWorkingDirectory)/${{ parameters.Language }}-profile.zip
artifactName: ${{ parameters.Language }}-profile.zip
condition: ${{ parameters.Profile }}

- template: /eng/common/TestResources/remove-test-resources.yml
parameters:
ServiceDirectory: ${{ parameters.ServiceDirectory }}
Expand Down
4 changes: 2 additions & 2 deletions eng/common/scripts/Helpers/ApiView-Helpers.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -42,12 +42,12 @@ function Check-ApiReviewStatus($packageName, $packageVersion, $language, $url, $
{
Write-Host "API Review is approved for package $($packageName)"
}
else if ($response.StatusCode -eq '202')
elseif ($response.StatusCode -eq '202')
{
Write-Host "Package name $($packageName) is not yet approved by an SDK API approver. Package name must be approved to release a beta version if $($packageName) was never released a stable version."
Write-Host "You can check http://aka.ms/azsdk/engsys/apireview/faq for more details on package name Approval."
}
else if ($response.StatusCode -eq '201')
elseif ($response.StatusCode -eq '201')
{
Write-Warning "API Review is not approved for package $($packageName). Release pipeline will fail if API review is not approved for a stable version release."
Write-Host "You can check http://aka.ms/azsdk/engsys/apireview/faq for more details on API Approval."
Expand Down
75 changes: 75 additions & 0 deletions eng/pipelines/apiview-review-gen-cadl.yml
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"
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ resources:
- repository: azure-sdk-build-tools
type: git
name: internal/azure-sdk-build-tools
ref: refs/tags/azure-sdk-build-tools_20221201.3
ref: refs/tags/azure-sdk-build-tools_20221212.1

parameters:
- name: BuildToolsRepoPath
Expand Down
2 changes: 1 addition & 1 deletion eng/pipelines/templates/steps/test-proxy-local-tool.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ steps:
dotnet tool install --tool-path $(Build.BinariesDirectory)/test-proxy `
--prerelease `
--add-source $(Build.ArtifactStagingDirectory) `
azure.sdk.tools.testproxy
test-proxy
displayName: "Install test-proxy from local file"
workingDirectory: $(Build.SourcesDirectory)/tools/test-proxy
Expand Down
105 changes: 105 additions & 0 deletions eng/scripts/Create-Apiview-Token-Cadl.ps1
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"
}
4 changes: 2 additions & 2 deletions src/dotnet/APIView/APIView/APIView.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<ApplicationIcon />
<OutputType>Exe</OutputType>
<StartupObject />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<LangVersion>latest</LangVersion>
<IsPackable>false</IsPackable>
<PreserveCompilationContext>true</PreserveCompilationContext>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public async Task AddRevisionAsync_Computes_Headings_Of_Sections_With_Diff_A()
{
var reviewManager = testsBaseFixture.ReviewManager;
var user = testsBaseFixture.User;
var review = await testsBaseFixture.ReviewManager.CreateReviewAsync(user, fileNameA, "Revision1", fileStreamA, false, true);
var review = await testsBaseFixture.ReviewManager.CreateReviewAsync(user, fileNameA, "Revision1", fileStreamA, false, "Swagger", true);
await reviewManager.AddRevisionAsync(user, review.ReviewId, fileNameB, "Revision2", fileStreamB, true);
review = await reviewManager.GetReviewAsync(user, review.ReviewId);
var headingWithDiffInSections = review.Revisions[0].HeadingsOfSectionsWithDiff[review.Revisions[1].RevisionId];
Expand All @@ -64,7 +64,7 @@ public async Task AddRevisionAsync_Computes_Headings_Of_Sections_With_Diff_B()
{
var reviewManager = testsBaseFixture.ReviewManager;
var user = testsBaseFixture.User;
var review = await reviewManager.CreateReviewAsync(user, fileNameC, "Azure.Analytics.Purview.Account", fileStreamC, false, true);
var review = await reviewManager.CreateReviewAsync(user, fileNameC, "Azure.Analytics.Purview.Account", fileStreamC, false, "Swagger", true);
await reviewManager.AddRevisionAsync(user, review.ReviewId, fileNameD, "Azure.Analytics.Purview.Account", fileStreamD, true);
review = await reviewManager.GetReviewAsync(user, review.ReviewId);
var headingWithDiffInSections = review.Revisions[0].HeadingsOfSectionsWithDiff[review.Revisions[1].RevisionId];
Expand Down
2 changes: 1 addition & 1 deletion src/dotnet/APIView/APIViewUITests/APIViewUITests.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetFramework>net6.0</TargetFramework>

<IsPackable>false</IsPackable>

Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<LangVersion>latest</LangVersion>
<IsPackable>false</IsPackable>
<PreserveCompilationContext>true</PreserveCompilationContext>
Expand Down
5 changes: 4 additions & 1 deletion src/dotnet/APIView/APIViewWeb/APIViewWeb.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>netcoreapp3.1</TargetFramework>
<TargetFramework>net6.0</TargetFramework>
<LangVersion>latest</LangVersion>
<RootNamespace>APIViewWeb</RootNamespace>
<AssemblyName>APIViewWeb</AssemblyName>
Expand All @@ -24,6 +24,8 @@

<ItemGroup>
<PackageReference Include="AutoMapper.Extensions.Microsoft.DependencyInjection" Version="11.0.0" />
<PackageReference Include="Azure.Data.AppConfiguration" Version="1.2.0" />
<PackageReference Include="Azure.Identity" Version="1.8.0" />
<PackageReference Include="Azure.Storage.Blobs" Version="12.13.0" />
<PackageReference Include="CsvHelper" Version="27.2.1" />
<!-- Adding NU1701 suppression as these three libraries have not updated to more modern versions of .net, although in testing they work as required. -->
Expand All @@ -37,6 +39,7 @@
<NoWarn>NU1701</NoWarn>
</PackageReference>
<PackageReference Include="Microsoft.ApplicationInsights.AspNetCore" Version="2.12.0-beta4" />
<PackageReference Include="Microsoft.Azure.AppConfiguration.AspNetCore" Version="5.2.0" />
<PackageReference Include="Microsoft.Azure.Cosmos" Version="3.26.1" />
<PackageReference Include="Microsoft.AspNetCore.Mvc.Razor.RuntimeCompilation" Version="3.0" />
<PackageReference Include="Microsoft.TeamFoundationServer.Client" Version="16.170.0" />
Expand Down

This file was deleted.

Loading

0 comments on commit 5cdc4fc

Please sign in to comment.