From 382a01330c13c01132abb08fa7345a40eefd4f4c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniels=20=C5=A0atcs?= Date: Thu, 9 Apr 2026 20:16:17 +0300 Subject: [PATCH] More informative check summary --- __tests__/github/handler.test.ts | 10 ++++---- src/github/handler.ts | 40 +++++++++++++++++++++++++++++++- 2 files changed, 45 insertions(+), 5 deletions(-) diff --git a/__tests__/github/handler.test.ts b/__tests__/github/handler.test.ts index 0920d480..fd95f073 100644 --- a/__tests__/github/handler.test.ts +++ b/__tests__/github/handler.test.ts @@ -125,7 +125,8 @@ describe('createStatusCheck', () => { const report: Report = { results: { summary: { - failed: 0 + passed: 5, + skipped: 2 } } } as Report @@ -139,7 +140,7 @@ describe('createStatusCheck', () => { 'Test Status', 'completed', 'success', - 'Test Results', + '5 passed, 2 skipped', 'Test summary' ) }) @@ -167,7 +168,7 @@ describe('createStatusCheck', () => { 'Test Status', 'completed', 'failure', - 'Test Results', + '1 failed', 'Test summary' ) }) @@ -184,6 +185,7 @@ describe('createStatusCheck', () => { const report: Report = { results: { summary: { + passed: 10, failed: 0 } } @@ -201,7 +203,7 @@ describe('createStatusCheck', () => { 'Test Status', 'completed', 'success', - 'Test Results', + '10 passed', expect.stringMatching(/^a{65000}$/) ) }) diff --git a/src/github/handler.ts b/src/github/handler.ts index 63066fc4..588d1f44 100644 --- a/src/github/handler.ts +++ b/src/github/handler.ts @@ -267,6 +267,42 @@ async function postOrUpdateIssueComment( } } +/** + * Formats the test summary into a string like "10 passed, 1 failed, 2 skipped". + * @param summary - The test summary object + * @returns Formatted summary string + */ +function formatTestSummary(summary: { passed: number; failed: number; skipped: number; pending: number; other: number }): string { + const parts: string[] = [] + + if (summary.passed > 0) { + parts.push(`${summary.passed} passed`) + } + + if (summary.failed > 0) { + parts.push(`${summary.failed} failed`) + } + + if (summary.skipped > 0) { + parts.push(`${summary.skipped} skipped`) + } + + if (summary.pending > 0) { + parts.push(`${summary.pending} pending`) + } + + if (summary.other > 0) { + parts.push(`${summary.other} other`) + } + + if (parts.length === 0) { + return 'No tests' + } + + return parts.join(', ') +} + + /** * Creates a status check for a action. * @@ -285,6 +321,8 @@ export async function createStatusCheck( } try { + const formattedSummary = formatTestSummary(report.results.summary) + await createCheckRun( context.repo.owner, context.repo.repo, @@ -292,7 +330,7 @@ export async function createStatusCheck( inputs.statusCheckName, 'completed', report.results.summary.failed > 0 ? 'failure' : 'success', - 'Test Results', + formattedSummary, summary ) } catch (error) {