Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move PR validation logic from the official build to a separate yml #54053

Merged
merged 5 commits into from
Jun 17, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
118 changes: 19 additions & 99 deletions azure-pipelines-official.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ resources:
# SkipTests: false
# SkipApplyOptimizationData: false
# IbcDrop: 'default'
# PRNumber: 'default'

# The variables `_DotNetArtifactsCategory` and `_DotNetValidationArtifactsCategory` are required for proper publishing of build artifacts. See https://github.com/dotnet/roslyn/pull/38259
variables:
Expand All @@ -20,25 +19,17 @@ variables:
- group: DotNet-Roslyn-SDLValidation-Params

# 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
- ${{ if eq(variables['System.TeamProject'], 'DevDiv') }}:
- group: DotNet-GitHub-Versions-Repo-Write
- name: _DevDivDropAccessToken
value: $(System.AccessToken)
# If the pipeline is running in dnceng:
# Get access token with $dn-bot-devdiv-drop-rw-code-rw and dn-bot-dnceng-build-rw-code-rw from DotNet-VSTS-Infra-Access
# Get $dotnetfeed-storage-access-key-1 from DotNet-Blob-Feed
# Get $microsoft-symbol-server-pat and $symweb-symbol-server-pat from DotNet-Symbol-Server-Pats
# Get $AccessToken-dotnet-build-bot-public-repo from DotNet-Versions-Publish
- ${{ if eq(variables['System.TeamProject'], 'internal') }}:
- group: DotNet-Blob-Feed
- group: DotNet-Symbol-Server-Pats
- group: DotNet-Versions-Publish
- group: DotNet-VSTS-Infra-Access
- group: DotNet-DevDiv-Insertion-Workflow-Variables
- name: _DevDivDropAccessToken
value: $(dn-bot-devdiv-drop-rw-code-rw)
- group: DotNet-Blob-Feed
- group: DotNet-Symbol-Server-Pats
- group: DotNet-Versions-Publish
- group: DotNet-VSTS-Infra-Access
- group: DotNet-DevDiv-Insertion-Workflow-Variables
- name: _DevDivDropAccessToken
value: $(dn-bot-devdiv-drop-rw-code-rw)

stages:
- stage: build
Expand All @@ -54,31 +45,11 @@ stages:
- job: OfficialBuild
displayName: Official Build
timeoutInMinutes: 360
# Conditionally set build pool so we can share this YAML when building with different pipeline (devdiv vs dnceng)
pool:
${{ if eq(variables['System.TeamProject'], 'DevDiv') }}:
name: VSEngSS-MicroBuild2017
demands:
- msbuild
- visualstudio
- DotNetFramework
${{ if eq(variables['System.TeamProject'], 'internal') }}:
name: NetCoreInternal-Pool
queue: BuildPool.Server.Amd64.VS2017
name: NetCoreInternal-Pool
queue: BuildPool.Server.Amd64.VS2017

steps:
# Make sure our two pipelines generate builds with distinct build numbers to avoid confliction.
# i.e. DevDiv builds will have even rev# whereas dnceng builds will be odd.
- task: PowerShell@2
displayName: Update BuildNumber
inputs:
filePath: 'eng\update-build-number.ps1'
${{ if eq(variables['System.TeamProject'], 'DevDiv') }}:
arguments: '-buildNumber $(Build.BuildNumber) -oddOrEven even'
${{ if eq(variables['System.TeamProject'], 'internal') }}:
arguments: '-buildNumber $(Build.BuildNumber) -oddOrEven odd'
condition: eq(variables['System.JobAttempt'], '1')

- powershell: Write-Host "##vso[task.setvariable variable=SourceBranchName]$('$(Build.SourceBranch)'.Substring('refs/heads/'.Length))"
displayName: Setting SourceBranchName variable
condition: succeeded()
Expand All @@ -88,23 +59,7 @@ stages:
inputs:
type: 'Build'
tags: 'OfficialBuild'
condition: and(succeeded(), endsWith(variables['SourceBranchName'], '-vs-deps'), eq(variables['PRNumber'], 'default'))

- task: tagBuildOrRelease@0
displayName: Tag PR validation build
inputs:
type: 'Build'
tags: |
PRValidationBuild
PRNumber:$(PRNumber)
condition: and(succeeded(), ne(variables['PRNumber'], 'default'))

- task: PowerShell@2
displayName: Setup branch for insertion validation
inputs:
filePath: 'eng\setup-pr-validation.ps1'
arguments: '-sourceBranchName $(SourceBranchName) -prNumber $(PRNumber)'
condition: and(succeeded(), ne(variables['PRNumber'], 'default'))
condition: and(succeeded(), endsWith(variables['SourceBranchName'], '-vs-deps'))

- task: tagBuildOrRelease@0
displayName: Tag main validation build
Expand All @@ -118,8 +73,7 @@ stages:
displayName: Merge main-vs-deps into source branch
inputs:
filePath: 'scripts\merge-vs-deps.ps1'
${{ if eq(variables['System.TeamProject'], 'internal') }}:
arguments: '-accessToken $(dn-bot-dnceng-build-rw-code-rw)'
arguments: '-accessToken $(dn-bot-dnceng-build-rw-code-rw)'
condition: and(succeeded(), eq(variables['SourceBranchName'], 'main'))

- powershell: Write-Host "##vso[task.setvariable variable=VisualStudio.DropName]Products/$(System.TeamProject)/$(Build.Repository.Name)/$(SourceBranchName)/$(Build.BuildNumber)"
Expand All @@ -132,20 +86,15 @@ stages:
# Authenticate with service connections to be able to publish packages to external nuget feeds.
- task: NuGetAuthenticate@0
inputs:
${{ if eq(variables['System.TeamProject'], 'DevDiv') }}:
nuGetServiceConnections: azure-public/vs-impl, azure-public/vssdk
${{ if eq(variables['System.TeamProject'], 'internal') }}:
nuGetServiceConnections: azure-public/vs-impl, azure-public/vssdk, devdiv/engineering
nuGetServiceConnections: azure-public/vs-impl, azure-public/vssdk, devdiv/engineering

# Needed because the dnceng image we build on fails the next task without it
# 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)'
installationPath: '$(Build.SourcesDirectory)/.dotnet'
condition: eq(variables['System.TeamProject'], 'internal')

# Needed to restore the Microsoft.DevDiv.Optimization.Data.PowerShell package
- task: NuGetCommand@2
Expand All @@ -161,9 +110,7 @@ stages:
inputs:
signType: $(SignType)
zipSources: false
# If running in dnceng, we need to use a feed different from default
${{ if eq(variables['System.TeamProject'], 'internal') }}:
feedSource: https://dnceng.pkgs.visualstudio.com/_packaging/MicroBuildToolset/nuget/v3/index.json
feedSource: https://dnceng.pkgs.visualstudio.com/_packaging/MicroBuildToolset/nuget/v3/index.json
condition: and(succeeded(), in(variables['SignType'], 'test', 'real'))

- task: PowerShell@2
Expand Down Expand Up @@ -202,7 +149,7 @@ stages:
inputs:
filePath: 'eng\publish-assets.ps1'
arguments: '-configuration $(BuildConfiguration) -branchName "$(SourceBranchName)"'
condition: and(succeeded(), eq(variables['PRNumber'], 'default'))
condition: succeeded()

# Publish OptProf configuration files
# The env variable is required to enable cross account access using PAT (dnceng -> devdiv)
Expand Down Expand Up @@ -272,12 +219,8 @@ stages:
command: push
packagesToPush: '$(Build.SourcesDirectory)\artifacts\VSSetup\$(BuildConfiguration)\DevDivPackages\**\*.nupkg'
allowPackageConflicts: true
${{ if eq(variables['System.TeamProject'], 'DevDiv') }}:
feedsToUse: config
publishVstsFeed: '97a41293-2972-4f48-8c0e-05493ae82010'
${{ if eq(variables['System.TeamProject'], 'internal') }}:
nuGetFeedType: external
publishFeedCredentials: 'DevDiv - VS package feed'
nuGetFeedType: external
publishFeedCredentials: 'DevDiv - VS package feed'
condition: succeeded()

# Publish an artifact that the RoslynInsertionTool is able to find by its name.
Expand Down Expand Up @@ -315,25 +258,8 @@ stages:
publishUsingPipelines: true
dependsOn:
- OfficialBuild
${{ if eq(variables['System.TeamProject'], 'DevDiv') }}:
queue:
name: Hosted VS2017
${{ if eq(variables['System.TeamProject'], 'internal') }}:
pool:
vmImage: vs2017-win2016

# We need to skip post-build stages for PR validation build, but it can only be identified by
# the runtime variable 'PRNumber', thus this dummy stage. Also the dummy job is required
# otherwise AzDO would just repeat jobs from previous stage.
- stage: SetValidateDependency
displayName: Setup the dependency for post-build stages
condition: and(succeeded(), eq(variables['PRNumber'], 'default'))
jobs:
- job: Log
displayName: Log
steps:
- powershell: Write-Host "Setup the dependency for post-build stages."
displayName: Log
pool:
vmImage: vs2017-win2016

- ${{ if and(ne(variables['System.TeamProject'], 'public'), notin(variables['Build.Reason'], 'PullRequest')) }}:
- template: eng\common\templates\post-build\post-build.yml
Expand All @@ -343,12 +269,6 @@ stages:
# https://github.com/dotnet/arcade/issues/2871 is resolved.
enableSymbolValidation: false
enableSourceLinkValidation: false
# It's important that post-build stages are depends on 'SetValidateDependency' stage instead of 'build',
# since we don't want to publish validation build.
validateDependsOn:
- SetValidateDependency
dependsOn:
- SetValidateDependency
# Enable SDL validation, passing through values from the 'DotNet-Roslyn-SDLValidation-Params' group.
SDLValidationParameters:
enable: true
Expand Down
Loading