Skip to content

Commit 0372df5

Browse files
committed
More informative check summary
1 parent 2649c1a commit 0372df5

1 file changed

Lines changed: 39 additions & 1 deletion

File tree

src/github/handler.ts

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,42 @@ async function postOrUpdateIssueComment(
267267
}
268268
}
269269

270+
/**
271+
* Formats the test summary into a string like "10 passed, 1 failed, 2 skipped".
272+
* @param summary - The test summary object
273+
* @returns Formatted summary string
274+
*/
275+
function formatTestSummary(summary: { passed: number; failed: number; skipped: number; pending: number; other: number }): string {
276+
const parts: string[] = []
277+
278+
if (summary.passed > 0) {
279+
parts.push(`${summary.passed} passed`)
280+
}
281+
282+
if (summary.failed > 0) {
283+
parts.push(`${summary.failed} failed`)
284+
}
285+
286+
if (summary.skipped > 0) {
287+
parts.push(`${summary.skipped} skipped`)
288+
}
289+
290+
if (summary.pending > 0) {
291+
parts.push(`${summary.pending} pending`)
292+
}
293+
294+
if (summary.other > 0) {
295+
parts.push(`${summary.other} other`)
296+
}
297+
298+
if (parts.length === 0) {
299+
return 'No tests'
300+
}
301+
302+
return parts.join(', ')
303+
}
304+
305+
270306
/**
271307
* Creates a status check for a action.
272308
*
@@ -285,14 +321,16 @@ export async function createStatusCheck(
285321
}
286322

287323
try {
324+
const formattedSummary = formatTestSummary(report.results.summary)
325+
288326
await createCheckRun(
289327
context.repo.owner,
290328
context.repo.repo,
291329
context.sha,
292330
inputs.statusCheckName,
293331
'completed',
294332
report.results.summary.failed > 0 ? 'failure' : 'success',
295-
'Test Results',
333+
formattedSummary,
296334
summary
297335
)
298336
} catch (error) {

0 commit comments

Comments
 (0)