Skip to content

Commit 78643d9

Browse files
committed
[ci] Enable api scan on dnceng (#30984)
* [ci] List dlls * Fix steps * Again * Again * yml * Execute post steps * Try run apiscan * Try add ids * TRY AGAIN * Try 1ES tasks * Fxi ident * Remove publish * Try template context * isProduction * try outputs * not release job * Fix artifact name * Try again fix variables * Try push metadat files * Try hardcode * Try again * Update variables
1 parent eb68420 commit 78643d9

File tree

4 files changed

+124
-12
lines changed

4 files changed

+124
-12
lines changed
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
# Template for APIScan stage
2+
3+
parameters:
4+
- name: prepareSteps
5+
type: stepList
6+
default: []
7+
- name: postSteps
8+
type: stepList
9+
default: []
10+
- name: pool
11+
type: object
12+
- name: dependsOnStage
13+
type: object
14+
default: []
15+
- name: softwareName
16+
type: string
17+
default: 'MAUI'
18+
- name: softwareVersion
19+
type: string
20+
default: '9.0'
21+
- name: softwareBuildNum
22+
type: string
23+
default: '$(Build.BuildId)'
24+
- name: softwareFolder
25+
type: string
26+
default: '$(Agent.TempDirectory)/APIScanFiles'
27+
- name: AppId
28+
type: string
29+
default: $(ApiScanAppId)
30+
- name: TenantId
31+
type: string
32+
default: $(ApiScanTenantId)
33+
- name: ServiceConnectionId
34+
type: string
35+
default: $(ApiScanServiceConnectionId)
36+
37+
stages:
38+
- stage: APIScan
39+
displayName: Run APIScan
40+
dependsOn: ${{ parameters.dependsOnStage }}
41+
jobs:
42+
- job: api_scan
43+
displayName: APIScan Job
44+
pool: ${{ parameters.pool }}
45+
templateContext:
46+
type: releaseJob
47+
isProduction: true
48+
inputs:
49+
- input: pipelineArtifact
50+
artifactName: APIScanFiles
51+
targetPath: ${{ parameters.softwareFolder }}
52+
steps:
53+
- ${{ each step in parameters.prepareSteps }}:
54+
- ${{ each pair in step }}:
55+
${{ pair.key }}: ${{ pair.value }}
56+
57+
- task: APIScan@2
58+
displayName: Run APIScan
59+
inputs:
60+
softwareFolder: ${{ parameters.softwareFolder }}
61+
softwareName: ${{ parameters.softwareName }}
62+
softwareVersionNum: ${{ parameters.softwareVersion }}
63+
softwareBuildNum: ${{ parameters.softwareBuildNum }}
64+
azureSubscription: 'dotnet-apiscan'
65+
env:
66+
AzureServicesAuthConnectionString: RunAs=App;AppId=${{ parameters.AppId }};TenantId=${{ parameters.TenantId }};ServiceConnectionId=${{ parameters.ServiceConnectionId }};
67+
SYSTEM_ACCESSTOKEN: $(System.AccessToken)
68+
69+
- task: PublishSecurityAnalysisLogs@3
70+
displayName: Publishing analysis artifacts
71+
inputs:
72+
ArtifactName: 'CodeAnalysisLogs'
73+
ArtifactType: 'Container'
74+
AllTools: true
75+
ToolLogsNotFoundAction: 'Standard'
76+
77+
- ${{ each step in parameters.postSteps }}:
78+
- ${{ each pair in step }}:
79+
${{ pair.key }}: ${{ pair.value }}

eng/pipelines/arcade/stage-pack.yml

Lines changed: 32 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,19 @@ stages:
3939
sourceIndexParams: ${{ parameters.sourceIndexParams }}
4040
publishAssetsImmediately: true
4141
enablePublishBuildArtifacts: true
42-
enablePublishTestResults: true
42+
enablePublishTestResults: false
43+
templateContext:
44+
outputs:
45+
- output: pipelineArtifact
46+
artifact: APIScanFiles
47+
path: $(Agent.TempDirectory)/APIScanFiles
48+
- output: pipelineArtifact
49+
artifact: Metadata
50+
path: $(Agent.TempDirectory)/metadata
51+
4352
workspace:
4453
clean: all
54+
4555
jobs:
4656
- job: pack_net_Windows
4757
displayName: Pack Windows
@@ -56,16 +66,6 @@ stages:
5666
- ${{ each pair in step }}:
5767
${{ pair.key }}: ${{ pair.value }}
5868

59-
# - script: $(_buildScript)
60-
# -restore -build
61-
# -configuration $(_BuildConfig)
62-
# /p:ArchiveTests=true
63-
# /p:TreatWarningsAsErrors=false
64-
# /p:_SkipUpdateBuildNumber=true
65-
# /bl:$(Build.Arcade.LogsPath)build.binlog
66-
# $(_OfficialBuildIdArgs)
67-
# displayName: 🛠️ Build
68-
6969
# Run on public pipeline
7070
- ${{ if parameters.runAsPublic }}:
7171
- script: $(_buildScript) -restore -pack -publish $(_PublishArgs) -configuration $(_BuildConfig) /bl:$(Build.Arcade.LogsPath)/$(_BuildConfig)/pack.binlog $(_OfficialBuildIdArgs)
@@ -79,3 +79,24 @@ stages:
7979
# only for workloads
8080
- script: $(_buildScript) -restore -build -sign $(_SignArgs) -publish $(_PublishArgs) -configuration $(_BuildConfig) /bl:$(Build.Arcade.LogsPath)/$(_BuildConfig)/build-workloads.binlog -projects src/Workload/workloads.csproj $(_OfficialBuildIdArgs)
8181
displayName: Build Workloads, Sign & Publish
82+
83+
- task: CopyFiles@2
84+
displayName: Copy assemblies for APIScan
85+
inputs:
86+
SourceFolder: '$(Build.SourcesDirectory)\artifacts\bin\Controls.Core'
87+
Contents: |
88+
**/*.dll
89+
**/*.pdb
90+
TargetFolder: '$(Agent.TempDirectory)\APIScanFiles'
91+
92+
- task: CopyFiles@2
93+
displayName: Copy Metadata
94+
inputs:
95+
SourceFolder: '$(Build.SourcesDirectory)\artifacts\packages\$(_BuildConfig)\Shipping\metadata'
96+
Contents: |
97+
**/*.json
98+
TargetFolder: '$(Agent.TempDirectory)\metadata'
99+
100+
- ${{ each step in parameters.postSteps }}:
101+
- ${{ each pair in step }}:
102+
${{ pair.key }}: ${{ pair.value }}

eng/pipelines/arcade/variables.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,12 @@ variables:
2626
value: false
2727
- name: _OfficialBuildIdArgs
2828
value: /p:OfficialBuildId=$(_BuildOfficalId) /p:_SkipUpdateBuildNumber=true
29+
- name: ApiScanAppId
30+
value: cbde2fca-1ca1-47f7-8212-fcdf1a556eb2
31+
- name: ApiScanTenantId
32+
value: 72f988bf-86f1-41af-91ab-2d7cd011db47
33+
- name: ApiScanServiceConnectionId
34+
value: 334a6802-ebad-4fb1-bc3b-105bcc70bda2
2935
# Produce test-signed build for PR and Public builds
3036
- ${{ if or(eq(variables['_RunAsPublic'], 'true'), eq(variables['Build.Reason'], 'PullRequest')) }}:
3137
# needed for darc (dependency flow) publishing

eng/pipelines/azure-pipelines-internal.yml

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,13 @@ extends:
9595
skipAndroidCreateAvds: true
9696
skipProvisioning: true
9797
skipXcode: true
98-
# Publish and validation steps. Only run in official builds
98+
99+
- template: /eng/pipelines/arcade/stage-api-scan.yml@self
100+
parameters:
101+
pool: ${{ parameters.VM_IMAGE_HOST }}
102+
dependsOnStage: Pack
103+
104+
# Publish and validation steps. Only run in official builds
99105
- template: /eng/common/templates-official/post-build/post-build.yml@self
100106
parameters:
101107
publishingInfraVersion: 3

0 commit comments

Comments
 (0)