Skip to content
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
18 changes: 12 additions & 6 deletions azure-pipelines-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ trigger:
exclude:
# Since the version of VS on the integration VM images are a moving target,
# we are unable to reliably run integration tests on servicing branches.
- release/dev17.0-vs-deps
- release/dev17.2
- release/dev17.3
- release/dev17.8
- release/dev17.10
- release/dev17.12

# Branches that trigger builds on PR
pr:
Expand All @@ -26,19 +26,25 @@ pr:
exclude:
# Since the version of VS on the integration VM images are a moving target,
# we are unable to reliably run integration tests on servicing branches.
- release/dev17.0-vs-deps
- release/dev17.2
- release/dev17.3
- release/dev17.8
- release/dev17.10
- release/dev17.12
paths:
exclude:
- docs/*
- eng/config/OptProf.json
- eng/config/PublishData.json
- eng/setup-pr-validation.ps1
- .vscode/*
- .github/*
- .devcontainer/*
- .git-blame-ignore-revs
- .vsconfig
- azure-pipelines-compliance.yml
- azure-pipelines-integration-dartlab.yml
- azure-pipelines-integration-scouting.yml
- azure-pipelines-official.yml
- azure-pipelines-pr-validation.yml
- CODE-OF-CONDUCT.md
- CONTRIBUTING.md
- README.md
Expand Down
5 changes: 4 additions & 1 deletion azure-pipelines-pr-validation.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ parameters:
type: number
- name: CommitSHA
type: string
- name: EnforceLatestCommit
type: boolean
default: true
- name: VisualStudioBranchName
type: string
default: default
Expand Down Expand Up @@ -195,7 +198,7 @@ extends:
displayName: Setup branch for insertion validation
inputs:
filePath: 'eng\setup-pr-validation.ps1'
arguments: '-sourceBranchName $(SourceBranchName) -prNumber ${{ parameters.PRNumber }} -commitSHA ${{ parameters.CommitSHA }}'
arguments: '-sourceBranchName $(SourceBranchName) -prNumber ${{ parameters.PRNumber }} -commitSHA ${{ parameters.CommitSHA }} -enforceLatestCommit ${{ iif(parameters.EnforceLatestCommit, '1', '0') }}'
condition: succeeded()

- powershell: Write-Host "##vso[task.setvariable variable=VisualStudio.DropName]Products/$(System.TeamProject)/$(Build.Repository.Name)/$(SourceBranchName)/$(OriginalBuildNumber)"
Expand Down
7 changes: 7 additions & 0 deletions azure-pipelines.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,20 @@ pr:
paths:
exclude:
- docs/*
- eng/config/OptProf.json
- eng/config/PublishData.json
- eng/setup-pr-validation.ps1
- src/LanguageServer/Microsoft.CommonLanguageServerProtocol.Framework/README.md
- .vscode/*
- .github/*
- .devcontainer/*
- .git-blame-ignore-revs
- .vsconfig
- azure-pipelines-compliance.yml
- azure-pipelines-integration-dartlab.yml
- azure-pipelines-integration-scouting.yml
- azure-pipelines-official.yml
- azure-pipelines-pr-validation.yml
- CODE-OF-CONDUCT.md
- CONTRIBUTING.md
- README.md
Expand Down
36 changes: 24 additions & 12 deletions eng/setup-pr-validation.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
param (
[string]$sourceBranchName,
[string]$prNumber,
[string]$commitSHA)
[string]$commitSHA,
[boolean]$enforceLatestCommit)

try {
# name and email are only used for merge commit, it doesn't really matter what we put in there.
Expand All @@ -13,28 +14,39 @@ try {
Write-Host "##vso[task.LogIssue type=warning;]The base branch for insertion validation is $sourceBranchName, which is not a vs-deps branch."
}

Write-Host "Validating the PR head matches the specified commit SHA ($commitSHA)..."
if ($commitSHA.Length -lt 7) {
Write-Host "##vso[task.LogIssue type=error;]The PR Commit SHA must be at least 7 characters long."
exit 1
}

if ($enforceLatestCommit) {
Write-Host "Validating the PR head matches the specified commit SHA ($commitSHA)..."
Write-Host "Getting the hash of refs/pull/$prNumber/head..."
$remoteRef = git ls-remote origin refs/pull/$prNumber/head
Write-Host ($remoteRef | Out-String)

Write-Host "Getting the hash of refs/pull/$prNumber/head..."
$remoteRef = git ls-remote origin refs/pull/$prNumber/head
Write-Host ($remoteRef | Out-String)

$prHeadSHA = $remoteRef.Split()[0]
if (!$prHeadSHA.StartsWith($commitSHA)) {
Write-Host "##vso[task.LogIssue type=error;]The PR's Head SHA ($prHeadSHA) does not begin with the specified commit SHA ($commitSHA). Unreviewed changes may have been pushed to the PR."
exit 1
$prHeadSHA = $remoteRef.Split()[0]
if (!$prHeadSHA.StartsWith($commitSHA)) {
Write-Host "##vso[task.LogIssue type=error;]The PR's Head SHA ($prHeadSHA) does not begin with the specified commit SHA ($commitSHA). Unreviewed changes may have been pushed to the PR."
exit 1
}
}

Write-Host "Setting up the build for PR validation by merging refs/pull/$prNumber/merge into $sourceBranchName..."
Write-Host "Setting up the build for PR validation by pulling refs/pull/$prNumber/merge..."
git pull origin refs/pull/$prNumber/merge
if (!$?) {
Write-Host "##vso[task.LogIssue type=error;]Merging branch refs/pull/$prNumber/merge failed."
Write-Host "##vso[task.LogIssue type=error;]Pulling branch refs/pull/$prNumber/merge failed."
exit 1
}

if (!$enforceLatestCommit) {
Write-Host "Checking out the specified commit SHA ($commitSHA)..."
git checkout $commitSHA
if (!$?) {
Write-Host "##vso[task.LogIssue type=error;]Checking out commit SHA $commitSHA failed."
exit 1
}
}
}
catch {
Write-Host $_
Expand Down