From 8891f9511e07f8b8319547cbef002bf6e6cf011a Mon Sep 17 00:00:00 2001 From: Praven Kuttappan <55455725+praveenkuttappan@users.noreply.github.com> Date: Tue, 19 Mar 2024 17:16:13 -0400 Subject: [PATCH] Update pipeline step to remove deprecated params in API view script (#5458) * Update pipeline step to remove deprecated params in API view script --- .../templates/jobs/archetype-sdk-client.yml | 104 +++++++++--------- eng/scripts/Create-APIReview.ps1 | 49 +++++---- eng/scripts/Language-Settings.ps1 | 2 +- 3 files changed, 78 insertions(+), 77 deletions(-) diff --git a/eng/pipelines/templates/jobs/archetype-sdk-client.yml b/eng/pipelines/templates/jobs/archetype-sdk-client.yml index aca35023a..50311bd31 100644 --- a/eng/pipelines/templates/jobs/archetype-sdk-client.yml +++ b/eng/pipelines/templates/jobs/archetype-sdk-client.yml @@ -80,61 +80,35 @@ jobs: # Disable build for cpp - client - ${{ if and(eq(parameters.RunMetaJobs, 'true'), ne(parameters.ServiceDirectory, 'not-specified' )) }}: - - ${{ each artifact in parameters.Artifacts }}: - - job: - displayName: Create API Review for ${{ artifact.name }} - pool: - name: $(WINDOWSPOOL) - image: $(WINDOWSVMIMAGE) - os: windows - steps: - - task: Powershell@2 - inputs: - filePath: $(Build.SourcesDirectory)/eng/common/scripts/Save-Package-Properties.ps1 - arguments: > - -ServiceDirectory ${{ parameters.ServiceDirectory }} - -OutDirectory $(Build.ArtifactStagingDirectory)/PackageInfo - pwsh: true - workingDirectory: $(Pipeline.Workspace) - displayName: Dump Package properties - condition: succeeded() + - job: + displayName: Create API Review + pool: + name: $(WINDOWSPOOL) + image: $(WINDOWSVMIMAGE) + os: windows + steps: + - task: Powershell@2 + inputs: + filePath: $(Build.SourcesDirectory)/eng/common/scripts/Save-Package-Properties.ps1 + arguments: > + -ServiceDirectory ${{ parameters.ServiceDirectory }} + -OutDirectory $(Build.ArtifactStagingDirectory)/PackageInfo + pwsh: true + workingDirectory: $(Pipeline.Workspace) + displayName: Dump Package properties + condition: succeeded() - - template: /eng/common/pipelines/templates/steps/set-default-branch.yml + - template: /eng/common/pipelines/templates/steps/set-default-branch.yml - - task: UniversalPackages@0 - displayName: Download ApiView Parser. - inputs: - command: download - vstsFeed: 'internal/AzureSDKForCpp' - vstsFeedPackage: 'parseazuresdkcpp' - downloadDirectory: '$(System.DefaultWorkingDirectory)/parser' - vstsPackageVersion: 0.11.0 - condition: >- - and( - succeeded(), - ne(variables['Skip.CreateApiReview'], 'true'), - ne(variables['Build.Reason'],'PullRequest'), - eq(variables['System.TeamProject'], 'internal') - ) - - - task: Powershell@2 - inputs: - filePath: $(System.DefaultWorkingDirectory)/eng/scripts/Create-APIReview.ps1 - arguments: > - -ArtifactName ${{ artifact.name }} - -OutPath $(Build.ArtifactStagingDirectory) - -ApiviewUri "$(azuresdk-apiview-uri)" - -ApiKey "$(azuresdk-apiview-apikey)" - -ApiLabel "Auto Review - $(Build.SourceVersion)" - -SourceBranch $(Build.SourceBranchName) - -DefaultBranch $(DefaultBranch) - -ConfigFileDir $(Build.ArtifactStagingDirectory)/PackageInfo - -ParserPath $(System.DefaultWorkingDirectory)/parser/RelWithDebInfo/ParseAzureSdkCpp.exe - -SourcePath $(Build.SourcesDirectory)/sdk/${{ parameters.ServiceDirectory }}/${{ artifact.name }}/inc - pwsh: true - workingDirectory: $(Pipeline.Workspace) - displayName: Create API Review for ${{ artifact.name }} - condition: >- + - task: UniversalPackages@0 + displayName: Download ApiView Parser. + inputs: + command: download + vstsFeed: 'internal/AzureSDKForCpp' + vstsFeedPackage: 'parseazuresdkcpp' + downloadDirectory: '$(System.DefaultWorkingDirectory)/parser' + vstsPackageVersion: 0.11.0 + condition: >- and( succeeded(), ne(variables['Skip.CreateApiReview'], 'true'), @@ -142,6 +116,30 @@ jobs: eq(variables['System.TeamProject'], 'internal') ) + - task: Powershell@2 + inputs: + filePath: $(System.DefaultWorkingDirectory)/eng/scripts/Create-APIReview.ps1 + arguments: > + -ArtifactList ('${{ convertToJson(parameters.Artifacts) }}' | ConvertFrom-Json | Select-Object Name) + -OutPath $(Build.ArtifactStagingDirectory) + -ApiKey "$(azuresdk-apiview-apikey)" + -SourceBranch $(Build.SourceBranchName) + -DefaultBranch $(DefaultBranch) + -ParserPath $(System.DefaultWorkingDirectory)/parser/RelWithDebInfo/ParseAzureSdkCpp.exe + -ServicePath $(Build.SourcesDirectory)/sdk/${{ parameters.ServiceDirectory }} + -BuildId $(Build.BuildId) + -RepoName "$(Build.Repository.Name)" + pwsh: true + workingDirectory: $(Pipeline.Workspace) + displayName: Create API Review + condition: >- + and( + succeeded(), + ne(variables['Skip.CreateApiReview'], 'true'), + ne(variables['Build.Reason'],'PullRequest'), + eq(variables['System.TeamProject'], 'internal') + ) + - job: GenerateReleaseArtifacts pool: name: $(WINDOWSPOOL) diff --git a/eng/scripts/Create-APIReview.ps1 b/eng/scripts/Create-APIReview.ps1 index df54fabd5..987f26759 100644 --- a/eng/scripts/Create-APIReview.ps1 +++ b/eng/scripts/Create-APIReview.ps1 @@ -1,44 +1,47 @@ Param( [Parameter(Mandatory=$True)] - [string] $ArtifactName, + [array] $ArtifactList, [Parameter(Mandatory=$True)] [string] $OutPath, [Parameter(Mandatory=$True)] - [string] $ApiviewUri, - [Parameter(Mandatory=$True)] [string] $ApiKey, [Parameter(Mandatory=$True)] - [string] $ApiLabel, - [Parameter(Mandatory=$True)] [string] $SourceBranch, [Parameter(Mandatory=$True)] [string] $DefaultBranch, [Parameter(Mandatory=$True)] - [string] $ConfigFileDir, - [Parameter(Mandatory=$True)] [string] $ParserPath, [Parameter(Mandatory=$True)] - [string] $SourcePath + [string] $ServicePath, + [Parameter(Mandatory=$True)] + [string] $RepoName, + [Parameter(Mandatory=$True)] + [string] $BuildId ) Write-Host "$PSScriptRoot" . (Join-Path $PSScriptRoot .. common scripts common.ps1) -$createReviewScript = (Join-Path $PSScriptRoot .. common scripts Create-APIReview.ps1) -$apiviewSettings = Join-Path $SourcePath "ApiViewSettings.json" -if (!(Test-Path $apiviewSettings)) +foreach ($artifact in $ArtifactList) { - Write-Host "ApiViewSettings.json file is not found in $($SourcePath). APIView settings file is required to generate API review file." - exit 1 + $ArtifactName = $artifact.name + Write-Host "Generating artifact for $ArtifactName" + $SourcePath = Join-Path $ServicePath $ArtifactName "inc" + $apiviewSettings = Join-Path $SourcePath "ApiViewSettings.json" + if (!(Test-Path $apiviewSettings)) + { + Write-Host "ApiViewSettings.json file is not found in $($SourcePath). APIView settings file is required to generate API review file." + exit 1 + } + + Write-Host "Creating API review artifact for $($ArtifactName)" + New-Item -ItemType Directory -Path $OutPath/$ArtifactName -force + $parentPath = Split-Path $ParserPath -Parent + Write-Host "Contents in $($parentPath)" + Get-ChildItem -Path $parentPath -Recurse + & $ParserPath -o $OutPath/$ArtifactName/$ArtifactName.json $SourcePath } -Write-Host "Creating API review artifact for $($ArtifactName)" -New-Item -ItemType Directory -Path $OutPath/$ArtifactName -force -$parentPath = Split-Path $ParserPath -Parent -Write-Host "Contents in $($parentPath)" -Get-ChildItem -Path $parentPath -Recurse - -& $ParserPath -o $OutPath/$ArtifactName/$ArtifactName.json $SourcePath - -Write-Host "Send request to APIView to create review for $ArtifactName" -&($createReviewScript) -ArtifactPath $OutPath -APIViewUri $ApiviewUri -APIKey $ApiKey -APILabel $ApiLabel -PackageName $ArtifactName -SourceBranch $SourceBranch -DefaultBranch $DefaultBranch -ConfigFileDir $ConfigFileDir +$createReviewScript = (Join-Path $PSScriptRoot .. common scripts Create-APIReview.ps1) +Write-Host "Running script to create review for all artifacts." +&($createReviewScript) -ArtifactList $ArtifactList -ArtifactPath $OutPath -APIKey $ApiKey -SourceBranch $SourceBranch -DefaultBranch $DefaultBranch -RepoName $RepoName -BuildId $BuildId diff --git a/eng/scripts/Language-Settings.ps1 b/eng/scripts/Language-Settings.ps1 index a03759bce..ed22d5a5a 100644 --- a/eng/scripts/Language-Settings.ps1 +++ b/eng/scripts/Language-Settings.ps1 @@ -106,7 +106,7 @@ function SetPackageVersion ($PackageName, $Version, $ServiceDirectory, $ReleaseD function Find-cpp-Artifacts-For-Apireview($ArtifactPath, $PackageName) { - $artifact = Get-ChildItem -Path (Join-Path $ArtifactPath $PackageName) -Filter "*.json" + $artifact = @(Get-ChildItem -Path (Join-Path $ArtifactPath $PackageName) -Filter "*.json") if ($artifact) { $packages = @{