diff --git a/azure-pipelines-integration.yml b/azure-pipelines-integration.yml index 241c0fec59dfc..afddf6a20c094 100644 --- a/azure-pipelines-integration.yml +++ b/azure-pipelines-integration.yml @@ -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: @@ -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 diff --git a/azure-pipelines-pr-validation.yml b/azure-pipelines-pr-validation.yml index d779e1a90d00a..bce51fb000190 100644 --- a/azure-pipelines-pr-validation.yml +++ b/azure-pipelines-pr-validation.yml @@ -13,6 +13,9 @@ parameters: type: number - name: CommitSHA type: string +- name: EnforceLatestCommit + type: boolean + default: true - name: VisualStudioBranchName type: string default: default @@ -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)" diff --git a/azure-pipelines.yml b/azure-pipelines.yml index 0f26c4fff3483..c178ac6eaaa41 100644 --- a/azure-pipelines.yml +++ b/azure-pipelines.yml @@ -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 diff --git a/eng/setup-pr-validation.ps1 b/eng/setup-pr-validation.ps1 index 44f3e7d07f6c8..d5d594deb41cd 100644 --- a/eng/setup-pr-validation.ps1 +++ b/eng/setup-pr-validation.ps1 @@ -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. @@ -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 $_