forked from dotnet/roslyn
-
Notifications
You must be signed in to change notification settings - Fork 0
/
azure-pipelines-pr-validation.yml
344 lines (308 loc) · 14.2 KB
/
azure-pipelines-pr-validation.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
trigger: none
pr: none
resources:
repositories:
- repository: 1ESPipelineTemplates
type: git
name: 1ESPipelineTemplates/1ESPipelineTemplates
ref: refs/tags/release
parameters:
- name: PRNumber
type: number
- name: CommitSHA
type: string
- name: VisualStudioBranchName
type: string
default: default
- name: OptionalTitlePrefix
type: string
default: '[PR Validation]'
- name: InsertToolset
type: boolean
default: true
- name: SkipApplyOptimizationData
type: boolean
default: false
# The variables `_DotNetArtifactsCategory` and `_DotNetValidationArtifactsCategory` are required for proper publishing of build artifacts. See https://github.com/dotnet/roslyn/pull/38259
variables:
- name: _DotNetArtifactsCategory
value: .NETCore
- name: _DotNetValidationArtifactsCategory
value: .NETCoreValidation
- group: DotNet-Roslyn-SDLValidation-Params
- group: DotNet-Roslyn-Insertion-Variables
- name: Codeql.Enabled
value: false
- name: Codeql.SkipTaskAutoInjection
value: true
# To retrieve OptProf data we need to authenticate to the VS drop storage.
# If the pipeline is running in DevDiv, the account has access to the VS drop storage.
# Get $AccessToken-dotnet-build-bot-public-repo from DotNet-GitHub-Versions-Repo-Write
- group: DotNet-GitHub-Versions-Repo-Write
- name: _DevDivDropAccessToken
value: $(System.AccessToken)
extends:
template: v1/1ES.Unofficial.PipelineTemplate.yml@1ESPipelineTemplates
parameters:
sdl:
enableAllTools: false
pool:
name: VSEngSS-MicroBuild2022-1ES
demands:
- msbuild
- visualstudio
- DotNetFramework
customBuildTags:
- ES365AIMigrationTooling
stages:
- stage: build
displayName: Build and Test
jobs:
- job: PRValidationBuild
displayName: PR Validation Build
timeoutInMinutes: 360
templateContext:
outputs:
# Publish OptProf configuration files to the artifact service
- output: artifactsDrop
displayName: 'OptProf - Publish to Artifact Services - ProfilingInputs'
condition: succeeded()
dropServiceURI: 'https://devdiv.artifacts.visualstudio.com'
buildNumber: 'ProfilingInputs/$(System.TeamProject)/$(Build.Repository.Name)/$(SourceBranchName)/$(OriginalBuildNumber)'
sourcePath: '$(Build.SourcesDirectory)\artifacts\OptProf\$(BuildConfiguration)\Data'
toLowerCase: false
usePat: true
accessToken: $(_DevDivDropAccessToken)
retentionDays: 90
# Publish OptProf generated JSON files as a pipeline artifact. This allows for easy inspection from
# a build execution.
- output: pipelineArtifact
displayName: 'Publish OptProf Data Files'
condition: succeeded()
targetPath: '$(Build.SourcesDirectory)\artifacts\OptProf\$(BuildConfiguration)\Data'
artifactName: 'OptProf Data Files'
- output: pipelineArtifact
displayName: 'Publish Logs'
condition: succeededOrFailed()
targetPath: '$(Build.SourcesDirectory)\artifacts\log\$(BuildConfiguration)'
artifactName: 'Build Diagnostic Files'
publishLocation: Container
- output: pipelineArtifact
displayName: 'Publish Ngen Logs'
condition: succeeded()
targetPath: '$(Build.SourcesDirectory)\artifacts\log\$(BuildConfiguration)\ngen'
artifactName: 'NGen Logs'
publishLocation: Container
# Publishes setup VSIXes to a drop.
# Note: The insertion tool looks for the display name of this task in the logs.
- output: microBuildVstsDrop
displayName: Upload VSTS Drop
condition: succeeded()
dropFolder: 'artifacts\VSSetup\$(BuildConfiguration)\Insertion'
dropName: $(VisualStudio.DropName)
accessToken: $(_DevDivDropAccessToken)
dropRetentionDays: 90
# Publish insertion packages to CoreXT store.
- output: nuget
displayName: 'Publish CoreXT Packages'
condition: succeeded()
packageParentPath: '$(Build.SourcesDirectory)\artifacts\VSSetup\$(BuildConfiguration)\DevDivPackages'
packagesToPush: '$(Build.SourcesDirectory)\artifacts\VSSetup\$(BuildConfiguration)\DevDivPackages\**\*.nupkg'
allowPackageConflicts: true
nuGetFeedType: internal
publishVstsFeed: '97a41293-2972-4f48-8c0e-05493ae82010'
# Publish an artifact that the RoslynInsertionTool is able to find by its name.
- output: pipelineArtifact
displayName: 'Publish Artifact VSSetup'
condition: succeeded()
targetPath: 'artifacts\VSSetup\$(BuildConfiguration)'
artifactName: 'VSSetup'
# Publish our NuPkgs as an artifact. The name of this artifact must be PackageArtifacts as the
# arcade templates depend on the name.
- output: buildArtifacts
displayName: 'Publish Artifact Packages'
condition: succeeded()
PathtoPublish: 'artifacts\packages\$(BuildConfiguration)'
ArtifactName: 'PackageArtifacts'
# Publish Asset Manifests for Build Asset Registry job
- output: buildArtifacts
displayName: 'Publish Asset Manifests'
condition: succeeded()
PathtoPublish: '$(Build.SourcesDirectory)/artifacts/log/$(BuildConfiguration)/AssetManifest'
ArtifactName: AssetManifests
steps:
- powershell: Write-Host "##vso[task.setvariable variable=OriginalBuildNumber;isreadonly=true]$('$(Build.BuildNumber)')"
displayName: Setting OriginalBuildNumber variable
condition: succeeded()
- powershell: Write-Host "##vso[task.setvariable variable=SourceBranchName;isreadonly=true]$('$(Build.SourceBranch)'.Substring('refs/heads/'.Length))"
displayName: Setting SourceBranchName variable
condition: succeeded()
- task: Powershell@2
name: FancyBuild
displayName: Setting FancyBuild.BuildNumber
inputs:
targetType: inline
script: |
$pull_request = Invoke-RestMethod -Uri "https://api.github.com/repos/dotnet/roslyn/pulls/${{ parameters.PRNumber }}" `
-Headers @{
"Accept" = "application/vnd.github+json";
"X-GitHub-Api-Version" = "2022-11-28"
}
$buildNumberName = "$(OriginalBuildNumber) - $($pull_request.user.login) - '$($pull_request.title)'"
$buildNumberName = $buildNumberName -replace '["/:<>\|?@*]','_'
# Maximum buildnumber length is 255 chars and we are going to append to the end to ensure we have space.
if ($buildNumberName.Length -GT 253) {
$buildNumberName = $buildNumberName.Substring(0, 253)
}
# Avoid ever ending the BuildNumber with a `.` by always appending to it.
$buildNumberName += ' #'
Write-Host "##vso[task.setvariable variable=BuildNumber;isoutput=true;isreadonly=true]$buildNumberName"
Write-Host "##vso[build.updatebuildnumber]$buildNumberName"
- task: Powershell@2
displayName: Tag PR validation build
inputs:
targetType: inline
script: |
Write-Host "##vso[build.addBuildTag]OfficialBuild"
Write-Host "##vso[build.addBuildTag]${{ parameters.CommitSHA }}"
Write-Host "##vso[build.addBuildTag]PRNumber${{ parameters.PRNumber }}"
condition: succeeded()
- task: PowerShell@2
displayName: Setup branch for insertion validation
inputs:
filePath: 'eng\setup-pr-validation.ps1'
arguments: '-sourceBranchName $(SourceBranchName) -prNumber ${{ parameters.PRNumber }} -commitSHA ${{ parameters.CommitSHA }}'
condition: succeeded()
- powershell: Write-Host "##vso[task.setvariable variable=VisualStudio.DropName]Products/$(System.TeamProject)/$(Build.Repository.Name)/$(SourceBranchName)/$(OriginalBuildNumber)"
displayName: Setting VisualStudio.DropName variable
- task: NuGetToolInstaller@0
inputs:
versionSpec: '4.9.2'
# Authenticate with service connections to be able to publish packages to external nuget feeds.
- task: NuGetAuthenticate@1
inputs:
nuGetServiceConnections: azure-public/vs-impl, azure-public/vssdk
# Needed because the build fails the NuGet Tools restore without it
- task: UseDotNet@2
displayName: 'Use .NET Core sdk'
inputs:
packageType: sdk
useGlobalJson: true
workingDirectory: '$(Build.SourcesDirectory)'
# Needed to restore the Microsoft.DevDiv.Optimization.Data.PowerShell package
- task: NuGetCommand@2
displayName: Restore internal tools
inputs:
command: restore
feedsToUse: config
restoreSolution: 'eng\common\internal\Tools.csproj'
nugetConfigPath: 'NuGet.config'
restoreDirectory: '$(Build.SourcesDirectory)\.packages'
- task: MicroBuildSigningPlugin@4
inputs:
signType: $(SignType)
zipSources: false
condition: and(succeeded(), in(variables['SignType'], 'test', 'real'))
- task: PowerShell@2
displayName: Build
inputs:
filePath: eng/build.ps1
arguments: -ci
-prepareMachine
-restore
-build
-pack
-sign
-publish
-binaryLog
-configuration $(BuildConfiguration)
-officialBuildId $(OriginalBuildNumber)
-officialSkipTests $(SkipTests)
-officialSkipApplyOptimizationData $(SkipApplyOptimizationData)
-officialSourceBranchName $(SourceBranchName)
-officialIbcDrop $(IbcDrop)
-officialVisualStudioDropAccessToken $(_DevDivDropAccessToken)
/p:RepositoryName=$(Build.Repository.Name)
/p:VisualStudioDropName=$(VisualStudio.DropName)
/p:DotNetSignType=$(SignType)
/p:PublishToSymbolServer=true
/p:DotNetArtifactsCategory=$(_DotNetArtifactsCategory)
/p:DotnetPublishUsingPipelines=true
/p:IgnoreIbcMergeErrors=true
/p:GenerateSbom=true
/p:PreReleaseVersionLabel=pr-validation
condition: succeeded()
- template: /eng/common/templates-official/steps/generate-sbom.yml@self
- task: PowerShell@2
displayName: Publish Assets
inputs:
filePath: 'eng\publish-assets.ps1'
arguments: '-configuration $(BuildConfiguration) -branchName "$(SourceBranchName)" -prValidation'
condition: succeeded()
- task: PublishTestResults@2
displayName: Publish xUnit Test Results
inputs:
testRunner: XUnit
testResultsFiles: '$(Build.SourcesDirectory)\artifacts\TestResults\$(BuildConfiguration)\*.xml'
mergeTestResults: true
testRunTitle: 'Unit Tests'
condition: and(succeededOrFailed(), ne(variables['SkipTests'], 'true'))
# We need to reset the BuildNumber before we pass off to Arcade
- powershell: Write-Host "##vso[build.updatebuildnumber]$(OriginalBuildNumber)"
displayName: Reset BuildNumber
condition: succeeded()
# Publish to Build Asset Registry
- template: /eng/common/templates-official/job/publish-build-assets.yml@self
parameters:
publishUsingPipelines: true
dependsOn:
- PRValidationBuild
pool:
name: VSEngSS-MicroBuild2022-1ES
- stage: insert
dependsOn:
- build
- publish_using_darc
displayName: Insert to VS
jobs:
- job: insert
variables:
FancyBuildNumber: $[stageDependencies.build.PRValidationBuild.outputs['FancyBuild.BuildNumber']]
displayName: Insert to VS
pool:
name: VSEngSS-MicroBuild2022-1ES
steps:
- download: current
artifact: VSSetup
- powershell: |
$branchName = "$(Build.SourceBranch)".Substring("refs/heads/".Length)
Write-Host "##vso[task.setvariable variable=ComponentBranchName]$branchName"
displayName: Get Branch Name
- template: /eng/pipelines/insert.yml@self
parameters:
createDraftPR: true
autoComplete: false
insertToolset: ${{ parameters.InsertToolset }}
buildUserName: "[email protected]"
buildPassword: $(dn-bot-devdiv-build-e-code-full-release-e-packaging-r)
componentUserName: "[email protected]"
componentPassword: $(dn-bot-dnceng-build-e-code-full-release-e-packaging-r)
vsBranchName: ${{ parameters.VisualStudioBranchName }}
titlePrefix: ${{ parameters.OptionalTitlePrefix }}
sourceBranch: $(ComponentBranchName)
publishDataURI: "https://raw.githubusercontent.com/dotnet/roslyn/main/eng/config/PublishData.json"
queueSpeedometerValidation: true
dropPath: '$(Pipeline.Workspace)\VSSetup'
# Arcade is done so we can set BuildNumber back
- powershell: Write-Host "##vso[build.updatebuildnumber]$(FancyBuildNumber)"
displayName: Reset BuildNumber
condition: succeeded()
# Use post-build to publish symbol packages.
- template: /eng/common/templates-official/post-build/post-build.yml@self
parameters:
publishingInfraVersion: 3
# Symbol validation is not entirely reliable as of yet, so should be turned off until
# https://github.com/dotnet/arcade/issues/2871 is resolved.
enableSymbolValidation: false
enableSourceLinkValidation: false
SDLValidationParameters: false