Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ jobs:
| `require_tests` | Optional. Fail if no test are found. |
| `require_passed_tests` | Optional. Fail if no passed test are found. (This is stricter than `require_tests`, which accepts skipped tests). |
| `include_passed` | Optional. By default the action will skip passed items for the annotations. Enable this flag to include them. |
| `include_skipped` | Optional. Controls whether skipped tests are included in the detailed summary table. Defaults to `true`. |
| `check_retries` | Optional. If a testcase is retried, ignore the original failure. |
| `check_title_template` | Optional. Template to configure the title format. Placeholders: {{FILE_NAME}}, {{SUITE_NAME}}, {{TEST_NAME}}, {{CLASS_NAME}}, {{BREAD_CRUMB}}. |
| `bread_crumb_delimiter` | Optional. Defines the delimiter characters between the breadcrumb elements. Defaults to: `/`. |
Expand Down
41 changes: 38 additions & 3 deletions __tests__/table.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ describe('buildSummaryTables', () => {
'/'
)

const [table, detailTable, flakyTable] = buildSummaryTables([testResult], true, true, true, true, false)
const [table, detailTable, flakyTable] = buildSummaryTables([testResult], true, true, true, true, true, false)

expect(table).toStrictEqual(NORMAL_TABLE)
expect(detailTable).toStrictEqual([
Expand Down Expand Up @@ -116,12 +116,47 @@ describe('buildSummaryTables', () => {
'/'
)

const [table, detailTable, flakyTable] = buildSummaryTables([testResult], true, true, true, true, true)
const [table, detailTable, flakyTable] = buildSummaryTables([testResult], true, true, true, true, true, true)
expect(table).toStrictEqual([])
expect(detailTable).toStrictEqual([])
expect(flakyTable).toStrictEqual([])
})

it('should exclude skipped tests when includeSkipped is false', async () => {
const testResult = await parseTestReports(
'checkName',
'summary',
'test_results/tests/utils/target/surefire-reports/TEST-action.surefire.report.calc.StringUtilsTest.xml', // This file has skipped tests
'*',
true,
true,
true,
[],
'{{SUITE_NAME}}/{{TEST_NAME}}',
'/'
)

// Test with includeSkipped = false (should exclude skipped tests from detailed table)
const [, detailTable] = buildSummaryTables([testResult], true, false, true, false, false, false)

// Check that the detail table doesn't include skipped tests
const flatResults = detailTable.flat()
const hasSkippedTests = flatResults.some(
cell => typeof cell === 'string' && cell.includes('⚠️ skipped')
)
expect(hasSkippedTests).toBe(false)

// Test with includeSkipped = true (should include skipped tests in detailed table)
const [, detailTableWithSkipped] = buildSummaryTables([testResult], true, true, true, false, false, false)

// Check that the detail table includes skipped tests
const flatResultsWithSkipped = detailTableWithSkipped.flat()
const hasSkippedTestsIncluded = flatResultsWithSkipped.some(
cell => typeof cell === 'string' && cell.includes('⚠️ skipped')
)
expect(hasSkippedTestsIncluded).toBe(true)
})

it('should group detail tables', async () => {
const testResult = await parseTestReports(
'checkName',
Expand All @@ -136,7 +171,7 @@ describe('buildSummaryTables', () => {
'/'
)

const [table, detailTable, flakyTable] = buildSummaryTables([testResult], true, true, true, true, false, true)
const [table, detailTable, flakyTable] = buildSummaryTables([testResult], true, true, true, true, true, false, true)

expect(table).toStrictEqual(NORMAL_TABLE)
expect(detailTable).toStrictEqual([
Expand Down
4 changes: 4 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,10 @@ inputs:
description: 'Include passed tests in the report'
required: false
default: 'false'
include_skipped:
description: 'Include skipped tests in the report'
required: false
default: 'true'
check_title_template:
description: |-
Template to configure the title format. Placeholders: {{FILE_NAME}}, {{SUITE_NAME}}, {{TEST_NAME}}, {{CLASS_NAME}}, {{BREAD_CRUMB}}.
Expand Down
2 changes: 2 additions & 0 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ export async function run(): Promise<void> {
const requireTests = core.getInput('require_tests') === 'true'
const requirePassedTests = core.getInput('require_passed_tests') === 'true'
const includePassed = core.getInput('include_passed') === 'true'
const includeSkipped = core.getInput('include_skipped') === 'true'
const checkRetries = core.getInput('check_retries') === 'true'
const annotateNotice = core.getInput('annotate_notice') === 'true'
const jobSummary = core.getInput('job_summary') === 'true'
Expand Down Expand Up @@ -186,6 +187,7 @@ export async function run(): Promise<void> {
const [table, detailTable, flakyTable] = buildSummaryTables(
testResults,
includePassed,
includeSkipped,
detailedSummary,
flakySummary,
verboseSummary,
Expand Down
18 changes: 15 additions & 3 deletions src/table.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import {toFormatedTime} from './utils.js'
export function buildSummaryTables(
testResults: TestResult[],
includePassed: boolean,
includeSkipped: boolean,
detailedSummary: boolean,
flakySummary: boolean,
verboseSummary: boolean,
Expand Down Expand Up @@ -91,7 +92,9 @@ export function buildSummaryTables(
table.push(row)

const annotations = testResult.globalAnnotations.filter(
annotation => includePassed || annotation.annotation_level !== 'notice'
annotation =>
(includePassed || annotation.annotation_level !== 'notice' || annotation.status !== 'success') &&
(includeSkipped || annotation.status !== 'skipped')
)

if (annotations.length === 0) {
Expand Down Expand Up @@ -129,6 +132,7 @@ export function buildSummaryTables(
internalTestResult,
detailsTable,
includePassed,
includeSkipped,
includeTimeInSummary,
passedDetailIcon,
skippedDetailIcon
Expand All @@ -138,7 +142,11 @@ export function buildSummaryTables(
}

if (flakySummary) {
const flakyAnnotations = annotations.filter(annotation => annotation.retries > 0)
const flakyAnnotations = annotations.filter(
annotation =>
annotation.retries > 0 &&
(includeSkipped || annotation.status !== 'skipped')
)
if (flakyAnnotations.length > 0) {
flakyTable.push([{data: `<strong>${testResult.checkName}</strong>`, colspan}])
for (const annotation of flakyAnnotations) {
Expand All @@ -159,13 +167,16 @@ function appendDetailsTable(
testResult: ActualTestResult,
detailsTable: SummaryTableRow[],
includePassed: boolean,
includeSkipped: boolean,
includeTimeInSummary: boolean,
passedDetailIcon: string,
skippedDetailIcon: string
): void {
const colspan = includeTimeInSummary ? '3' : '2'
const annotations = testResult.annotations.filter(
annotation => includePassed || annotation.annotation_level !== 'notice'
annotation =>
(includePassed || annotation.annotation_level !== 'notice' || annotation.status !== 'success') &&
(includeSkipped || annotation.status !== 'skipped')
)
if (annotations.length > 0) {
detailsTable.push([{data: `<em>${testResult.name}</em>`, colspan}])
Expand All @@ -191,6 +202,7 @@ function appendDetailsTable(
childTestResult,
detailsTable,
includePassed,
includeSkipped,
includeTimeInSummary,
passedDetailIcon,
skippedDetailIcon
Expand Down