Skip to content

Commit

Permalink
show summary
Browse files Browse the repository at this point in the history
  • Loading branch information
cenfun committed Jul 4, 2024
1 parent c203d40 commit 6ec1942
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
3 changes: 3 additions & 0 deletions github-actions-summary/example.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,9 @@ test('passed test', () => {

});

/**
* @owner Mark
*/
test('failed test', () => {
expect(false).toBe(true);
});
8 changes: 4 additions & 4 deletions github-actions-summary/github-actions-summary.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,26 +16,26 @@ export default async (reportData, helper) => {
fs.writeFileSync(summaryFile, '');
process.env.GITHUB_STEP_SUMMARY = summaryFile;

// https://github.com/actions/toolkit/tree/main/packages/core
summary.addHeading(reportData.name, '2');
summary.addRaw(`> ${reportData.dateH} (${reportData.durationH})`);
summary.addRaw(`📅 ${reportData.dateH} (🕒${reportData.durationH})`);
summary.addEOL();

const rows = [];
['tests', 'passed', 'flaky', 'skipped', 'failed'].forEach((k) => {
const item = reportData.summary[k];
const percent = item.percent ? ` (${item.percent})` : '';
rows.push([{
data: item.name
}, {
data: item.value
}, {
data: percent
data: item.percent
}]);
});
summary.addTable(rows);

if (reportData.summary.passed.value === reportData.summary.tests.value) {
summary.addRaw(' Congratulations! All tests passed.');
summary.addRaw(' Congratulations! All tests passed.');
} else if (reportData.summary.failed.value > 0) {
// @owners of all failed cases
const owners = [];
Expand Down

0 comments on commit 6ec1942

Please sign in to comment.