Merge Mirror Branches into Integration Branches (#256)

This commit is contained in:
Nick Banks 2020-03-24 11:55:22 -07:00 коммит произвёл GitHub
Родитель 6a5d6ce1c3
Коммит 5233151382
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
4 изменённых файлов: 122 добавлений и 20 удалений

Просмотреть файл

@ -10,9 +10,11 @@ trigger:
include:
- master
- release/*
- integration/*
pr:
- master
- release/*
- integration/*
name: 0.$(Date:yyMM).$(DayOfMonth)$(Rev:rr).0
@ -25,6 +27,7 @@ stages:
- stage: build_windows
displayName: Build Windows
dependsOn: []
condition: startsWith(variables['Build.SourceBranch'], 'refs/heads/integration/')
jobs:
- template: ./templates/build-config-user.yml
parameters:
@ -54,6 +57,7 @@ stages:
- stage: build_winkernel
displayName: Build Windows Drivers
dependsOn: []
condition: startsWith(variables['Build.SourceBranch'], 'refs/heads/integration/')
jobs:
- template: ./templates/build-config-winkernel.yml
parameters:
@ -76,6 +80,7 @@ stages:
displayName: Build Verification Tests
dependsOn:
- build_windows
condition: and(succeeded(), startsWith(variables['Build.SourceBranch'], 'refs/heads/integration/'))
jobs:
- template: ./templates/run-bvt-int.yml
parameters:
@ -90,5 +95,30 @@ stages:
dependsOn:
- build_windows
- build_winkernel
condition: and(succeeded(), startsWith(variables['Build.SourceBranch'], 'refs/heads/integration/'))
jobs:
- template: ./templates/create-package.yml
#
# Merge to Integration
#
- stage: integrate
displayName: Integrate Branch
dependsOn: []
condition: not(startsWith(variables['Build.SourceBranch'], 'refs/heads/integration/'))
jobs:
- job: integrate
displayName: Integrate Branch
pool:
vmImage: windows-latest
variables:
runCodesignValidationInjection: false
steps:
- checkout: self
- task: PowerShell@2
displayName: Integrate Branch
inputs:
pwsh: true
filePath: .azure/scripts/integrate-branch.ps1
arguments: -Branch $(Build.SourceBranch)

Просмотреть файл

@ -128,7 +128,21 @@ stages:
- build_linux
condition: and(succeeded(), in(variables['Build.Reason'], 'IndividualCI', 'BatchedCI'), not(startsWith(variables['Build.SourceBranch'], 'refs/heads/feature/')))
jobs:
- template: ./templates/sync-mirror.yml
- job: mirror
displayName: Mirror branch
pool:
vmImage: windows-latest
steps:
- checkout: self
persistCredentials: true
- task: PowerShell@2
displayName: Sync Changes to AzDO Mirror Branch
inputs:
pwsh: true
filePath: .azure/scripts/sync-mirror.ps1
arguments: -Branch $(Build.SourceBranch)
env:
AzDO_PAT: $(AzDO_PAT)
#
# Build Verification Tests

Просмотреть файл

@ -0,0 +1,77 @@
<#
.SYNOPSIS
This synchronizes all the changes from mirror branch to the integration branch.
.EXAMPLE
integrate-branch.ps1
.EXAMPLE
integrate-branch.ps1 -Branch refs/heads/release/xxxx
#>
param (
[Parameter(Mandatory = $false)]
[string]$Branch = "refs/heads/master"
)
Set-StrictMode -Version 'Latest'
$PSDefaultParameterValues['*:ErrorAction'] = 'Stop'
# Redirect stderr to stdout for git.
$env:GIT_REDIRECT_STDERR = '2>&1'
# Remove the 'refs/heads/' prefix.
$MirrorBranch = $Branch.Substring(11)
# The integration branch is just the mirror branch prefixed with "integration/"
$IntegrationBranch = "integration/$MirrorBranch"
Write-Host "`n== Integrating changes in $MirrorBranch to $IntegrationBranch =="
# Make sure we can checkout the mirror branch.
Write-Host "`n== Checking out $MirrorBranch =="
git checkout $MirrorBranch
"LASTEXITCODE=$LASTEXITCODE"
if ($LASTEXITCODE) { Write-Error "Checkout mirror branch failed!" }
# Try to checkout the existing branch.
Write-Host "`n== Checking out $IntegrationBranch =="
git checkout $IntegrationBranch
"LASTEXITCODE=$LASTEXITCODE"
if ($LASTEXITCODE) {
# Failed to checkout existing branch, so create it and push it upstream.
Write-Host "`n== Creating $IntegrationBranch =="
git checkout -b $IntegrationBranch
"LASTEXITCODE=$LASTEXITCODE"
if ($LASTEXITCODE) { Write-Error "Create branch failed!" }
Write-Host "`n== Setting $IntegrationBranch upstream =="
git push --set-upstream origin $IntegrationBranch
"LASTEXITCODE=$LASTEXITCODE"
if ($LASTEXITCODE) { Write-Error "Push branch failed!" }
} else {
# Set identity for any merge commits.
git config user.email "quicdev@microsoft.com"
git config user.name "QUIC Dev Bot"
# Checkout successful. Merge the mirror changes.
Write-Host "`n== Merging $MirrorBranch into $IntegrationBranch =="
git merge $MirrorBranch
"LASTEXITCODE=$LASTEXITCODE"
if ($LASTEXITCODE) {
git merge --abort
Write-Error "Merge Failed! Run and handle the merge conflicts:`n`ngit checkout $IntegrationBranch`ngit merge $MirrorBranch`n"
}
# Push the changes upstream.
Write-Host "`n== Pushing $IntegrationBranch upstream =="
git push
"LASTEXITCODE=$LASTEXITCODE"
if ($LASTEXITCODE) { Write-Error "Push branch failed!" }
}
Write-Host "`n== Integration complete =="

Просмотреть файл

@ -1,19 +0,0 @@
# This template contains steps to sync the GitHub repo to the AzDO mirror repo.
jobs:
- job: mirror
displayName: Mirror branch
pool:
vmImage: windows-latest
steps:
- checkout: self
persistCredentials: true
- task: PowerShell@2
displayName: Sync Changes to AzDO Mirror Branch
inputs:
pwsh: true
filePath: .azure/scripts/sync-mirror.ps1
arguments: -Branch $(Build.SourceBranch)
env:
AzDO_PAT: $(AzDO_PAT)