Skip to content

Commit

Permalink
Merge pull request #566 from cypress-io/adam/add-workflow-summary
Browse files Browse the repository at this point in the history
  • Loading branch information
admah committed Jun 10, 2022
2 parents 5c469cf + 3a65c0d commit be2de7b
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .github/workflows/example-component-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
- name: Checkout
uses: actions/checkout@v2
- name: Cypress run
uses: cypress-io/github-action@4
uses: cypress-io/github-action@v4
with:
working-directory: examples/v10/component-tests
component: true
37 changes: 37 additions & 0 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -75355,9 +75355,46 @@ const runTests = async () => {
process.chdir(workingDirectory)
return cypress
.run(cypressOptions)
.then(generateSummary)
.then(onTestsFinished, onTestsError)
}

const generateSummary = async (testResults) => {
const headers = [
{ data: 'Result', header: true },
{ data: 'Passed :white_check_mark:', header: true },
{ data: 'Failed :x:', header: true },
{ data: 'Pending :hand:', header: true },
{ data: 'Skipped :leftwards_arrow_with_hook:', header: true },
{ data: 'Duration :clock8:', header: true }
]

const status =
testResults.totalFailed === 0
? 'Passing :white_check_mark:'
: 'Failing :red_circle:'

const summaryRows = [
status,
`${testResults.totalPassed}`,
`${testResults.totalFailed}`,
`${testResults.totalPending}`,
`${testResults.totalSkipped}`,
`${testResults.totalDuration / 1000}s` || ''
]

await core.summary
.addHeading('Cypress Results', 2)
.addTable([headers, summaryRows])
.addLink(
testResults.runUrl ? 'View Run in Dashboard' : '',
testResults.runUrl || ''
)
.write()

return testResults
}

const installMaybe = () => {
const installParameter = getInputBool('install', true)
if (!installParameter) {
Expand Down
37 changes: 37 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -745,9 +745,46 @@ const runTests = async () => {
process.chdir(workingDirectory)
return cypress
.run(cypressOptions)
.then(generateSummary)
.then(onTestsFinished, onTestsError)
}

const generateSummary = async (testResults) => {
const headers = [
{ data: 'Result', header: true },
{ data: 'Passed :white_check_mark:', header: true },
{ data: 'Failed :x:', header: true },
{ data: 'Pending :hand:', header: true },
{ data: 'Skipped :leftwards_arrow_with_hook:', header: true },
{ data: 'Duration :clock8:', header: true }
]

const status =
testResults.totalFailed === 0
? 'Passing :white_check_mark:'
: 'Failing :red_circle:'

const summaryRows = [
status,
`${testResults.totalPassed}`,
`${testResults.totalFailed}`,
`${testResults.totalPending}`,
`${testResults.totalSkipped}`,
`${testResults.totalDuration / 1000}s` || ''
]

await core.summary
.addHeading('Cypress Results', 2)
.addTable([headers, summaryRows])
.addLink(
testResults.runUrl ? 'View Run in Dashboard' : '',
testResults.runUrl || ''
)
.write()

return testResults
}

const installMaybe = () => {
const installParameter = getInputBool('install', true)
if (!installParameter) {
Expand Down

0 comments on commit be2de7b

Please sign in to comment.