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
5 changes: 4 additions & 1 deletion .github/scripts/BuildAndRunHostApp.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -349,7 +349,8 @@ Write-Step "Collecting test artifacts (screenshots, page source)..."
$testAssemblyDirs = @(
(Join-Path $RepoRoot "artifacts/bin/Controls.TestCases.Android.Tests/Debug/net10.0"),
(Join-Path $RepoRoot "artifacts/bin/Controls.TestCases.iOS.Tests/Debug/net10.0"),
(Join-Path $RepoRoot "artifacts/bin/Controls.TestCases.Mac.Tests/Debug/net10.0")
(Join-Path $RepoRoot "artifacts/bin/Controls.TestCases.Mac.Tests/Debug/net10.0"),
(Join-Path $RepoRoot "artifacts/bin/Controls.TestCases.WinUI.Tests/Debug/net10.0-windows10.0.19041.0")
)

$copiedCount = 0
Expand Down Expand Up @@ -441,6 +442,8 @@ if (Test-Path $deviceLogFile) {
Write-Host " iOS Simulator Logs (Last 100 lines)" -ForegroundColor Cyan
} elseif ($Platform -eq "catalyst") {
Write-Host " MacCatalyst App Logs (Last 100 lines)" -ForegroundColor Cyan
} elseif ($Platform -eq "windows") {
Write-Host " Windows App Logs (Last 100 lines)" -ForegroundColor Cyan
}
Write-Host "═══════════════════════════════════════════════════════" -ForegroundColor Cyan

Expand Down
20 changes: 16 additions & 4 deletions .github/scripts/Review-PR.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ param(
[int]$PRNumber,

[Parameter(Mandatory = $false)]
[ValidateSet('android', 'ios', 'windows', 'maccatalyst')]
[ValidateSet('android', 'ios', 'windows', 'maccatalyst', 'catalyst')]
[string]$Platform,
Comment on lines 45 to 47

[Parameter(Mandatory = $false)]
Expand Down Expand Up @@ -482,12 +482,20 @@ $summaryScriptsDir = Join-Path $RepoRoot ".github/scripts"
$dryRunFlag = if ($DryRun) { @('-DryRun') } else { @() }

# 3a: Post PR review phases (pre-flight, gate, try-fix, report)
$aiSummaryCommentId = $null
$reviewScript = Join-Path $summaryScriptsDir "post-ai-summary-comment.ps1"
if (Test-Path $reviewScript) {
try {
Write-Host " 📝 Posting PR review summary..." -ForegroundColor Cyan
& $reviewScript -PRNumber $PRNumber @dryRunFlag
Write-Host " ✅ PR review summary posted" -ForegroundColor Green
$reviewOutput = & $reviewScript -PRNumber $PRNumber @dryRunFlag
# Capture comment ID from script output (format: COMMENT_ID=<id>)
$idLine = $reviewOutput | Where-Object { $_ -match '^COMMENT_ID=' } | Select-Object -Last 1
if ($idLine -match '^COMMENT_ID=(\d+)$') {
$aiSummaryCommentId = $Matches[1]
Write-Host " ✅ PR review summary posted (comment ID: $aiSummaryCommentId)" -ForegroundColor Green
} else {
Write-Host " ✅ PR review summary posted" -ForegroundColor Green
}
} catch {
Write-Host " ⚠️ PR review summary posting failed (non-fatal): $_" -ForegroundColor Yellow
}
Expand All @@ -500,7 +508,11 @@ $finalizeScript = Join-Path $summaryScriptsDir "post-pr-finalize-comment.ps1"
if (Test-Path $finalizeScript) {
try {
Write-Host " 📝 Posting PR finalize summary..." -ForegroundColor Cyan
& $finalizeScript -PRNumber $PRNumber @dryRunFlag
$finalizeArgs = @('-PRNumber', $PRNumber) + $dryRunFlag
if ($aiSummaryCommentId) {
$finalizeArgs += @('-ExistingCommentId', $aiSummaryCommentId)
}
& $finalizeScript @finalizeArgs
Write-Host " ✅ PR finalize summary posted" -ForegroundColor Green
} catch {
Write-Host " ⚠️ PR finalize summary posting failed (non-fatal): $_" -ForegroundColor Yellow
Expand Down
34 changes: 29 additions & 5 deletions .github/scripts/post-ai-summary-comment.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -831,19 +831,43 @@ if ($existingComment) {
$tempFile = [System.IO.Path]::GetTempFileName()
@{ body = $commentBody } | ConvertTo-Json -Depth 10 | Set-Content -Path $tempFile -Encoding UTF8

gh api --method PATCH "repos/dotnet/maui/issues/comments/$($existingComment.id)" --input $tempFile | Out-Null
Remove-Item $tempFile
$patchResult = $null
$commentId = $existingComment.id
try {
$patchResult = gh api --method PATCH "repos/dotnet/maui/issues/comments/$($existingComment.id)" --input $tempFile 2>&1
if ($LASTEXITCODE -ne 0) { throw "PATCH failed (exit code $LASTEXITCODE): $patchResult" }
Write-Host "✅ Review comment updated successfully" -ForegroundColor Green
} catch {
Write-Host "⚠️ Could not update comment (no edit permission?) — creating new comment instead: $_" -ForegroundColor Yellow

$newTempFile = [System.IO.Path]::GetTempFileName()
try {
@{ body = $commentBody } | ConvertTo-Json -Depth 10 | Set-Content -Path $newTempFile -Encoding UTF8
$newCommentJson = gh api --method POST "repos/dotnet/maui/issues/$PRNumber/comments" --input $newTempFile
$commentId = ($newCommentJson | ConvertFrom-Json).id
Write-Host "✅ Review comment posted as new (ID: $commentId)" -ForegroundColor Green
} finally {
Remove-Item $newTempFile -ErrorAction SilentlyContinue
}
} finally {
Remove-Item $tempFile -ErrorAction SilentlyContinue
}

Write-Host "✅ Review comment updated successfully" -ForegroundColor Green
# Output the comment ID so callers can pass it to subsequent scripts
Write-Output "COMMENT_ID=$commentId"
} else {
Write-Host "Creating new review comment..." -ForegroundColor Yellow

# Create temp file for new comment
$tempFile = [System.IO.Path]::GetTempFileName()
@{ body = $commentBody } | ConvertTo-Json -Depth 10 | Set-Content -Path $tempFile -Encoding UTF8

gh api --method POST "repos/dotnet/maui/issues/$PRNumber/comments" --input $tempFile | Out-Null
$newCommentJson = gh api --method POST "repos/dotnet/maui/issues/$PRNumber/comments" --input $tempFile
Remove-Item $tempFile

Write-Host "✅ Review comment posted successfully" -ForegroundColor Green
# Extract and output the new comment ID so callers can pass it to subsequent scripts
$newCommentId = ($newCommentJson | ConvertFrom-Json).id
Write-Host "✅ Review comment posted successfully (ID: $newCommentId)" -ForegroundColor Green

Write-Output "COMMENT_ID=$newCommentId"
}
91 changes: 69 additions & 22 deletions .github/scripts/post-pr-finalize-comment.ps1
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ param(
[Parameter(Mandatory=$false)]
[string]$SummaryFile,

[Parameter(Mandatory=$false)]
[string]$ExistingCommentId,

[Parameter(Mandatory=$false)]
[switch]$DryRun,

Expand Down Expand Up @@ -128,21 +131,41 @@ Write-Host "`nInjecting into AI Summary comment on #$PRNumber..." -ForegroundCol

# Find existing unified comment
$existingUnifiedComment = $null
try {
$commentsJson = gh api "repos/dotnet/maui/issues/$PRNumber/comments?per_page=100" 2>$null
$comments = $commentsJson | ConvertFrom-Json
foreach ($comment in $comments) {
if ($comment.body -match [regex]::Escape($MAIN_MARKER)) {
$existingUnifiedComment = $comment
Write-Host "✓ Found unified AI Summary comment (ID: $($comment.id))" -ForegroundColor Green
break

# If caller passed the comment ID (avoids GitHub API eventual-consistency race), fetch it directly
if (-not [string]::IsNullOrWhiteSpace($ExistingCommentId)) {
try {
$commentJson = gh api "repos/dotnet/maui/issues/comments/$ExistingCommentId" 2>$null
$directComment = $commentJson | ConvertFrom-Json
if ($directComment.body -match [regex]::Escape($MAIN_MARKER)) {
$existingUnifiedComment = $directComment
Write-Host "✓ Found unified AI Summary comment via passed ID (ID: $($directComment.id))" -ForegroundColor Green
} else {
Write-Host "⚠️ Passed comment ID $ExistingCommentId does not contain AI Summary marker — falling back to search" -ForegroundColor Yellow
}
} catch {
Write-Host "⚠️ Could not fetch comment by ID $ExistingCommentId — falling back to search" -ForegroundColor Yellow
}
if (-not $existingUnifiedComment) {
Write-Host "✓ No existing AI Summary comment found — will create new" -ForegroundColor Yellow
}

# Fallback: search through all PR comments
if (-not $existingUnifiedComment) {
try {
$commentsJson = gh api "repos/dotnet/maui/issues/$PRNumber/comments?per_page=100" 2>$null
$comments = $commentsJson | ConvertFrom-Json
foreach ($comment in $comments) {
if ($comment.body -match [regex]::Escape($MAIN_MARKER)) {
$existingUnifiedComment = $comment
Write-Host "✓ Found unified AI Summary comment (ID: $($comment.id))" -ForegroundColor Green
break
}
}
if (-not $existingUnifiedComment) {
Write-Host "✓ No existing AI Summary comment found — will create new" -ForegroundColor Yellow
}
} catch {
Write-Host "⚠️ Could not fetch comments: $_" -ForegroundColor Yellow
}
} catch {
Write-Host "⚠️ Could not fetch comments: $_" -ForegroundColor Yellow
}

# Build the final comment body
Expand Down Expand Up @@ -186,14 +209,38 @@ if ($DryRun) {
$tempFile = [System.IO.Path]::GetTempFileName()
@{ body = $finalComment } | ConvertTo-Json -Depth 10 | Set-Content -Path $tempFile -Encoding UTF8

if ($existingUnifiedComment) {
Write-Host "Updating unified comment ID $($existingUnifiedComment.id)..." -ForegroundColor Yellow
$result = gh api --method PATCH "repos/dotnet/maui/issues/comments/$($existingUnifiedComment.id)" --input $tempFile --jq '.html_url'
Write-Host "✅ PR finalize section updated: $result" -ForegroundColor Green
} else {
Write-Host "Creating new unified comment on PR #$PRNumber..." -ForegroundColor Yellow
$result = gh api --method POST "repos/dotnet/maui/issues/$PRNumber/comments" --input $tempFile --jq '.html_url'
Write-Host "✅ Unified comment posted: $result" -ForegroundColor Green
}
try {
if ($existingUnifiedComment) {
Write-Host "Updating unified comment ID $($existingUnifiedComment.id)..." -ForegroundColor Yellow
$patchResult = $null
try {
$patchResult = gh api --method PATCH "repos/dotnet/maui/issues/comments/$($existingUnifiedComment.id)" --input $tempFile --jq '.html_url' 2>&1
if ($LASTEXITCODE -ne 0) { throw "PATCH failed (exit code $LASTEXITCODE): $patchResult" }
Write-Host "✅ PR finalize section updated: $patchResult" -ForegroundColor Green
} catch {
Write-Host "⚠️ Could not update comment (no edit permission?) — creating new comment instead: $_" -ForegroundColor Yellow
# Rebuild the comment body as a standalone new comment (not an injection into existing)
$standaloneBody = @"
$MAIN_MARKER

Remove-Item $tempFile
## 🤖 AI Summary

$finalizeSection
"@
$standaloneTempFile = [System.IO.Path]::GetTempFileName()
try {
@{ body = $standaloneBody } | ConvertTo-Json -Depth 10 | Set-Content -Path $standaloneTempFile -Encoding UTF8
$result = gh api --method POST "repos/dotnet/maui/issues/$PRNumber/comments" --input $standaloneTempFile --jq '.html_url'
Write-Host "✅ Unified comment posted (new): $result" -ForegroundColor Green
} finally {
Remove-Item $standaloneTempFile -ErrorAction SilentlyContinue
}
}
} else {
Write-Host "Creating new unified comment on PR #$PRNumber..." -ForegroundColor Yellow
$result = gh api --method POST "repos/dotnet/maui/issues/$PRNumber/comments" --input $tempFile --jq '.html_url'
Write-Host "✅ Unified comment posted: $result" -ForegroundColor Green
}
} finally {
Remove-Item $tempFile -ErrorAction SilentlyContinue
}
Loading
Loading