Skip to content

Commit

Permalink
test: [M3-6876] - Improve formatting of GitHub test result comments (#…
Browse files Browse the repository at this point in the history
…11200)

* Add optional title to GitHub comment, improve passing test headline

* Use HTML table for GitHub comment test result breakdown

* Change GitHub comment "Debugging" heading to "Troubleshooting"

* Added changeset: Slight improvements to GitHub test result comment formatting
  • Loading branch information
jdamore-linode authored Nov 1, 2024
1 parent 1985645 commit 2e6defb
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 6 deletions.
5 changes: 5 additions & 0 deletions packages/manager/.changeset/pr-11200-tests-1730467459621.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@linode/manager": Tests
---

Slight improvements to GitHub test result comment formatting ([#11200](https://github.com/linode/manager/pull/11200))
34 changes: 28 additions & 6 deletions scripts/junit-summary/formatters/github-formatter.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,16 @@ export const githubFormatter: Formatter = (
metadata: Metadata,
_junitData: TestSuites[]
) => {
const title = !!metadata.pipelineTitle
? `## ${metadata.pipelineTitle}`
: null;

const headline = (() => {
const headingMarkdown = '## ';
const headingMarkdown = '### ';

const description = runInfo.failing
? `${runInfo.failing} failing ${pluralize(runInfo.failing, 'test', 'tests')} on`
: `Passing`;
? `:small_red_triangle: ${runInfo.failing} failing ${pluralize(runInfo.failing, 'test', 'tests')} on`
: `:tada: ${runInfo.passing} passing ${pluralize(runInfo.passing, 'test', 'tests')} on`;

// If available, render a link for the run.
const runLink = (metadata.runId && metadata.runUrl)
Expand All @@ -37,12 +42,28 @@ export const githubFormatter: Formatter = (
return `${headingMarkdown}${description} ${runLink}`;
})();

const breakdown = `:x: ${runInfo.failing} Failing | :green_heart: ${runInfo.passing} Passing | :arrow_right_hook: ${runInfo.skipped} Skipped | :clock1: ${secondsToTimeString(runInfo.time)}\n\n`;
const breakdown = [
'<table>',
'<thead><tr>',
'<td><strong>:x: Failing</strong></td>',
'<td><strong>:white_check_mark: Passing</strong></td>',
'<td><strong>:arrow_right_hook: Skipped</strong></td>',
'<td><strong>:clock1: Duration</strong></td>',
'</tr></thead>',
'<tbody><tr>',
`<td><code>${runInfo.failing} Failing</code></td>`,
`<td><code>${runInfo.passing} Passing</code></td>`,
`<td><code>${runInfo.skipped} Skipped</code></td>`,
`<td><code>${secondsToTimeString(runInfo.time)}</code></td>`,
'</tr></tbody>',
'</table>',
'\n\n',
].join('');

const extra = metadata.extra ? `${metadata.extra}\n\n` : null;

const failedTestSummary = (() => {
const heading = `### Details`;
const heading = `#### Details`;
const failedTestHeader = `<table><thead><tr><th colspan="3">Failing Tests</th></tr><tr><th></th><th>Spec</th><th>Test</th></tr></thead><tbody>`;
const failedTestRows = results
.filter((result: TestResult) => result.failing)
Expand All @@ -62,7 +83,7 @@ export const githubFormatter: Formatter = (
})();

const rerunNote = (() => {
const heading = `### Debugging`;
const heading = `#### Troubleshooting`;
const failingTestFiles = results
.filter((result: TestResult) => result.failing)
.map((result: TestResult) => result.testFilename);
Expand All @@ -81,6 +102,7 @@ export const githubFormatter: Formatter = (
})();

return [
title,
headline,
'',
breakdown,
Expand Down

0 comments on commit 2e6defb

Please sign in to comment.