Skip to content

Commit 8906b05

Browse files
fix: capture test output, add job status, and fix merge commit SHA
Co-authored-by: supervoidcoder <88671013+supervoidcoder@users.noreply.github.com>
1 parent d16d7f4 commit 8906b05

2 files changed

Lines changed: 36 additions & 12 deletions

File tree

.github/workflows/build.yml

Lines changed: 28 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -69,22 +69,28 @@ jobs:
6969
Write-Host "Running test: $testName"
7070
7171
try {
72-
# Run the test and capture exit code
73-
& $_.FullName 2>&1 | Out-Null
72+
# Run the test and capture output and exit code
73+
$output = & $_.FullName 2>&1
7474
$exitCode = $LASTEXITCODE
7575
7676
if ($exitCode -eq 0) {
7777
$passedTests++
78-
$testResults += "✅ $testName - PASSED"
78+
# Include output in the result
79+
$outputText = if ($output) { "`n Output: $($output -join "`n ")" } else { "" }
80+
$testResults += "✅ $testName - PASSED$outputText"
7981
Write-Host "✅ Test passed: $testName"
8082
} else {
8183
$failedTests++
82-
$testResults += "❌ $testName - FAILED (Exit code: $exitCode)"
84+
# Include output and exit code in the result
85+
$outputText = if ($output) { "`n Output: $($output -join "`n ")" } else { "" }
86+
$testResults += "❌ $testName - FAILED (Exit code: $exitCode)$outputText"
8387
Write-Host "❌ Test failed: $testName (Exit code: $exitCode)"
8488
}
8589
} catch {
8690
$failedTests++
87-
$testResults += "❌ $testName - FAILED (Exception: $_)"
91+
# Include exception and any captured output
92+
$outputText = if ($output) { "`n Output: $($output -join "`n ")" } else { "" }
93+
$testResults += "❌ $testName - FAILED (Exception: $_)$outputText"
8894
Write-Host "❌ Test failed with exception: $testName"
8995
}
9096
}
@@ -123,8 +129,12 @@ jobs:
123129
if: always()
124130
shell: pwsh
125131
run: |
132+
# Determine job status based on previous steps
133+
$jobStatus = if ("${{ steps.run_tests.outcome }}" -eq "success") { "success" } else { "failure" }
134+
126135
$results = @{
127136
arch = "${{ matrix.arch }}"
137+
status = $jobStatus
128138
total = "${{ steps.run_tests.outputs.total }}"
129139
passed = "${{ steps.run_tests.outputs.passed }}"
130140
failed = "${{ steps.run_tests.outputs.failed }}"
@@ -171,17 +181,26 @@ jobs:
171181
for (const file of files) {
172182
const data = JSON.parse(fs.readFileSync(file, 'utf8'));
173183
const arch = data.arch;
184+
const status = data.status || 'unknown';
174185
const total = data.total || 0;
175186
const passed = data.passed || 0;
176187
const failed = data.failed || 0;
177188
178-
if (failed > 0) {
189+
// Mark as failed if either tests failed OR job status is not success
190+
if (failed > 0 || status !== 'success') {
179191
allPassed = false;
180192
}
181193
182-
const status = failed === 0 ? '✅' : '❌';
183-
commentBody += `### ${status} ${arch.toUpperCase()}\n`;
184-
commentBody += `**${passed}/${total} tests passed**\n\n`;
194+
// Determine emoji based on both test results and job status
195+
const emoji = (failed === 0 && status === 'success') ? '✅' : '❌';
196+
commentBody += `### ${emoji} ${arch.toUpperCase()}\n`;
197+
198+
// Show appropriate message based on job status
199+
if (status !== 'success') {
200+
commentBody += `**Job failed** - Tests may not have run due to compile or setup failure\n\n`;
201+
} else {
202+
commentBody += `**${passed}/${total} tests passed**\n\n`;
203+
}
185204
186205
if (data.details && data.details.trim()) {
187206
commentBody += '<details>\n';

.github/workflows/release.yml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ permissions:
1313
jobs:
1414
prepare:
1515
name: Prepare release (check files, version, notes)
16+
# Only run if PR was actually merged
17+
if: github.event.pull_request.merged == true
1618
runs-on: ubuntu-latest
1719
outputs:
1820
should_release: ${{ steps.check_files.outputs.should_release }}
@@ -155,9 +157,12 @@ jobs:
155157
Write-Output "DEBUG: Base SHA: $baseSha"
156158
Write-Output "DEBUG: Head SHA: $headSha"
157159
158-
# Get the merge commit message (when PR is merged, this will be the merge commit)
159-
# The merge commit is the commit that gets created when the PR is merged to main
160-
$mergeCommitBody = git log -1 --pretty=format:"%b" HEAD
160+
# Get the merge commit message using the actual merge commit SHA
161+
# The merge_commit_sha is the SHA of the commit created when the PR is merged
162+
$mergeCommitSha = "${{ github.event.pull_request.merge_commit_sha }}"
163+
Write-Output "DEBUG: Merge commit SHA: $mergeCommitSha"
164+
165+
$mergeCommitBody = git log -1 --pretty=format:"%b" $mergeCommitSha
161166
Write-Output "DEBUG: Merge commit body: $mergeCommitBody"
162167
163168
# Get all commit messages in the PR

0 commit comments

Comments
 (0)