Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Include passed count always in the summary #597

Merged
merged 2 commits into from
Jul 15, 2022
Merged
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
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