diff --git a/eng/pipelines/templates/jobs/archetype-sdk-client.yml b/eng/pipelines/templates/jobs/archetype-sdk-client.yml index 0f4755c6d41..bd44fb1aeb5 100644 --- a/eng/pipelines/templates/jobs/archetype-sdk-client.yml +++ b/eng/pipelines/templates/jobs/archetype-sdk-client.yml @@ -1,3 +1,6 @@ +# cSpell:ignore vsts +# cSpell:ignore parseazuresdkcpp + parameters: - name: Artifacts type: object @@ -84,6 +87,20 @@ jobs: - 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.6.0 + condition: >- + and( + succeeded(), + ne(variables['Skip.CreateApiReview'], 'true'),eq(variables['System.TeamProject'], 'internal') + ) + - task: Powershell@2 inputs: filePath: $(System.DefaultWorkingDirectory)/eng/scripts/Create-APIReview.ps1 @@ -96,6 +113,8 @@ jobs: -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 }} diff --git a/eng/scripts/Create-APIReview.ps1 b/eng/scripts/Create-APIReview.ps1 index 0a0d7cd1afa..df54fabd506 100644 --- a/eng/scripts/Create-APIReview.ps1 +++ b/eng/scripts/Create-APIReview.ps1 @@ -14,30 +14,31 @@ Param( [Parameter(Mandatory=$True)] [string] $DefaultBranch, [Parameter(Mandatory=$True)] - [string] $ConfigFileDir + [string] $ConfigFileDir, + [Parameter(Mandatory=$True)] + [string] $ParserPath, + [Parameter(Mandatory=$True)] + [string] $SourcePath ) Write-Host "$PSScriptRoot" . (Join-Path $PSScriptRoot .. common scripts common.ps1) $createReviewScript = (Join-Path $PSScriptRoot .. common scripts Create-APIReview.ps1) -Set-Location $PSScriptRoot -Write-Host "Creating API review artifact for $ArtifactName" -New-Item -ItemType Directory -Path $OutPath/$ArtifactName -force +$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 +} -$gitroot = Join-Path $PSScriptRoot .. .. -Write-Host "Get-ApiViewCommandLine.ps1 $gitroot $ArtifactName" -$cmdLine = & $PSScriptRoot/Get-ApiViewCommandLine.ps1 $gitroot $ArtifactName -Write-Host "Executing clang++ command:" -Write-Host $cmdLine -$cmd, $cmdArgs = $cmdLine -split ' ' -# Get-ApiViewCommandLine.ps1 returns a string representing a clang++ command that needs to be run, e.g. -# clang++ -Xclang -ast-dump -I -# ApiView expects a zip of this ast as the format for a C++ language artifact. -& $cmd $cmdArgs > clangAstOutput +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 -Compress-Archive -Path clangAstOutput -DestinationPath $OutPath/$ArtifactName/$ArtifactName -Rename-Item $OutPath/$ArtifactName/$ArtifactName.zip -NewName "$ArtifactName.cppast" +& $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 diff --git a/eng/scripts/Language-Settings.ps1 b/eng/scripts/Language-Settings.ps1 index 7dc88bcf89c..e6815f1f65a 100644 --- a/eng/scripts/Language-Settings.ps1 +++ b/eng/scripts/Language-Settings.ps1 @@ -101,7 +101,7 @@ function SetPackageVersion ($PackageName, $Version, $ServiceDirectory, $ReleaseD function Find-cpp-Artifacts-For-Apireview($ArtifactPath, $PackageName) { - $artifact = Get-ChildItem -Path (Join-Path $ArtifactPath $PackageName) -Filter "*.cppast" + $artifact = Get-ChildItem -Path (Join-Path $ArtifactPath $PackageName) -Filter "*.json" if ($artifact) { $packages = @{ diff --git a/sdk/template/azure-template/inc/ApiViewSettings.json b/sdk/template/azure-template/inc/ApiViewSettings.json new file mode 100644 index 00000000000..4f510210279 --- /dev/null +++ b/sdk/template/azure-template/inc/ApiViewSettings.json @@ -0,0 +1,16 @@ +{ + "sourceFilesToProcess": null, + "sourceFilesToSkip": [ + ], + "additionalIncludeDirectories": [ + "../../../core/azure-core/inc" + ], + "additionalCompilerSwitches": [], + "allowInternal": false, + "includeDetail": false, + "includePrivate": false, + "filterNamespace": "Azure::", + "reviewName": "Azure Template API Review", + "serviceName": "Azure Template", + "packageName": "azure-template" +}