From f9fbcd321a5f117df268e4d2700e630946b5a68e Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 1 Feb 2026 01:46:46 +0000 Subject: [PATCH 1/8] Initial plan From 1917a02d4d87d89adf0afb54d1dd8f69c293d934 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 1 Feb 2026 01:48:51 +0000 Subject: [PATCH 2/8] feat: upgrade CI workflows with matrix builds and PR test comments Co-authored-by: supervoidcoder <88671013+supervoidcoder@users.noreply.github.com> --- .github/workflows/build.yml | 203 +++++++++++++++++++++++++++++++--- .github/workflows/release.yml | 18 ++- 2 files changed, 201 insertions(+), 20 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index d0564a0..28d2c75 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -2,35 +2,202 @@ name: Build Check on: [pull_request, push] permissions: contents: read + pull-requests: write # Required to post comments on PRs jobs: - build-windows: - runs-on: windows-latest + # Matrix job that compiles and tests all architectures + build-and-test: + strategy: + fail-fast: false # Continue testing other architectures even if one fails + matrix: + include: + # x64 architecture - native runner + - arch: x64 + runner: windows-latest + vcvars_arch: x64 + # x86 architecture - runs on x64 via WoW64 + - arch: x86 + runner: windows-latest + vcvars_arch: x64_x86 + # ARM64 architecture - native ARM runner for testing + - arch: arm64 + runner: windows-11-arm + vcvars_arch: x64_arm64 + + runs-on: ${{ matrix.runner }} + steps: - uses: actions/checkout@v4 - - name: Setup MSVC + - name: Setup MSVC for ${{ matrix.arch }} uses: ilammy/msvc-dev-cmd@v1 + with: + arch: ${{ matrix.vcvars_arch }} - - name: Compile + - name: Compile for ${{ matrix.arch }} shell: pwsh run: | - cl /O2 /std:c++20 /EHsc main.cpp /DUNICODE /D_UNICODE /Fe:win-witr.exe - # Add the current directory (where win-witr.exe was compiled) to PATH - $env:PATH = "$PWD;$env:PATH" - - # Verify the exe is accessible - Write-Host "Checking win-witr.exe availability..." - win-witr --version - - name: Run Tests + # Compile the executable + cl /O2 /std:c++20 /EHsc main.cpp /DUNICODE /D_UNICODE /Fe:win-witr-${{ matrix.arch }}.exe + + # Add the current directory to PATH + $env:PATH = "$PWD;$env:PATH" + + # Verify the exe is accessible + Write-Host "Checking win-witr-${{ matrix.arch }}.exe availability..." + .\win-witr-${{ matrix.arch }}.exe --version + + - name: Run Tests for ${{ matrix.arch }} + id: run_tests shell: pwsh run: | + # Initialize test counters + $totalTests = 0 + $passedTests = 0 + $failedTests = 0 + $testResults = @() + + # Add the current directory to PATH + $env:PATH = "$PWD;$env:PATH" + # Run all test .bat files Get-ChildItem -Path tests -Recurse -Filter *.bat | ForEach-Object { - Write-Host "Running test: $($_.FullName)" - & $_.FullName - if ($LASTEXITCODE -ne 0) { - Write-Error "Test failed: $($_.Name)" - exit 1 + $totalTests++ + $testName = $_.Name + Write-Host "Running test: $testName" + + try { + & $_.FullName 2>&1 | Out-Null + if ($LASTEXITCODE -eq 0) { + $passedTests++ + $testResults += "✅ $testName - PASSED" + Write-Host "✅ Test passed: $testName" + } else { + $failedTests++ + $testResults += "❌ $testName - FAILED (Exit code: $LASTEXITCODE)" + Write-Host "❌ Test failed: $testName" + } + } catch { + $failedTests++ + $testResults += "❌ $testName - FAILED (Exception: $_)" + Write-Host "❌ Test failed with exception: $testName" } } - + + # Output test summary + Write-Host "`n=== Test Summary for ${{ matrix.arch }} ===" + Write-Host "Total: $totalTests" + Write-Host "Passed: $passedTests" + Write-Host "Failed: $failedTests" + + # Store results for PR comment + $results = @{ + total = $totalTests + passed = $passedTests + failed = $failedTests + details = $testResults -join "`n" + } + + # Export results to GitHub output using multiline format + "total=$totalTests" >> $env:GITHUB_OUTPUT + "passed=$passedTests" >> $env:GITHUB_OUTPUT + "failed=$failedTests" >> $env:GITHUB_OUTPUT + $delimiter = "EOF_$([guid]::NewGuid())" + "details<<$delimiter" >> $env:GITHUB_OUTPUT + $testResults -join "`n" >> $env:GITHUB_OUTPUT + "$delimiter" >> $env:GITHUB_OUTPUT + + # Exit with error if any tests failed + if ($failedTests -gt 0) { + Write-Error "Some tests failed for ${{ matrix.arch }}" + exit 1 + } + + # Upload test results as artifacts for the comment job + - name: Save test results + if: always() + shell: pwsh + run: | + $results = @{ + arch = "${{ matrix.arch }}" + total = "${{ steps.run_tests.outputs.total }}" + passed = "${{ steps.run_tests.outputs.passed }}" + failed = "${{ steps.run_tests.outputs.failed }}" + details = "${{ steps.run_tests.outputs.details }}" + } + + $results | ConvertTo-Json | Out-File -FilePath "test-results-${{ matrix.arch }}.json" + + - name: Upload test results artifact + if: always() + uses: actions/upload-artifact@v4 + with: + name: test-results-${{ matrix.arch }} + path: test-results-${{ matrix.arch }}.json + + # Job to post test results as a PR comment + post-test-results: + needs: build-and-test + if: always() && github.event_name == 'pull_request' + runs-on: ubuntu-latest + permissions: + pull-requests: write + + steps: + - name: Download all test results + uses: actions/download-artifact@v4 + with: + pattern: test-results-* + merge-multiple: true + + - name: Generate and post comment + uses: actions/github-script@v7 + with: + script: | + const fs = require('fs'); + + // Read all test result files + const files = fs.readdirSync('.').filter(f => f.startsWith('test-results-') && f.endsWith('.json')); + + let commentBody = '## 🧪 Test Results\n\n'; + let allPassed = true; + + // Process each architecture + for (const file of files) { + const data = JSON.parse(fs.readFileSync(file, 'utf8')); + const arch = data.arch; + const total = data.total || 0; + const passed = data.passed || 0; + const failed = data.failed || 0; + + if (failed > 0) { + allPassed = false; + } + + const status = failed === 0 ? '✅' : '❌'; + commentBody += `### ${status} ${arch.toUpperCase()}\n`; + commentBody += `**${passed}/${total} tests passed**\n\n`; + + if (data.details && data.details.trim()) { + commentBody += '
\n'; + commentBody += 'Test Details\n\n'; + commentBody += '```\n'; + commentBody += data.details; + commentBody += '\n```\n'; + commentBody += '
\n\n'; + } + } + + if (allPassed) { + commentBody += '\n✨ All tests passed across all architectures!\n'; + } else { + commentBody += '\n⚠️ Some tests failed. Please review the details above.\n'; + } + + // Post comment to PR + await github.rest.issues.createComment({ + owner: context.repo.owner, + repo: context.repo.repo, + issue_number: context.issue.number, + body: commentBody + }); + diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 7958ac8..7518d21 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -155,6 +155,11 @@ jobs: Write-Output "DEBUG: Base SHA: $baseSha" Write-Output "DEBUG: Head SHA: $headSha" + # Get the merge commit message (when PR is merged, this will be the merge commit) + # The merge commit is the commit that gets created when the PR is merged to main + $mergeCommitBody = git log -1 --pretty=format:"%b" HEAD + Write-Output "DEBUG: Merge commit body: $mergeCommitBody" + # Get all commit messages in the PR $commits = @(git log --pretty=format:"%h|%s|%b" "$baseSha..$headSha") Write-Output "DEBUG: Found $($commits.Count) commits in PR" @@ -214,8 +219,17 @@ jobs: } } - # Build release notes - $releaseNotes = "## Changes`n`n" + # Build release notes with merge commit extended description at the top + $releaseNotes = "" + + # Add merge commit extended description if it exists + if (-not [string]::IsNullOrWhiteSpace($mergeCommitBody)) { + $releaseNotes += "## Release Notes`n`n" + $releaseNotes += "$mergeCommitBody`n`n" + $releaseNotes += "---`n`n" + } + + $releaseNotes += "## Changes`n`n" if ($features.Count -gt 0) { $releaseNotes += "### ✨ Features`n" From fe5b221953b271abb5b88bbaf149b10208d38c43 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 1 Feb 2026 01:49:12 +0000 Subject: [PATCH 3/8] fix: use native ARM64 compilation on windows-11-arm runner Co-authored-by: supervoidcoder <88671013+supervoidcoder@users.noreply.github.com> --- .github/workflows/build.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 28d2c75..cec38f5 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -21,7 +21,7 @@ jobs: # ARM64 architecture - native ARM runner for testing - arch: arm64 runner: windows-11-arm - vcvars_arch: x64_arm64 + vcvars_arch: arm64 runs-on: ${{ matrix.runner }} From 52b6d98bc5cd10f1aa7b4f006561d74422971f5a Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 1 Feb 2026 01:49:58 +0000 Subject: [PATCH 4/8] fix: properly capture test exit codes in build workflow Co-authored-by: supervoidcoder <88671013+supervoidcoder@users.noreply.github.com> --- .github/workflows/build.yml | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index cec38f5..f16a149 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -66,15 +66,18 @@ jobs: Write-Host "Running test: $testName" try { - & $_.FullName 2>&1 | Out-Null - if ($LASTEXITCODE -eq 0) { + # Run the test and capture output and exit code + $output = & $_.FullName 2>&1 + $exitCode = $LASTEXITCODE + + if ($exitCode -eq 0) { $passedTests++ $testResults += "✅ $testName - PASSED" Write-Host "✅ Test passed: $testName" } else { $failedTests++ - $testResults += "❌ $testName - FAILED (Exit code: $LASTEXITCODE)" - Write-Host "❌ Test failed: $testName" + $testResults += "❌ $testName - FAILED (Exit code: $exitCode)" + Write-Host "❌ Test failed: $testName (Exit code: $exitCode)" } } catch { $failedTests++ From 936030860e04efbc958bf1fc51a554282f3b9f45 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 1 Feb 2026 01:51:01 +0000 Subject: [PATCH 5/8] refactor: simplify test output handling and multiline delimiter Co-authored-by: supervoidcoder <88671013+supervoidcoder@users.noreply.github.com> --- .github/workflows/build.yml | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index f16a149..76e9f29 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -66,8 +66,8 @@ jobs: Write-Host "Running test: $testName" try { - # Run the test and capture output and exit code - $output = & $_.FullName 2>&1 + # Run the test and capture exit code + & $_.FullName 2>&1 | Out-Null $exitCode = $LASTEXITCODE if ($exitCode -eq 0) { @@ -104,10 +104,9 @@ jobs: "total=$totalTests" >> $env:GITHUB_OUTPUT "passed=$passedTests" >> $env:GITHUB_OUTPUT "failed=$failedTests" >> $env:GITHUB_OUTPUT - $delimiter = "EOF_$([guid]::NewGuid())" - "details<<$delimiter" >> $env:GITHUB_OUTPUT + "details<> $env:GITHUB_OUTPUT $testResults -join "`n" >> $env:GITHUB_OUTPUT - "$delimiter" >> $env:GITHUB_OUTPUT + "EOF_DETAILS" >> $env:GITHUB_OUTPUT # Exit with error if any tests failed if ($failedTests -gt 0) { From d16d7f4c8e06d876d978394e4e4ca7d472cf8a89 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 1 Feb 2026 01:51:47 +0000 Subject: [PATCH 6/8] fix: create standard executable name for tests and use unique delimiter Co-authored-by: supervoidcoder <88671013+supervoidcoder@users.noreply.github.com> --- .github/workflows/build.yml | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 76e9f29..db8c79d 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -36,9 +36,12 @@ jobs: - name: Compile for ${{ matrix.arch }} shell: pwsh run: | - # Compile the executable + # Compile the executable with architecture-specific name cl /O2 /std:c++20 /EHsc main.cpp /DUNICODE /D_UNICODE /Fe:win-witr-${{ matrix.arch }}.exe + # Create a copy with the standard name for tests + Copy-Item -Path "win-witr-${{ matrix.arch }}.exe" -Destination "win-witr.exe" + # Add the current directory to PATH $env:PATH = "$PWD;$env:PATH" @@ -104,9 +107,10 @@ jobs: "total=$totalTests" >> $env:GITHUB_OUTPUT "passed=$passedTests" >> $env:GITHUB_OUTPUT "failed=$failedTests" >> $env:GITHUB_OUTPUT - "details<> $env:GITHUB_OUTPUT + $delimiter = "EOF_DETAILS_$(Get-Date -Format 'yyyyMMddHHmmss')" + "details<<$delimiter" >> $env:GITHUB_OUTPUT $testResults -join "`n" >> $env:GITHUB_OUTPUT - "EOF_DETAILS" >> $env:GITHUB_OUTPUT + "$delimiter" >> $env:GITHUB_OUTPUT # Exit with error if any tests failed if ($failedTests -gt 0) { From 8906b05db6c7952c3b8b56c4ef8fbf8b82d1fd10 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 1 Feb 2026 02:18:42 +0000 Subject: [PATCH 7/8] fix: capture test output, add job status, and fix merge commit SHA Co-authored-by: supervoidcoder <88671013+supervoidcoder@users.noreply.github.com> --- .github/workflows/build.yml | 37 ++++++++++++++++++++++++++--------- .github/workflows/release.yml | 11 ++++++++--- 2 files changed, 36 insertions(+), 12 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index db8c79d..939c6bf 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -69,22 +69,28 @@ jobs: Write-Host "Running test: $testName" try { - # Run the test and capture exit code - & $_.FullName 2>&1 | Out-Null + # Run the test and capture output and exit code + $output = & $_.FullName 2>&1 $exitCode = $LASTEXITCODE if ($exitCode -eq 0) { $passedTests++ - $testResults += "✅ $testName - PASSED" + # Include output in the result + $outputText = if ($output) { "`n Output: $($output -join "`n ")" } else { "" } + $testResults += "✅ $testName - PASSED$outputText" Write-Host "✅ Test passed: $testName" } else { $failedTests++ - $testResults += "❌ $testName - FAILED (Exit code: $exitCode)" + # Include output and exit code in the result + $outputText = if ($output) { "`n Output: $($output -join "`n ")" } else { "" } + $testResults += "❌ $testName - FAILED (Exit code: $exitCode)$outputText" Write-Host "❌ Test failed: $testName (Exit code: $exitCode)" } } catch { $failedTests++ - $testResults += "❌ $testName - FAILED (Exception: $_)" + # Include exception and any captured output + $outputText = if ($output) { "`n Output: $($output -join "`n ")" } else { "" } + $testResults += "❌ $testName - FAILED (Exception: $_)$outputText" Write-Host "❌ Test failed with exception: $testName" } } @@ -123,8 +129,12 @@ jobs: if: always() shell: pwsh run: | + # Determine job status based on previous steps + $jobStatus = if ("${{ steps.run_tests.outcome }}" -eq "success") { "success" } else { "failure" } + $results = @{ arch = "${{ matrix.arch }}" + status = $jobStatus total = "${{ steps.run_tests.outputs.total }}" passed = "${{ steps.run_tests.outputs.passed }}" failed = "${{ steps.run_tests.outputs.failed }}" @@ -171,17 +181,26 @@ jobs: for (const file of files) { const data = JSON.parse(fs.readFileSync(file, 'utf8')); const arch = data.arch; + const status = data.status || 'unknown'; const total = data.total || 0; const passed = data.passed || 0; const failed = data.failed || 0; - if (failed > 0) { + // Mark as failed if either tests failed OR job status is not success + if (failed > 0 || status !== 'success') { allPassed = false; } - const status = failed === 0 ? '✅' : '❌'; - commentBody += `### ${status} ${arch.toUpperCase()}\n`; - commentBody += `**${passed}/${total} tests passed**\n\n`; + // Determine emoji based on both test results and job status + const emoji = (failed === 0 && status === 'success') ? '✅' : '❌'; + commentBody += `### ${emoji} ${arch.toUpperCase()}\n`; + + // Show appropriate message based on job status + if (status !== 'success') { + commentBody += `**Job failed** - Tests may not have run due to compile or setup failure\n\n`; + } else { + commentBody += `**${passed}/${total} tests passed**\n\n`; + } if (data.details && data.details.trim()) { commentBody += '
\n'; diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 7518d21..9b84260 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -13,6 +13,8 @@ permissions: jobs: prepare: name: Prepare release (check files, version, notes) + # Only run if PR was actually merged + if: github.event.pull_request.merged == true runs-on: ubuntu-latest outputs: should_release: ${{ steps.check_files.outputs.should_release }} @@ -155,9 +157,12 @@ jobs: Write-Output "DEBUG: Base SHA: $baseSha" Write-Output "DEBUG: Head SHA: $headSha" - # Get the merge commit message (when PR is merged, this will be the merge commit) - # The merge commit is the commit that gets created when the PR is merged to main - $mergeCommitBody = git log -1 --pretty=format:"%b" HEAD + # Get the merge commit message using the actual merge commit SHA + # The merge_commit_sha is the SHA of the commit created when the PR is merged + $mergeCommitSha = "${{ github.event.pull_request.merge_commit_sha }}" + Write-Output "DEBUG: Merge commit SHA: $mergeCommitSha" + + $mergeCommitBody = git log -1 --pretty=format:"%b" $mergeCommitSha Write-Output "DEBUG: Merge commit body: $mergeCommitBody" # Get all commit messages in the PR From cbbed0688719af379e6a4c8627cea22b7ec7c482 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Sun, 1 Feb 2026 02:19:30 +0000 Subject: [PATCH 8/8] fix: initialize output variable outside try block to prevent undefined errors Co-authored-by: supervoidcoder <88671013+supervoidcoder@users.noreply.github.com> --- .github/workflows/build.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 939c6bf..d6952ef 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -68,6 +68,9 @@ jobs: $testName = $_.Name Write-Host "Running test: $testName" + # Initialize output variable outside try block + $output = $null + try { # Run the test and capture output and exit code $output = & $_.FullName 2>&1