Skip to content

Commit 5ce8e53

Browse files
authored
[ci] Add API Scan job (#9)
Context: https://devdiv.visualstudio.com/DevDiv/_wiki/wikis/DevDiv.wiki/25351/APIScan-step-by-step-guide-to-setting-up-a-Pipeline Context: https://portal.microsofticm.com/imp/v3/incidents/incident/480553298/summary The `APIScan@2` task has been added to pipeline runs against `main`. This task should help us identify related issues earlier, rather than having to wait for a full scan of VS. Note: we rename many of the `.exe`s, e.g. rename `lld.exe` to `ld.exe`. This prevents APIScan from finding symbol files, as APIScan appears to check for a `.pdb` file matching the *original* filename, e.g. it needs `lld.pdb` (original name), *not* `ld.pdb` (to match renamed `ld.exe`). Update `package.sh` so that the original `*.pdb` filenames are copied into `${artifacts_source_bin}`, so that APIScan can find symbols.
1 parent 9d342d5 commit 5ce8e53

File tree

3 files changed

+78
-2
lines changed

3 files changed

+78
-2
lines changed

build-llvm.cmd

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ set SOURCE_DIR=%MY_DIR%external\llvm\llvm
55
set PROJECTS=lld
66
set TARGETS=X86;ARM;AArch64
77
set BINARIES=llvm-mc.exe llvm-strip.exe lld.exe llc.exe
8-
set PDBS=llvm-mc.pdb llvm-strip.pdb lld.pdb llc.pdb
8+
set PDBS=llvm-mc.pdb llvm-objcopy.pdb llvm-strip.pdb lld.pdb llc.pdb
99

1010
set HOST_BUILD_DIR=%BUILD_DIR%\%HOST%\llvm
1111
set HOST_BIN_DIR=%HOST_BUILD_DIR%\Release\bin
@@ -71,7 +71,7 @@ IF %ERRORLEVEL% GEQ 1 EXIT /B 5
7171
move %HOST_BIN_DIR%\llvm-objcopy.exe %HOST_BIN_DIR%\llvm-strip.exe
7272
IF %ERRORLEVEL% GEQ 1 EXIT /B 6
7373

74-
move %HOST_BIN_DIR%\llvm-objcopy.pdb %HOST_BIN_DIR%\llvm-strip.pdb
74+
copy %HOST_BIN_DIR%\llvm-objcopy.pdb %HOST_BIN_DIR%\llvm-strip.pdb
7575
IF %ERRORLEVEL% GEQ 1 EXIT /B 7
7676

7777
for %%b in (%BINARIES%) DO (

build-tools/automation/azure-pipelines.yml

Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,8 @@ resources:
2828
ref: refs/tags/release
2929

3030
parameters:
31+
- name: ApiScanSourceBranch
32+
default: refs/heads/main
3133
- name: SignArtifactsOverride
3234
default: false
3335
- name: Skip1ESComplianceTasks
@@ -44,6 +46,10 @@ variables:
4446
value: android-llvm-toolchain-signed
4547
${{ else }}:
4648
value: android-llvm-toolchain-unsigned
49+
- name: ApiScanSoftwareName
50+
value: VS
51+
- name: ApiScanSoftwareVersion
52+
value: 17.10
4753
- name: TeamName
4854
value: XamarinAndroid
4955
- name: BUILD_DIR
@@ -296,3 +302,71 @@ extends:
296302
inputs:
297303
TargetFolders: $(Build.SourcesDirectory)\artifacts
298304
ExcludeSNVerify: true
305+
306+
307+
- stage: Compliance
308+
displayName: Compliance
309+
dependsOn: package
310+
condition: and(eq(dependencies.package.result, 'Succeeded'), eq(variables['Build.SourceBranch'], '${{ parameters.ApiScanSourceBranch }}'))
311+
jobs:
312+
- job: api_scan
313+
displayName: API Scan
314+
pool: $(MicroBuildPoolName)
315+
timeoutInMinutes: 360
316+
workspace:
317+
clean: all
318+
steps:
319+
- task: DownloadPipelineArtifact@2
320+
inputs:
321+
artifactName: $(ToolchainArtifactName)
322+
downloadPath: $(Build.StagingDirectory)\toolchain-zip
323+
324+
- task: ExtractFiles@1
325+
displayName: Extract $(ToolchainArtifactName)
326+
inputs:
327+
archiveFilePatterns: $(Build.StagingDirectory)\**\*.zip
328+
destinationFolder: $(Build.SourcesDirectory)\binutils
329+
330+
- task: CopyFiles@2
331+
displayName: Collect Files for APIScan
332+
inputs:
333+
Contents: |
334+
$(Build.SourcesDirectory)\binutils\windows\**\?(*.dll|*.exe|*.pdb)
335+
TargetFolder: $(Agent.TempDirectory)\T
336+
337+
- powershell: Get-ChildItem -Path "$(Agent.TempDirectory)\T" -Recurse
338+
displayName: List Files for APIScan
339+
340+
- task: APIScan@2
341+
displayName: Run APIScan
342+
inputs:
343+
softwareFolder: $(Agent.TempDirectory)\T
344+
symbolsFolder: 'SRV*http://symweb;$(Agent.TempDirectory)\T'
345+
softwareName: $(ApiScanSoftwareName)
346+
softwareVersionNum: $(ApiScanSoftwareVersion)
347+
isLargeApp: true
348+
toolVersion: Latest
349+
env:
350+
AzureServicesAuthConnectionString: runAs=App;AppId=$(ApiScanClientId);TenantId=$(ApiScanTenant);AppKey=$(ApiScanSecret)
351+
352+
- task: SdtReport@2
353+
displayName: Guardian Export - Security Report
354+
inputs:
355+
GdnExportAllTools: false
356+
GdnExportGdnToolApiScan: true
357+
GdnExportOutputSuppressionFile: apiscan.gdnsuppress
358+
359+
- task: PublishSecurityAnalysisLogs@3
360+
displayName: Publish Guardian Artifacts
361+
inputs:
362+
ArtifactName: APIScan Logs
363+
ArtifactType: Container
364+
AllTools: false
365+
APIScan: true
366+
ToolLogsNotFoundAction: Warning
367+
368+
- task: PostAnalysis@2
369+
displayName: Fail Build on Guardian Issues
370+
inputs:
371+
GdnBreakAllTools: false
372+
GdnBreakGdnToolApiScan: true

package.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,8 @@ function prepare()
6363
exe=".exe"
6464
cmd=".cmd"
6565

66+
cp -P -a "${artifacts_source_bin}/llvm-objcopy.pdb" "${artifacts_dest_bin}/llvm-objcopy.pdb"
67+
cp -P -a "${artifacts_source_bin}/lld.pdb" "${artifacts_dest_bin}/lld.pdb"
6668
make_windows_wrapper_scripts "scripts/llvm-strip.cmd.in" "${artifacts_source_bin}" "strip"
6769
make_windows_wrapper_scripts "scripts/gas.cmd.in" "${artifacts_source_bin}" "as"
6870
make_windows_wrapper_scripts "scripts/ld.cmd.in" "${artifacts_source_bin}" "ld"

0 commit comments

Comments
 (0)