Skip to content

Commit

Permalink
Merge pull request #597 from mikepenz/feature/591
Browse files Browse the repository at this point in the history
Include passed count always in the summary
  • Loading branch information
mikepenz authored Jul 15, 2022
2 parents b56a6d7 + 8df9ab3 commit 8b8d3c8
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 27 deletions.
20 changes: 7 additions & 13 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.

19 changes: 7 additions & 12 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,21 +49,17 @@ export async function run(): Promise<void> {
const foundResults = testResult.count > 0 || testResult.skipped > 0

// get the count of passed and failed tests.
const passed = testResult.annotations.filter(
a => a.annotation_level === 'notice'
const failed = testResult.annotations.filter(
a => a.annotation_level === 'failure'
).length
const failed = testResult.annotations.length - passed
const passed = testResult.count - failed - testResult.skipped

core.setOutput('passed', passed)
core.setOutput('failed', failed)

let title = 'No test results found!'
if (foundResults) {
if (includePassed) {
title = `${testResult.count} tests run, ${passed} passed, ${testResult.skipped} skipped, ${failed} failed.`
} else {
title = `${testResult.count} tests run, ${testResult.skipped} skipped, ${failed} failed.`
}
title = `${testResult.count} tests run, ${passed} passed, ${testResult.skipped} skipped, ${failed} failed.`
}

core.info(`ℹ️ ${title}`)
Expand Down Expand Up @@ -165,19 +161,18 @@ export async function run(): Promise<void> {
const table: SummaryTableRow[] = [
[
{data: 'Tests', header: true},
{data: 'Passed ✅', header: true},
{data: 'Skipped ↪️', header: true},
{data: 'Failed ❌', header: true}
],
[
`${testResult.count} run`,
`${passed} passed`,
`${testResult.skipped} skipped`,
`${failed} failed`
]
]
if (includePassed) {
table[0].splice(1, 0, {data: 'Passed ✅', header: true})
table[1].splice(1, 0, `${passed} passed`)
}

await core.summary.addHeading(checkName).addTable(table).write()

if (failOnFailure && conclusion === 'failure') {
Expand Down
3 changes: 2 additions & 1 deletion src/testParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -257,8 +257,9 @@ async function parseSuite(
const failed = testcase.failure || testcase.error
const success = !failed

if (testcase.skipped || testcase._attributes.status === 'disabled')
if (testcase.skipped || testcase._attributes.status === 'disabled') {
skipped++
}
if (failed || (includePassed && success)) {
const stackTrace: string = (
(testcase.failure && testcase.failure._cdata) ||
Expand Down

0 comments on commit 8b8d3c8

Please sign in to comment.