Skip to content

Commit

Permalink
- further improve table format, remove obsolete first column
Browse files Browse the repository at this point in the history
- ensure flaky table is built only if enabled (but also if detailed is disabled)
  • Loading branch information
mikepenz committed Nov 3, 2024
1 parent d9c3594 commit bc02967
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 39 deletions.
35 changes: 18 additions & 17 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion src/annotator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ export async function attachSummary(
flakySummary: SummaryTableRow[]
): Promise<void> {
await core.summary.addTable(table).write()
if (detailsTable.length > 0) {
if (detailsTable.length > 1) {
await core.summary.addTable(detailsTable).write()
}
if (flakySummary.length > 1) {
Expand Down
42 changes: 22 additions & 20 deletions src/table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ export function buildSummaryTables(
? []
: [
[
{data: '', header: true},
{data: 'Test', header: true},
{data: 'Result', header: true}
]
Expand All @@ -33,7 +32,6 @@ export function buildSummaryTables(
? []
: [
[
{data: '', header: true},
{data: 'Test', header: true},
{data: 'Retries', header: true}
]
Expand All @@ -48,23 +46,23 @@ export function buildSummaryTables(
`${testResult.failed} failed`
])

if (detailedSummary) {
const annotations = testResult.globalAnnotations.filter(
annotation => includePassed || annotation.annotation_level !== 'notice'
)
const annotations = testResult.globalAnnotations.filter(
annotation => includePassed || annotation.annotation_level !== 'notice'
)

if (annotations.length === 0) {
if (!includePassed) {
core.info(
`⚠️ No annotations found for ${testResult.checkName}. If you want to include passed results in this table please configure 'include_passed' as 'true'`
)
}
detailsTable.push([`-`, `No test annotations available`, `-`])
} else {
if (annotations.length === 0) {
if (!includePassed) {
core.info(
`⚠️ No annotations found for ${testResult.checkName}. If you want to include passed results in this table please configure 'include_passed' as 'true'`
)
}
detailsTable.push([{data: `No test annotations available`, colspan: '2'}])
} else {
if (detailedSummary) {
detailsTable.push([{data: `${testResult.checkName}`, colspan: '2'}])
if (!groupSuite) {
for (const annotation of annotations) {
detailsTable.push([
`${testResult.checkName}`,
`${annotation.title}`,
`${
annotation.status === 'success'
Expand All @@ -76,15 +74,19 @@ export function buildSummaryTables(
])
}
} else {
detailsTable.push([`${testResult.checkName}`, ``, ``])
for (const internalTestResult of testResult.testResults) {
appendDetailsTable(internalTestResult, detailsTable, includePassed)
}
}
}
for (const annotation of annotations) {
if (annotation.retries > 0) {
flakyTable.push([`${testResult.checkName}`, `${annotation.title}`, `${annotation.retries}`])

if (flakySummary) {
const flakyAnnotations = annotations.filter(annotation => annotation.retries > 0)
if (flakyAnnotations.length > 0) {
flakyTable.push([{data: `${testResult.checkName}`, colspan: '2'}])
for (const annotation of flakyAnnotations) {
flakyTable.push([`${annotation.title}`, `${annotation.retries}`])
}
}
}
}
Expand All @@ -101,9 +103,9 @@ function appendDetailsTable(
annotation => includePassed || annotation.annotation_level !== 'notice'
)
if (annotations.length > 0) {
detailsTable.push([{data: `${testResult.name}`, colspan: '2'}])
for (const annotation of annotations) {
detailsTable.push([
`${testResult.name}`,
`${annotation.title}`,
`${
annotation.status === 'success'
Expand Down

0 comments on commit bc02967

Please sign in to comment.