Skip to content

[CI] Fix PR detection in api-diff configure#24626

Merged
dalexsoto merged 1 commit intomainfrom
release-test/fix-apidiffci
Feb 5, 2026
Merged

[CI] Fix PR detection in api-diff configure#24626
dalexsoto merged 1 commit intomainfrom
release-test/fix-apidiffci

Conversation

@dalexsoto
Copy link
Copy Markdown
Member

The api-diff pipeline is triggered via ResourceTrigger, so BUILD_REASON is not PullRequest and PR metadata may be absent. The configure step in VSTS.psm1 treated some runs as PR builds using BuildReason and a branch check, then unconditionally called GitHub PR APIs, which failed when no PR id was resolved.

Align PR detection with parse_pr_labels.ps1: use the parent build reason (fallback to current BUILD_REASON) and only treat Manual/IndividualCI builds as PRs when the parent branch name is 'merge'. This avoids misclassifying pipeline-triggered CI runs, prevents empty ChangeId lookups, and keeps CI behavior (tags/labels) consistent with the intended non‑PR path.

The api-diff pipeline is triggered via ResourceTrigger, so BUILD_REASON is not PullRequest and PR metadata may be absent. The configure step in VSTS.psm1 treated some runs as PR builds using BuildReason and a branch check, then unconditionally called GitHub PR APIs, which failed when no PR id was resolved.

Align PR detection with parse_pr_labels.ps1: use the parent build reason (fallback to current BUILD_REASON) and only treat Manual/IndividualCI builds as PRs when the parent branch name is 'merge'. This avoids misclassifying pipeline-triggered CI runs, prevents empty ChangeId lookups, and keeps CI behavior (tags/labels) consistent with the intended non‑PR path.
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Fixes PR-build detection in the api-diff configure step so resource-triggered runs aren’t misclassified as PR builds, and prevents GitHub PR API calls when no PR id is available.

Changes:

  • Derive an effective $buildReason (preferring the parent build reason, falling back to BUILD_REASON) for tagging/PR detection.
  • Refine PR detection rules (Manual/IndividualCI only treated as PR when parent branch name is merge).
  • Guard GitHub PR info retrieval so it only runs when a non-empty PR id was resolved; otherwise fall back to CI labeling/tagging.

Comment on lines 531 to +537
Write-Host "Configuring build from PR."

# retrieve the PR data to be able to fwd the labels from github
$prId = $this.ExportPRId($configuration)
}

if ($prId) {
Copy link

Copilot AI Feb 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The log line "Configuring build from PR." can be misleading now that PR metadata fetch is gated on successfully resolving a PR id. If ExportPRId returns null, the build is treated as CI, but the logs still claim it was configured from a PR. Consider moving/adjusting this message so it only prints after a non-empty PR id is found (or log that PR detection was attempted).

Suggested change
Write-Host "Configuring build from PR."
# retrieve the PR data to be able to fwd the labels from github
$prId = $this.ExportPRId($configuration)
}
if ($prId) {
# retrieve the PR data to be able to fwd the labels from github
$prId = $this.ExportPRId($configuration)
}
if ($prId) {
Write-Host "Configuring build from PR."

Copilot uses AI. Check for mistakes.
Comment on lines +520 to 538
$buildReason = $configuration.PARENT_BUILD_BUILD_REASON
if (-not $buildReason) {
$buildReason = $Env:BUILD_REASON
}

if ($buildReason -eq "Schedule") {
$tags.Add("cronjob")
}

if ($Env:IS_PR -eq "true" -or $configuration.BuildReason -eq "PullRequest" -or (($configuration.BuildReason -eq "Manual") -and ($configuration.PARENT_BUILD_BUILD_SOURCEBRANCH -eq "merge")) ) {
$prId = $null
if ($Env:IS_PR -eq "true" -or $buildReason -eq "PullRequest" -or (($buildReason -eq "Manual" -or $buildReason -eq "IndividualCI") -and ($configuration.PARENT_BUILD_BUILD_SOURCEBRANCHNAME -eq "merge")) ) {
Write-Host "Configuring build from PR."

# retrieve the PR data to be able to fwd the labels from github
$prId = $this.ExportPRId($configuration)
}

if ($prId) {
$prInfo = Get-GitHubPRInfo -ChangeId $prId
Copy link

Copilot AI Feb 4, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR detection/tagging behavior was changed (build reason selection, Manual/IndividualCI handling, and skipping GitHub PR API calls when no PR id is resolved), but there are no Pester tests covering these PR/non-PR branches. Add unit tests for New-BuildConfiguration covering at least: (1) IS_PR/buildReason indicates PR but ExportPRId returns null => no Get-GitHubPRInfo call and ciBuild tagging, and (2) Manual/IndividualCI + SourceBranchName=merge => PR path.

Copilot uses AI. Check for mistakes.
@vs-mobiletools-engineering-service2
Copy link
Copy Markdown
Collaborator

✅ [CI Build #df0d7d9] Build passed (Build packages) ✅

Pipeline on Agent
Hash: df0d7d99feacde53013b8389496356f30d5e3545 [PR build]

@vs-mobiletools-engineering-service2
Copy link
Copy Markdown
Collaborator

✅ [CI Build #df0d7d9] Build passed (Detect API changes) ✅

Pipeline on Agent
Hash: df0d7d99feacde53013b8389496356f30d5e3545 [PR build]

@vs-mobiletools-engineering-service2
Copy link
Copy Markdown
Collaborator

✅ API diff for current PR / commit

NET (empty diffs)

✅ API diff vs stable

NET (empty diffs)

ℹ️ Generator diff

Generator Diff: vsdrops (html) vsdrops (raw diff) gist (raw diff) - Please review changes)

Pipeline on Agent
Hash: df0d7d99feacde53013b8389496356f30d5e3545 [PR build]

@vs-mobiletools-engineering-service2
Copy link
Copy Markdown
Collaborator

✅ [CI Build #df0d7d9] Build passed (Build macOS tests) ✅

Pipeline on Agent
Hash: df0d7d99feacde53013b8389496356f30d5e3545 [PR build]

@vs-mobiletools-engineering-service2
Copy link
Copy Markdown
Collaborator

💻 [CI Build #df0d7d9] Tests on macOS M1 - Mac Monterey (12) passed 💻

All tests on macOS M1 - Mac Monterey (12) passed.

Pipeline on Agent
Hash: df0d7d99feacde53013b8389496356f30d5e3545 [PR build]

@vs-mobiletools-engineering-service2
Copy link
Copy Markdown
Collaborator

💻 [CI Build #df0d7d9] Tests on macOS arm64 - Mac Sequoia (15) passed 💻

All tests on macOS arm64 - Mac Sequoia (15) passed.

Pipeline on Agent
Hash: df0d7d99feacde53013b8389496356f30d5e3545 [PR build]

@vs-mobiletools-engineering-service2
Copy link
Copy Markdown
Collaborator

💻 [CI Build #df0d7d9] Tests on macOS M1 - Mac Ventura (13) passed 💻

All tests on macOS M1 - Mac Ventura (13) passed.

Pipeline on Agent
Hash: df0d7d99feacde53013b8389496356f30d5e3545 [PR build]

@vs-mobiletools-engineering-service2
Copy link
Copy Markdown
Collaborator

💻 [CI Build #df0d7d9] Tests on macOS arm64 - Mac Tahoe (26) passed 💻

All tests on macOS arm64 - Mac Tahoe (26) passed.

Pipeline on Agent
Hash: df0d7d99feacde53013b8389496356f30d5e3545 [PR build]

@vs-mobiletools-engineering-service2
Copy link
Copy Markdown
Collaborator

💻 [CI Build #df0d7d9] Tests on macOS X64 - Mac Sonoma (14) passed 💻

All tests on macOS X64 - Mac Sonoma (14) passed.

Pipeline on Agent
Hash: df0d7d99feacde53013b8389496356f30d5e3545 [PR build]

@vs-mobiletools-engineering-service2
Copy link
Copy Markdown
Collaborator

✅ [CI Build #df0d7d9] Build passed (Build packages) ✅

Pipeline on Agent
Hash: df0d7d99feacde53013b8389496356f30d5e3545 [PR build]

@vs-mobiletools-engineering-service2
Copy link
Copy Markdown
Collaborator

✅ [PR Build #df0d7d9] Build passed (Detect API changes) ✅

Pipeline on Agent
Hash: df0d7d99feacde53013b8389496356f30d5e3545 [PR build]

@vs-mobiletools-engineering-service2
Copy link
Copy Markdown
Collaborator

✅ API diff for current PR / commit

NET (empty diffs)

✅ API diff vs stable

NET (empty diffs)

ℹ️ Generator diff

Generator Diff: vsdrops (html) vsdrops (raw diff) gist (raw diff) - Please review changes)

Pipeline on Agent
Hash: df0d7d99feacde53013b8389496356f30d5e3545 [PR build]

@vs-mobiletools-engineering-service2
Copy link
Copy Markdown
Collaborator

✅ [CI Build #df0d7d9] Build passed (Build macOS tests) ✅

Pipeline on Agent
Hash: df0d7d99feacde53013b8389496356f30d5e3545 [PR build]

@vs-mobiletools-engineering-service2
Copy link
Copy Markdown
Collaborator

💻 [CI Build #df0d7d9] Tests on macOS M1 - Mac Monterey (12) passed 💻

All tests on macOS M1 - Mac Monterey (12) passed.

Pipeline on Agent
Hash: df0d7d99feacde53013b8389496356f30d5e3545 [PR build]

@vs-mobiletools-engineering-service2
Copy link
Copy Markdown
Collaborator

💻 [CI Build #df0d7d9] Tests on macOS arm64 - Mac Sequoia (15) passed 💻

All tests on macOS arm64 - Mac Sequoia (15) passed.

Pipeline on Agent
Hash: df0d7d99feacde53013b8389496356f30d5e3545 [PR build]

@vs-mobiletools-engineering-service2
Copy link
Copy Markdown
Collaborator

💻 [CI Build #df0d7d9] Tests on macOS M1 - Mac Ventura (13) passed 💻

All tests on macOS M1 - Mac Ventura (13) passed.

Pipeline on Agent
Hash: df0d7d99feacde53013b8389496356f30d5e3545 [PR build]

@vs-mobiletools-engineering-service2
Copy link
Copy Markdown
Collaborator

💻 [CI Build #df0d7d9] Tests on macOS arm64 - Mac Tahoe (26) passed 💻

All tests on macOS arm64 - Mac Tahoe (26) passed.

Pipeline on Agent
Hash: df0d7d99feacde53013b8389496356f30d5e3545 [PR build]

@vs-mobiletools-engineering-service2
Copy link
Copy Markdown
Collaborator

💻 [CI Build #df0d7d9] Tests on macOS X64 - Mac Sonoma (14) passed 💻

All tests on macOS X64 - Mac Sonoma (14) passed.

Pipeline on Agent
Hash: df0d7d99feacde53013b8389496356f30d5e3545 [PR build]

@vs-mobiletools-engineering-service2

This comment has been minimized.

@vs-mobiletools-engineering-service2
Copy link
Copy Markdown
Collaborator

🚀 [CI Build #df0d7d9] Test results 🚀

Test results

✅ All tests passed on VSTS: test results.

🎉 All 117 tests passed 🎉

Tests counts

✅ cecil: All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (iOS): All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (MacCatalyst): All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (macOS): All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (Multiple platforms): All 1 tests passed. Html Report (VSDrops) Download
✅ dotnettests (tvOS): All 1 tests passed. Html Report (VSDrops) Download
✅ framework: All 2 tests passed. Html Report (VSDrops) Download
✅ fsharp: All 4 tests passed. Html Report (VSDrops) Download
✅ generator: All 5 tests passed. Html Report (VSDrops) Download
✅ interdependent-binding-projects: All 4 tests passed. Html Report (VSDrops) Download
✅ introspection: All 4 tests passed. [attempt 2] Html Report (VSDrops) Download
✅ linker: All 44 tests passed. Html Report (VSDrops) Download
✅ monotouch (iOS): All 9 tests passed. Html Report (VSDrops) Download
✅ monotouch (MacCatalyst): All 11 tests passed. Html Report (VSDrops) Download
✅ monotouch (macOS): All 9 tests passed. Html Report (VSDrops) Download
✅ monotouch (tvOS): All 9 tests passed. Html Report (VSDrops) Download
✅ msbuild: All 2 tests passed. Html Report (VSDrops) Download
✅ windows: All 3 tests passed. Html Report (VSDrops) Download
✅ xcframework: All 4 tests passed. Html Report (VSDrops) Download
✅ xtro: All 1 tests passed. Html Report (VSDrops) Download

Pipeline on Agent
Hash: df0d7d99feacde53013b8389496356f30d5e3545 [PR build]

@dalexsoto dalexsoto enabled auto-merge (squash) February 5, 2026 04:35
@dalexsoto dalexsoto merged commit 79818da into main Feb 5, 2026
62 checks passed
@dalexsoto dalexsoto deleted the release-test/fix-apidiffci branch February 5, 2026 07:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants