Generate API review for C++ using new parser (#4302)
This commit is contained in:
parent
5058f15594
commit
7da07d5072
@ -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 }}
|
||||
|
||||
@ -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"
|
||||
$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
|
||||
|
||||
$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++ <space separated list of header files> -Xclang -ast-dump -I <space separated list of header files>
|
||||
# ApiView expects a zip of this ast as the format for a C++ language artifact.
|
||||
& $cmd $cmdArgs > clangAstOutput
|
||||
|
||||
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
|
||||
|
||||
@ -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 = @{
|
||||
|
||||
16
sdk/template/azure-template/inc/ApiViewSettings.json
Normal file
16
sdk/template/azure-template/inc/ApiViewSettings.json
Normal file
@ -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"
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user