Repository navigation
[release/9.0.1xx] Backport a number of CI changes to make PRs work. - #25345
Conversation
rolfbjarne
commented
May 6, 2026
- [devops] Make the tests pipeline use a pr: trigger. ([devops] Make the tests pipeline use a pr: trigger. #25239)
- [devops] Make the API diff pipeline use a pr: trigger. ([devops] Make the API diff pipeline use a pr: trigger. #25284)
- [devops] Fix PR latest-commit detection ([devops] Fix PR latest-commit detection #25231)
- [devops] Disable implicit CI triggers on xamarin-macios-pr pipeline ([devops] Disable implicit CI triggers on xamarin-macios-pr pipeline #25211)
- [devops] Remove the branch-based trigger for pull requests. ([devops] Remove the branch-based trigger for pull requests. #25182)
The pull request #25177 ran the PR pipeline twice: * https://dev.azure.com/devdiv/DevDiv/_build/results?buildId=13868591&view=results * https://dev.azure.com/devdiv/DevDiv/_build/results?buildId=13868592&view=results when it should only have been done once. So I asked Copilot, which said: It was triggered twice because two different Azure triggers fired for the same change. - 13868591 was queued as individualCI for refs/heads/dev/rolf/nsurlsession-cleanup on commit b3223c4. - 13868592 was queued seconds later as pullRequest for refs/pull/25177/merge on the synthetic merge commit 7fccb8c. That matches the repo’s PR pipeline config in tools/devops/automation/build-pull-request.yml, which has both a branch trigger: for refs/heads/dev/* and a pr: trigger for '*'. So opening/updating PR #25177 caused one normal branch CI run and one PR-validation run. So disable the branched-based trigger.
…25211) Without an explicit trigger section, Azure DevOps defaults to enabling CI triggers on all branches. This causes duplicate builds when a branch (e.g. darc-main-*) has an open PR — one from the implicit CI trigger and one from the PR trigger. Adding 'trigger: none' ensures only PR-triggered builds run. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Treat PR merge refs as PR builds regardless of the reported build reason, and consider synthetic merge commits current when one of their parents matches the PR head. Also pass the checkout template's isPR flag correctly so the fixed commit hash is used for PR comment handling. --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Unfortunately Azure DevOps doesn't properly report GitHub checks for pipelines triggered by another pipeline, when that other pipeline was triggered from a pr trigger. So go back to triggering the API diff pipeline using a pr: trigger. This effectively reverts #21880 ("[CI] Make the API diff be triggered as soon as the config of the build is done.") References: * https://stackoverflow.com/questions/78443654/reporting-stage-statuses-to-github-for-pipeline-triggered-by-another-pipeline
Unfortunately Azure DevOps doesn't properly report GitHub checks for pipelines triggered by another pipeline, when that other pipeline was triggered from a pr trigger. So start triggering this pipeline using a pr: trigger. References: * https://stackoverflow.com/questions/78443654/reporting-stage-statuses-to-github-for-pipeline-triggered-by-another-pipeline --------- Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
Backports several Azure DevOps pipeline adjustments into release/9.0.1xx to improve GitHub PR check reporting and make PR validation behave correctly (especially around PR-triggered pipelines and latest-commit detection).
Changes:
- Switch PR-related pipelines to use explicit
pr:triggers (and disable unintended/implicit CI triggers where needed). - Add an option for the tests pipeline to build packages within the same pipeline (
buildPackages) and wire stage dependencies accordingly. - Improve PR detection / latest-commit logic in the GitHub automation PowerShell module, with accompanying test updates.
Reviewed changes
Copilot reviewed 10 out of 10 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| tools/devops/automation/templates/windows/stage.yml | Make Windows integration stage optionally depend on build_packages when not running as a post-pipeline. |
| tools/devops/automation/templates/tests-stage.yml | Introduce buildPackages parameter, optionally add a build_packages stage, and adjust downstream stage dependencies and postPipeline wiring. |
| tools/devops/automation/templates/pipelines/run-tests-pipeline.yml | Expose buildPackages pipeline parameter and pass through to the tests stage template. |
| tools/devops/automation/templates/common/configure.yml | Emit TEST_MATRIX as an output variable and compute an output SIMULATOR_TEST_MATRIX for dependent stages. |
| tools/devops/automation/templates/common/checkout.yml | Pass isPR through directly to IS_PR environment variable for checkout/merge-fix logic. |
| tools/devops/automation/scripts/GitHub.Tests.ps1 | Extend tests for synthetic-merge/latest-commit detection and PR merge-ref PR detection (but currently contains a broken call site). |
| tools/devops/automation/scripts/GitHub.psm1 | Add git helper functions and enhance IsCurrentCommitLatestInPR() to handle synthetic merge commits and cache results. |
| tools/devops/automation/run-pr-api-diff.yml | Convert API diff pipeline to a pr: trigger with path filters. |
| tools/devops/automation/run-post-pr-build-tests.yml | Convert post-build tests pipeline to a pr: trigger and configure it to build packages in-pipeline. |
| tools/devops/automation/build-pull-request.yml | Disable branch CI triggers (trigger: none) to prevent duplicate PR builds when pr: is present. |
| Write-Host "##vso[task.setvariable variable=TEST_MATRIX;isOutput=true]$testMatrix" | ||
|
|
||
| # also compute the simulator test matrix and set it as output variable so that | ||
| # dependent stages in post-build test pipelines can consume it | ||
| $simulatorTestMatrix = Get-TestConfiguration ` | ||
| -TestConfigurations "$Env:TEST_CONFIGURATIONS" ` | ||
| -SupportedPlatforms "$Env:SUPPORTED_PLATFORMS" ` | ||
| -EnabledPlatforms "$Env:CONFIGURE_PLATFORMS_DOTNET_PLATFORMS" ` | ||
| -TestsLabels "${{ parameters.testsLabels }}" ` | ||
| -StatusContext "${{ parameters.statusContext }}" ` | ||
| -StageFilter "simulator_tests" | ||
| $simulatorTestMatrix = $simulatorTestMatrix | ConvertFrom-Json | ConvertTo-Json -Compress | ||
| Write-Host "##vso[task.setvariable variable=SIMULATOR_TEST_MATRIX;isOutput=true]$simulatorTestMatrix" |
| It 'returns true when the current commit is a synthetic merge commit for the latest PR head' { | ||
| Mock Invoke-Request { | ||
| return @{ | ||
| "head" = @{ | ||
| "sha" = "abc123def456" | ||
| } | ||
| "base" = @{ | ||
| "ref" = "main" | ||
| } | ||
| } | ||
| } -ModuleName 'GitHub' | ||
| Mock Test-GitIsAncestor { | ||
| return $false | ||
| } -ModuleName 'GitHub' | ||
| Mock Get-GitCommitParents { | ||
| return @("basebranch123", "abc123def456") | ||
| } -ModuleName 'GitHub' | ||
|
|
||
| $result = Get-IsCurrentCommitLatestInPR -Org "testorg" -Repo "testrepo" -Token "test-token" -Hash "merge123456" -PrIDs @("123") | ||
| $result | Should -Be $true | ||
| } | ||
|
|
||
| It 'returns false when commit is in the base branch despite having the PR head as a parent' { | ||
| Mock Invoke-Request { | ||
| return @{ | ||
| "head" = @{ | ||
| "sha" = "prhead123" | ||
| } | ||
| "base" = @{ | ||
| "ref" = "main" | ||
| } | ||
| } | ||
| } -ModuleName 'GitHub' | ||
| Mock Test-GitIsAncestor { | ||
| param ($Commit, $Branch) | ||
| # The commit is in the base branch | ||
| return $Branch -eq "origin/main" | ||
| } -ModuleName 'GitHub' | ||
| Mock Get-GitCommitParents { | ||
| return @("prhead123", "someothercommit") | ||
| } -ModuleName 'GitHub' | ||
|
|
||
| $result = Get-IsCurrentCommitLatestInPR -Org "testorg" -Repo "testrepo" -Token "test-token" -Hash "mergecommit456" -PrIDs @("123") | ||
| $result | Should -Be $false | ||
| } | ||
|
|
||
| It 'returns false when commit is in the PR branch despite having the PR head as a parent' { | ||
| Mock Invoke-Request { | ||
| return @{ | ||
| "head" = @{ | ||
| "sha" = "prhead123" | ||
| } | ||
| "base" = @{ | ||
| "ref" = "main" | ||
| } | ||
| } | ||
| } -ModuleName 'GitHub' | ||
| Mock Test-GitIsAncestor { | ||
| param ($Commit, $Branch) | ||
| # The commit is in the PR branch (ancestor of PR head) | ||
| return $Branch -eq "prhead123" | ||
| } -ModuleName 'GitHub' | ||
| Mock Get-GitCommitParents { | ||
| return @("prhead123", "someothercommit") | ||
| } -ModuleName 'GitHub' | ||
|
|
||
| $result = Get-IsCurrentCommitLatestInPR -Org "testorg" -Repo "testrepo" -Token "test-token" -Hash "mergecommit456" -PrIDs @("123") | ||
| $result | Should -Be $false | ||
| } |
✅ [PR Build #a071674] Build passed (Detect API changes) ✅Pipeline on Agent |
This comment has been minimized.
This comment has been minimized.
✅ [CI Build #a071674] Build passed (Build packages) ✅Pipeline on Agent |
✅ [PR Build #a071674] Build passed (Build macOS tests) ✅Pipeline on Agent |
✅ API diff for current PR / commitNET (empty diffs)✅ API diff vs stableNET (empty diffs)ℹ️ Generator diffGenerator Diff: vsdrops (html) vsdrops (raw diff) gist (raw diff) - Please review changes) Pipeline on Agent |
💻 [PR Build #a071674] Tests on macOS X64 - Mac Sonoma (14) passed 💻✅ All tests on macOS X64 - Mac Sonoma (14) passed. Pipeline on Agent |
💻 [PR Build #a071674] Tests on macOS M1 - Mac Monterey (12) passed 💻✅ All tests on macOS M1 - Mac Monterey (12) passed. Pipeline on Agent |
💻 [PR Build #a071674] Tests on macOS M1 - Mac Ventura (13) passed 💻✅ All tests on macOS M1 - Mac Ventura (13) passed. Pipeline on Agent |
💻 [PR Build #a071674] Tests on macOS arm64 - Mac Sequoia (15) passed 💻✅ All tests on macOS arm64 - Mac Sequoia (15) passed. Pipeline on Agent |
💻 [PR Build #a071674] Tests on macOS arm64 - Mac Tahoe (26) passed 💻✅ All tests on macOS arm64 - Mac Tahoe (26) passed. Pipeline on Agent |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
🚀 [CI Build #a071674] Test results 🚀Test results✅ All tests passed on VSTS: test results. 🎉 All 128 tests passed 🎉 Tests counts✅ cecil: All 1 tests passed. Html Report (VSDrops) Download Pipeline on Agent |