mirror of
https://github.com/dorny/test-reporter.git
synced 2025-12-16 06:17:10 +01:00
Add summary badge to report
This commit is contained in:
parent
92cb68e21e
commit
42eb11a3c8
9 changed files with 60 additions and 6 deletions
22
dist/index.js
generated
vendored
22
dist/index.js
generated
vendored
|
|
@ -750,15 +750,35 @@ const core = __importStar(__nccwpck_require__(2186));
|
|||
const markdown_utils_1 = __nccwpck_require__(6482);
|
||||
const slugger_1 = __nccwpck_require__(3328);
|
||||
function getReport(results) {
|
||||
const badge = getBadge(results);
|
||||
const runsSummary = results.map(getRunSummary).join('\n\n');
|
||||
const suites = results
|
||||
.flatMap(tr => tr.suites)
|
||||
.map((ts, i) => getSuiteSummary(ts, i))
|
||||
.join('\n');
|
||||
const suitesSection = `# Test Suites\n\n${suites}`;
|
||||
return [runsSummary, suitesSection].join('\n\n');
|
||||
return [badge, runsSummary, suitesSection].join('\n\n');
|
||||
}
|
||||
exports.default = getReport;
|
||||
function getBadge(results) {
|
||||
const passed = results.reduce((sum, tr) => sum + tr.passed, 0);
|
||||
const skipped = results.reduce((sum, tr) => sum + tr.skipped, 0);
|
||||
const failed = results.reduce((sum, tr) => sum + tr.failed, 0);
|
||||
const passedText = passed > 0 ? `${passed} passed` : null;
|
||||
const skippedText = skipped > 0 ? `${skipped} skipped` : null;
|
||||
const failedText = failed > 0 ? `${failed} failed` : null;
|
||||
const message = [passedText, skippedText, failedText].filter(s => s != null).join(', ') || 'none';
|
||||
let color = 'success';
|
||||
if (failed > 0) {
|
||||
color = 'critical';
|
||||
}
|
||||
else if (passed === 0 && failed === 0) {
|
||||
color = 'yellow';
|
||||
}
|
||||
const uri = encodeURIComponent(`tests-${message}-${color}`);
|
||||
const text = failed > 0 ? 'Tests failed' : 'Tests passed successfully';
|
||||
return ``;
|
||||
}
|
||||
function getRunSummary(tr) {
|
||||
core.info('Generating check run summary');
|
||||
const time = `${(tr.time / 1000).toFixed(3)}s`;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue