Skip to content

Commit 2fa670d

Browse files
committed
Use Version.Details.xml as primary VMR snapshot source
Version.Details.xml's <Source Sha=...> is the authoritative record of which VMR commit a product repo branch is based on. Previously the script treated it as a fallback after commit message parsing. Now it's checked first, with commit messages as secondary confirmation. This correctly handles: - Manual backflow (darc vmr backflow pushed directly) - Normal codeflow (Maestro-managed) - Conflicted PRs (VD.xml reflects pre-codeflow state) - Forward flow PRs (skips VD.xml, uses commit messages) Tested against sdk#52727 (manual backflow) and sdk#52885 (conflicted).
1 parent a9ea742 commit 2fa670d

File tree

3 files changed

+56
-54
lines changed

3 files changed

+56
-54
lines changed

.github/skills/azdo-helix-failures/references/helix-artifacts.md

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,10 +47,6 @@ Always query the specific work item to see what's available rather than assuming
4747

4848
Artifacts may be at the root level or nested in subdirectories like `xharness-output/logs/`.
4949

50-
> **Note:** The Helix API has a known bug ([dotnet/dnceng#6072](https://github.com/dotnet/dnceng/issues/6072)) where
51-
> file URIs for subdirectory files are incorrect. The script works around this by rebuilding URIs from the `FileName`
52-
> field, but raw API responses may return broken links for files like `xharness-output/wasm-console.log`.
53-
5450
## Binlog Files
5551

5652
Binlogs are **only present for tests that invoke MSBuild** (build/publish tests, AOT compilation). Standard unit tests don't produce binlogs.

.github/skills/azdo-helix-failures/scripts/Get-HelixFailures.ps1

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1353,20 +1353,6 @@ function Get-HelixWorkItemDetails {
13531353

13541354
try {
13551355
$response = Invoke-CachedRestMethod -Uri $url -TimeoutSec $TimeoutSec -AsJson
1356-
1357-
# Workaround for https://github.com/dotnet/dnceng/issues/6072:
1358-
# Helix API returns incorrect file URIs for files in subdirectories
1359-
# (e.g., xharness-output/testResults.xml). Rebuild URI from FileName.
1360-
if ($response -and $response.Files) {
1361-
$encodedWorkItem = [uri]::EscapeDataString($WorkItemName)
1362-
foreach ($file in $response.Files) {
1363-
if ($file.FileName -and $file.FileName -match '/') {
1364-
$encodedFileName = ($file.FileName -split '/' | ForEach-Object { [uri]::EscapeDataString($_) }) -join '/'
1365-
$file.Uri = "https://helix.dot.net/api/jobs/$JobId/workitems/$encodedWorkItem/files/$encodedFileName`?api-version=2019-06-17"
1366-
}
1367-
}
1368-
}
1369-
13701356
return $response
13711357
}
13721358
catch {

.github/skills/vmr-codeflow-status/scripts/Get-CodeflowStatus.ps1

Lines changed: 56 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -402,69 +402,85 @@ $freshnessRepoLabel = if ($isForwardFlow) { $sourceRepo } else { "VMR" }
402402
# Pre-load PR commits for use in validation and later analysis
403403
$prCommits = $pr.commits
404404

405-
# --- Step 2b: Cross-reference PR body snapshot against actual branch commits ---
405+
# --- Step 2b: Determine actual VMR snapshot on the PR branch ---
406+
# Priority: 1) Version.Details.xml (ground truth), 2) commit messages, 3) PR body
406407
$branchVmrCommit = $null
408+
$commitMsgVmrCommit = $null
409+
$versionDetailsVmrCommit = $null
410+
411+
# First: check eng/Version.Details.xml on the PR branch (authoritative source)
412+
if (-not $isForwardFlow) {
413+
$vdContent = Invoke-GitHubApi "/repos/$Repository/contents/eng/Version.Details.xml?ref=$([System.Uri]::EscapeDataString($pr.headRefName))" -Raw
414+
if ($vdContent -and $vdContent -match '<Source\s+[^>]*Sha="([a-fA-F0-9]+)"') {
415+
$versionDetailsVmrCommit = $Matches[1]
416+
$branchVmrCommit = $versionDetailsVmrCommit
417+
}
418+
}
419+
420+
# Second: scan commit messages for "Backflow from" / "Forward flow from" SHAs
407421
if ($prCommits) {
408-
# Look through PR branch commits (newest first) for "Backflow from" or "Forward flow from" messages
409-
# containing the actual VMR/source SHA that was used to create the branch content
410422
$reversedCommits = @($prCommits)
411423
[Array]::Reverse($reversedCommits)
412424
foreach ($c in $reversedCommits) {
413425
$msg = $c.messageHeadline
414-
# Backflow commits: "Backflow from https://github.com/dotnet/dotnet / <sha> build <id>"
415426
if ($msg -match '(?:Backflow|Forward flow) from .+ / ([a-fA-F0-9]+)') {
416-
$branchVmrCommit = $Matches[1]
417-
# Keep scanning — we want the most recent (last in original order = first in reversed)
427+
$commitMsgVmrCommit = $Matches[1]
418428
break
419429
}
420430
}
431+
# For forward flow (no Version.Details.xml source), commit messages are primary
432+
if (-not $branchVmrCommit -and $commitMsgVmrCommit) {
433+
$branchVmrCommit = $commitMsgVmrCommit
434+
}
421435
}
422436

423437
if ($branchVmrCommit -or $vmrCommit) {
424438
Write-Section "Snapshot Validation"
425439
$usedBranchSnapshot = $false
426-
if ($branchVmrCommit -and $vmrCommit) {
427-
$bodyShort = Get-ShortSha $vmrCommit
428-
$branchShort = $branchVmrCommit # already short from commit message
429-
if ($vmrCommit.StartsWith($branchVmrCommit) -or $branchVmrCommit.StartsWith($vmrCommit)) {
430-
Write-Host " ✅ PR body snapshot ($bodyShort) matches branch commit ($branchShort)" -ForegroundColor Green
440+
441+
if ($branchVmrCommit) {
442+
# We have a branch-derived snapshot (from Version.Details.xml or commit message)
443+
$branchShort = Get-ShortSha $branchVmrCommit
444+
$sourceLabel = if ($versionDetailsVmrCommit -and $branchVmrCommit -eq $versionDetailsVmrCommit) { "Version.Details.xml" } else { "branch commit" }
445+
446+
if ($vmrCommit) {
447+
$bodyShort = Get-ShortSha $vmrCommit
448+
if ($vmrCommit.StartsWith($branchVmrCommit) -or $branchVmrCommit.StartsWith($vmrCommit)) {
449+
Write-Host "$sourceLabel ($branchShort) matches PR body ($bodyShort)" -ForegroundColor Green
450+
}
451+
else {
452+
Write-Host " ⚠️ MISMATCH: $sourceLabel has $branchShort but PR body claims $bodyShort" -ForegroundColor Red
453+
Write-Host " PR body is stale — using $sourceLabel for freshness check" -ForegroundColor Yellow
454+
}
455+
}
456+
else {
457+
Write-Host " ℹ️ PR body has no commit reference — using $sourceLabel ($branchShort)" -ForegroundColor Yellow
458+
}
459+
460+
# Resolve to full SHA for accurate comparison (skip API call if already full-length)
461+
if ($branchVmrCommit.Length -ge 40) {
462+
$vmrCommit = $branchVmrCommit
463+
$usedBranchSnapshot = $true
431464
}
432465
else {
433-
Write-Host " ⚠️ MISMATCH: PR body claims $(Get-ShortSha $vmrCommit) but branch commit references $branchVmrCommit" -ForegroundColor Red
434-
Write-Host " The PR body may be stale — using branch commit ($branchVmrCommit) for freshness check" -ForegroundColor Yellow
435-
# Resolve the short SHA from the branch commit to a full SHA for accurate comparison
436466
$resolvedCommit = Invoke-GitHubApi "/repos/$freshnessRepo/commits/$branchVmrCommit"
437467
if ($resolvedCommit) {
438468
$vmrCommit = $resolvedCommit.sha
439469
$usedBranchSnapshot = $true
440470
}
441-
else {
442-
Write-Host " ⚠️ Could not resolve branch commit SHA $branchVmrCommit — falling back to PR body" -ForegroundColor Yellow
471+
elseif (-not $vmrCommit) {
472+
Write-Host " ⚠️ Could not resolve $sourceLabel SHA $branchShort" -ForegroundColor Yellow
443473
}
444474
}
445475
}
446-
elseif ($branchVmrCommit -and -not $vmrCommit) {
447-
Write-Host " ⚠️ PR body has no commit reference, but branch commit references $branchVmrCommit" -ForegroundColor Yellow
448-
Write-Host " Using branch commit for freshness check" -ForegroundColor Yellow
449-
$resolvedCommit = Invoke-GitHubApi "/repos/$freshnessRepo/commits/$branchVmrCommit"
450-
if ($resolvedCommit) {
451-
$vmrCommit = $resolvedCommit.sha
452-
$usedBranchSnapshot = $true
453-
}
454-
}
455-
elseif ($vmrCommit -and -not $branchVmrCommit) {
476+
else {
477+
# No branch-derived snapshot — PR body only
456478
$commitCount = if ($prCommits) { $prCommits.Count } else { 0 }
457-
if ($commitCount -eq 1) {
458-
$firstMsg = $prCommits[0].messageHeadline
459-
if ($firstMsg -match "^Initial commit for subscription") {
460-
Write-Host " ℹ️ PR has only an initial subscription commit — PR body snapshot ($(Get-ShortSha $vmrCommit)) not yet verifiable from branch" -ForegroundColor DarkGray
461-
}
462-
else {
463-
Write-Host " ⚠️ No VMR SHA found in branch commit messages — trusting PR body ($(Get-ShortSha $vmrCommit))" -ForegroundColor Yellow
464-
}
479+
if ($commitCount -eq 1 -and $prCommits[0].messageHeadline -match "^Initial commit for subscription") {
480+
Write-Host " ℹ️ PR has only an initial subscription commit — PR body snapshot ($(Get-ShortSha $vmrCommit)) not yet verifiable" -ForegroundColor DarkGray
465481
}
466482
else {
467-
Write-Host " ⚠️ No VMR SHA found in $commitCount branch commit messages — trusting PR body ($(Get-ShortSha $vmrCommit))" -ForegroundColor Yellow
483+
Write-Host " ⚠️ Could not verify PR body snapshot ($(Get-ShortSha $vmrCommit)) from branch" -ForegroundColor Yellow
468484
}
469485
}
470486
}
@@ -485,7 +501,11 @@ if ($vmrCommit -and $vmrBranch) {
485501
if ($branchHead) {
486502
$sourceHeadSha = $branchHead.sha
487503
$sourceHeadDate = $branchHead.commit.committer.date
488-
$snapshotSource = if ($usedBranchSnapshot) { "from branch commit" } else { "from PR body" }
504+
$snapshotSource = if ($usedBranchSnapshot) {
505+
if ($versionDetailsVmrCommit -and $vmrCommit.StartsWith($versionDetailsVmrCommit)) { "from Version.Details.xml" }
506+
elseif ($commitMsgVmrCommit) { "from branch commit" }
507+
else { "from branch" }
508+
} else { "from PR body" }
489509
Write-Status "PR snapshot" "$(Get-ShortSha $vmrCommit) ($snapshotSource)"
490510
Write-Status "$freshnessRepoLabel HEAD" "$(Get-ShortSha $sourceHeadSha) ($sourceHeadDate)"
491511

0 commit comments

Comments
 (0)