Skip to content

Commit e45bcd0

Browse files
committed
Move PR validation logic from the official build to a separate yml
1 parent b240d31 commit e45bcd0

File tree

3 files changed

+237
-76
lines changed

3 files changed

+237
-76
lines changed

azure-pipelines-official.yml

Lines changed: 5 additions & 69 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@ resources:
99
# SkipTests: false
1010
# SkipApplyOptimizationData: false
1111
# IbcDrop: 'default'
12-
# PRNumber: 'default'
1312

1413
# The variables `_DotNetArtifactsCategory` and `_DotNetValidationArtifactsCategory` are required for proper publishing of build artifacts. See https://github.com/dotnet/roslyn/pull/38259
1514
variables:
@@ -19,14 +18,8 @@ variables:
1918
value: .NETCoreValidation
2019
- group: DotNet-Roslyn-SDLValidation-Params
2120

22-
# To retrieve OptProf data we need to authenticate to the VS drop storage.
23-
# If the pipeline is running in DevDiv, the account has access to the VS drop storage.
24-
# Get $AccessToken-dotnet-build-bot-public-repo from DotNet-GitHub-Versions-Repo-Write
25-
- ${{ if eq(variables['System.TeamProject'], 'DevDiv') }}:
26-
- group: DotNet-GitHub-Versions-Repo-Write
27-
- name: _DevDivDropAccessToken
28-
value: $(System.AccessToken)
2921
# If the pipeline is running in dnceng:
22+
# To retrieve OptProf data we need to authenticate to the VS drop storage.
3023
# Get access token with $dn-bot-devdiv-drop-rw-code-rw and dn-bot-dnceng-build-rw-code-rw from DotNet-VSTS-Infra-Access
3124
# Get $dotnetfeed-storage-access-key-1 from DotNet-Blob-Feed
3225
# Get $microsoft-symbol-server-pat and $symweb-symbol-server-pat from DotNet-Symbol-Server-Pats
@@ -54,31 +47,13 @@ stages:
5447
- job: OfficialBuild
5548
displayName: Official Build
5649
timeoutInMinutes: 360
57-
# Conditionally set build pool so we can share this YAML when building with different pipeline (devdiv vs dnceng)
50+
# Conditionally set build pool so we can share this YAML when building with different pipeline
5851
pool:
59-
${{ if eq(variables['System.TeamProject'], 'DevDiv') }}:
60-
name: VSEngSS-MicroBuild2017
61-
demands:
62-
- msbuild
63-
- visualstudio
64-
- DotNetFramework
6552
${{ if eq(variables['System.TeamProject'], 'internal') }}:
6653
name: NetCoreInternal-Pool
6754
queue: BuildPool.Server.Amd64.VS2017
6855

6956
steps:
70-
# Make sure our two pipelines generate builds with distinct build numbers to avoid confliction.
71-
# i.e. DevDiv builds will have even rev# whereas dnceng builds will be odd.
72-
- task: PowerShell@2
73-
displayName: Update BuildNumber
74-
inputs:
75-
filePath: 'eng\update-build-number.ps1'
76-
${{ if eq(variables['System.TeamProject'], 'DevDiv') }}:
77-
arguments: '-buildNumber $(Build.BuildNumber) -oddOrEven even'
78-
${{ if eq(variables['System.TeamProject'], 'internal') }}:
79-
arguments: '-buildNumber $(Build.BuildNumber) -oddOrEven odd'
80-
condition: eq(variables['System.JobAttempt'], '1')
81-
8257
- powershell: Write-Host "##vso[task.setvariable variable=SourceBranchName]$('$(Build.SourceBranch)'.Substring('refs/heads/'.Length))"
8358
displayName: Setting SourceBranchName variable
8459
condition: succeeded()
@@ -88,23 +63,7 @@ stages:
8863
inputs:
8964
type: 'Build'
9065
tags: 'OfficialBuild'
91-
condition: and(succeeded(), endsWith(variables['SourceBranchName'], '-vs-deps'), eq(variables['PRNumber'], 'default'))
92-
93-
- task: tagBuildOrRelease@0
94-
displayName: Tag PR validation build
95-
inputs:
96-
type: 'Build'
97-
tags: |
98-
PRValidationBuild
99-
PRNumber:$(PRNumber)
100-
condition: and(succeeded(), ne(variables['PRNumber'], 'default'))
101-
102-
- task: PowerShell@2
103-
displayName: Setup branch for insertion validation
104-
inputs:
105-
filePath: 'eng\setup-pr-validation.ps1'
106-
arguments: '-sourceBranchName $(SourceBranchName) -prNumber $(PRNumber)'
107-
condition: and(succeeded(), ne(variables['PRNumber'], 'default'))
66+
condition: and(succeeded(), endsWith(variables['SourceBranchName'], '-vs-deps'))
10867

10968
- task: tagBuildOrRelease@0
11069
displayName: Tag main validation build
@@ -132,20 +91,16 @@ stages:
13291
# Authenticate with service connections to be able to publish packages to external nuget feeds.
13392
- task: NuGetAuthenticate@0
13493
inputs:
135-
${{ if eq(variables['System.TeamProject'], 'DevDiv') }}:
136-
nuGetServiceConnections: azure-public/vs-impl, azure-public/vssdk
13794
${{ if eq(variables['System.TeamProject'], 'internal') }}:
13895
nuGetServiceConnections: azure-public/vs-impl, azure-public/vssdk, devdiv/engineering
13996

140-
# Needed because the dnceng image we build on fails the next task without it
97+
# Needed because the build fails the NuGet Tools restore without it
14198
- task: UseDotNet@2
14299
displayName: 'Use .NET Core sdk'
143100
inputs:
144101
packageType: sdk
145102
useGlobalJson: true
146103
workingDirectory: '$(Build.SourcesDirectory)'
147-
installationPath: '$(Build.SourcesDirectory)/.dotnet'
148-
condition: eq(variables['System.TeamProject'], 'internal')
149104

150105
# Needed to restore the Microsoft.DevDiv.Optimization.Data.PowerShell package
151106
- task: NuGetCommand@2
@@ -202,7 +157,7 @@ stages:
202157
inputs:
203158
filePath: 'eng\publish-assets.ps1'
204159
arguments: '-configuration $(BuildConfiguration) -branchName "$(SourceBranchName)"'
205-
condition: and(succeeded(), eq(variables['PRNumber'], 'default'))
160+
condition: succeeded()
206161

207162
# Publish OptProf configuration files
208163
# The env variable is required to enable cross account access using PAT (dnceng -> devdiv)
@@ -272,9 +227,6 @@ stages:
272227
command: push
273228
packagesToPush: '$(Build.SourcesDirectory)\artifacts\VSSetup\$(BuildConfiguration)\DevDivPackages\**\*.nupkg'
274229
allowPackageConflicts: true
275-
${{ if eq(variables['System.TeamProject'], 'DevDiv') }}:
276-
feedsToUse: config
277-
publishVstsFeed: '97a41293-2972-4f48-8c0e-05493ae82010'
278230
${{ if eq(variables['System.TeamProject'], 'internal') }}:
279231
nuGetFeedType: external
280232
publishFeedCredentials: 'DevDiv - VS package feed'
@@ -315,26 +267,10 @@ stages:
315267
publishUsingPipelines: true
316268
dependsOn:
317269
- OfficialBuild
318-
${{ if eq(variables['System.TeamProject'], 'DevDiv') }}:
319-
queue:
320-
name: Hosted VS2017
321270
${{ if eq(variables['System.TeamProject'], 'internal') }}:
322271
pool:
323272
vmImage: vs2017-win2016
324273

325-
# We need to skip post-build stages for PR validation build, but it can only be identified by
326-
# the runtime variable 'PRNumber', thus this dummy stage. Also the dummy job is required
327-
# otherwise AzDO would just repeat jobs from previous stage.
328-
- stage: SetValidateDependency
329-
displayName: Setup the dependency for post-build stages
330-
condition: and(succeeded(), eq(variables['PRNumber'], 'default'))
331-
jobs:
332-
- job: Log
333-
displayName: Log
334-
steps:
335-
- powershell: Write-Host "Setup the dependency for post-build stages."
336-
displayName: Log
337-
338274
- ${{ if and(ne(variables['System.TeamProject'], 'public'), notin(variables['Build.Reason'], 'PullRequest')) }}:
339275
- template: eng\common\templates\post-build\post-build.yml
340276
parameters:

azure-pipelines-validation.yml

Lines changed: 209 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,209 @@
1+
resources:
2+
- repo: self
3+
clean: true
4+
5+
# Variables defined in yml cannot be overridden at queue time instead overrideable variables must be defined in the web gui.
6+
# Commenting out until AzDO supports something like the runtime parameters outlined here: https://github.com/Microsoft/azure-pipelines-yaml/pull/129
7+
#variables:
8+
# SignType: test
9+
# SkipTests: true
10+
# SkipApplyOptimizationData: false
11+
# IbcDrop: 'default'
12+
# PRNumber: 'REQUIRED'
13+
# CommitSHA: 'REQUIRED'
14+
15+
# The variables `_DotNetArtifactsCategory` and `_DotNetValidationArtifactsCategory` are required for proper publishing of build artifacts. See https://github.com/dotnet/roslyn/pull/38259
16+
variables:
17+
- name: _DotNetArtifactsCategory
18+
value: .NETCore
19+
- name: _DotNetValidationArtifactsCategory
20+
value: .NETCoreValidation
21+
- group: DotNet-Roslyn-SDLValidation-Params
22+
23+
# To retrieve OptProf data we need to authenticate to the VS drop storage.
24+
# If the pipeline is running in DevDiv, the account has access to the VS drop storage.
25+
# Get $AccessToken-dotnet-build-bot-public-repo from DotNet-GitHub-Versions-Repo-Write
26+
- ${{ if eq(variables['System.TeamProject'], 'DevDiv') }}:
27+
- group: DotNet-GitHub-Versions-Repo-Write
28+
- name: _DevDivDropAccessToken
29+
value: $(System.AccessToken)
30+
31+
stages:
32+
- stage: build
33+
displayName: Build and Test
34+
35+
jobs:
36+
37+
- job: OfficialTestBuild
38+
displayName: Official Test Build
39+
timeoutInMinutes: 360
40+
# Conditionally set build pool so we can share this YAML when building with different pipeline
41+
pool:
42+
${{ if eq(variables['System.TeamProject'], 'DevDiv') }}:
43+
name: VSEngSS-MicroBuild2017
44+
demands:
45+
- msbuild
46+
- visualstudio
47+
- DotNetFramework
48+
49+
steps:
50+
- powershell: Write-Host "##vso[task.setvariable variable=SourceBranchName]$('$(Build.SourceBranch)'.Substring('refs/heads/'.Length))"
51+
displayName: Setting SourceBranchName variable
52+
condition: succeeded()
53+
54+
- task: tagBuildOrRelease@0
55+
displayName: Tag PR validation build
56+
inputs:
57+
type: 'Build'
58+
tags: |
59+
PRValidationBuild
60+
PRNumber:$(PRNumber)
61+
condition: succeeded()
62+
63+
- task: PowerShell@2
64+
displayName: Setup branch for insertion validation
65+
inputs:
66+
filePath: 'eng\setup-pr-validation.ps1'
67+
arguments: '-sourceBranchName $(SourceBranchName) -prNumber $(PRNumber) -commitSHA $(CommitSHA)'
68+
condition: succeeded()
69+
70+
- powershell: Write-Host "##vso[task.setvariable variable=VisualStudio.DropName]Products/$(System.TeamProject)/$(Build.Repository.Name)/$(SourceBranchName)/$(Build.BuildNumber)"
71+
displayName: Setting VisualStudio.DropName variable
72+
73+
- task: NuGetToolInstaller@0
74+
inputs:
75+
versionSpec: '4.9.2'
76+
77+
# Authenticate with service connections to be able to publish packages to external nuget feeds.
78+
- task: NuGetAuthenticate@0
79+
inputs:
80+
${{ if eq(variables['System.TeamProject'], 'DevDiv') }}:
81+
nuGetServiceConnections: azure-public/vs-impl, azure-public/vssdk
82+
83+
# Needed to restore the Microsoft.DevDiv.Optimization.Data.PowerShell package
84+
- task: NuGetCommand@2
85+
displayName: Restore internal tools
86+
inputs:
87+
command: restore
88+
feedsToUse: config
89+
restoreSolution: 'eng\common\internal\Tools.csproj'
90+
nugetConfigPath: 'NuGet.config'
91+
restoreDirectory: '$(Build.SourcesDirectory)\.packages'
92+
93+
- task: MicroBuildSigningPlugin@2
94+
inputs:
95+
signType: $(SignType)
96+
zipSources: false
97+
# If running in dnceng, we need to use a feed different from default
98+
${{ if eq(variables['System.TeamProject'], 'internal') }}:
99+
feedSource: https://dnceng.pkgs.visualstudio.com/_packaging/MicroBuildToolset/nuget/v3/index.json
100+
condition: and(succeeded(), in(variables['SignType'], 'test', 'real'))
101+
102+
- task: PowerShell@2
103+
displayName: Build
104+
inputs:
105+
filePath: eng/build.ps1
106+
arguments: -ci
107+
-restore
108+
-build
109+
-pack
110+
-sign
111+
-publish
112+
-binaryLog
113+
-configuration $(BuildConfiguration)
114+
-officialBuildId $(Build.BuildNumber)
115+
-officialSkipTests $(SkipTests)
116+
-officialSkipApplyOptimizationData $(SkipApplyOptimizationData)
117+
-officialSourceBranchName $(SourceBranchName)
118+
-officialIbcDrop $(IbcDrop)
119+
-officialVisualStudioDropAccessToken $(_DevDivDropAccessToken)
120+
/p:RepositoryName=$(Build.Repository.Name)
121+
/p:VisualStudioDropName=$(VisualStudio.DropName)
122+
/p:DotNetSignType=$(SignType)
123+
/p:DotNetPublishToBlobFeed=false
124+
/p:DotNetPublishBlobFeedKey=$(dotnetfeed-storage-access-key-1)
125+
/p:DotNetPublishBlobFeedUrl=https://dotnetfeed.blob.core.windows.net/dotnet-core/index.json
126+
/p:PublishToSymbolServer=false
127+
/p:DotNetSymbolServerTokenMsdl=$(microsoft-symbol-server-pat)
128+
/p:DotNetSymbolServerTokenSymWeb=$(symweb-symbol-server-pat)
129+
/p:DotNetArtifactsCategory=$(_DotNetArtifactsCategory)
130+
/p:DotnetPublishUsingPipelines=false
131+
condition: succeeded()
132+
133+
# Publish OptProf generated JSON files as a build artifact. This allows for easy inspection from
134+
# a build execution.
135+
- task: PublishBuildArtifacts@1
136+
displayName: Publish OptProf Data Files
137+
inputs:
138+
PathtoPublish: '$(Build.SourcesDirectory)\artifacts\OptProf\$(BuildConfiguration)\Data'
139+
ArtifactName: 'OptProf Data Files'
140+
condition: succeeded()
141+
142+
- task: PublishBuildArtifacts@1
143+
displayName: Publish Logs
144+
inputs:
145+
PathtoPublish: '$(Build.SourcesDirectory)\artifacts\log\$(BuildConfiguration)'
146+
ArtifactName: 'Build Diagnostic Files'
147+
publishLocation: Container
148+
continueOnError: true
149+
condition: succeededOrFailed()
150+
151+
- task: PublishBuildArtifacts@1
152+
displayName: Publish Ngen Logs
153+
inputs:
154+
PathtoPublish: '$(Build.SourcesDirectory)\artifacts\log\$(BuildConfiguration)\ngen'
155+
ArtifactName: 'NGen Logs'
156+
publishLocation: Container
157+
continueOnError: true
158+
condition: succeeded()
159+
160+
- task: PublishTestResults@2
161+
displayName: Publish xUnit Test Results
162+
inputs:
163+
testRunner: XUnit
164+
testResultsFiles: '$(Build.SourcesDirectory)\artifacts\TestResults\$(BuildConfiguration)\*.xml'
165+
mergeTestResults: true
166+
testRunTitle: 'Unit Tests'
167+
condition: and(succeededOrFailed(), ne(variables['SkipTests'], 'true'))
168+
169+
# Publishes setup VSIXes to a drop.
170+
# Note: The insertion tool looks for the display name of this task in the logs.
171+
- task: ms-vseng.MicroBuildTasks.4305a8de-ba66-4d8b-b2d1-0dc4ecbbf5e8.MicroBuildUploadVstsDropFolder@1
172+
displayName: Upload VSTS Drop
173+
inputs:
174+
DropName: $(VisualStudio.DropName)
175+
DropFolder: 'artifacts\VSSetup\$(BuildConfiguration)\Insertion'
176+
AccessToken: $(_DevDivDropAccessToken)
177+
condition: succeeded()
178+
179+
# Publish insertion packages to CoreXT store.
180+
- task: NuGetCommand@2
181+
displayName: Publish CoreXT Packages
182+
inputs:
183+
command: push
184+
packagesToPush: '$(Build.SourcesDirectory)\artifacts\VSSetup\$(BuildConfiguration)\DevDivPackages\**\*.nupkg'
185+
allowPackageConflicts: true
186+
${{ if eq(variables['System.TeamProject'], 'DevDiv') }}:
187+
feedsToUse: config
188+
publishVstsFeed: '97a41293-2972-4f48-8c0e-05493ae82010'
189+
condition: succeeded()
190+
191+
# Publish an artifact that the RoslynInsertionTool is able to find by its name.
192+
- task: PublishBuildArtifacts@1
193+
displayName: Publish Artifact VSSetup
194+
inputs:
195+
PathtoPublish: 'artifacts\VSSetup\$(BuildConfiguration)'
196+
ArtifactName: 'VSSetup'
197+
condition: succeeded()
198+
199+
# Publish Asset Manifests for Build Asset Registry job
200+
- task: PublishBuildArtifacts@1
201+
displayName: Publish Asset Manifests
202+
inputs:
203+
PathtoPublish: '$(Build.SourcesDirectory)/artifacts/log/$(BuildConfiguration)/AssetManifest'
204+
ArtifactName: AssetManifests
205+
condition: succeeded()
206+
207+
- task: ms-vseng.MicroBuildTasks.521a94ea-9e68-468a-8167-6dcf361ea776.MicroBuildCleanup@1
208+
displayName: Perform Cleanup Tasks
209+
condition: succeededOrFailed()

0 commit comments

Comments
 (0)