Skip to content

Commit ebe8b24

Browse files
authored
feat: add optional job summary-title parameter (#1056)
1 parent a2be6ec commit ebe8b24

File tree

5 files changed

+46
-8
lines changed

5 files changed

+46
-8
lines changed

.github/workflows/example-chrome.yml

+2
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ jobs:
2828
build: npx cypress info
2929
working-directory: examples/browser
3030
browser: chrome
31+
summary-title: 'Chrome headless'
3132
# As of Cypress v8.0 the `cypress run` command
3233
# executes tests in `headless` mode by default
3334

@@ -47,6 +48,7 @@ jobs:
4748
working-directory: examples/browser
4849
browser: chrome
4950
headed: true
51+
summary-title: 'Chrome headed'
5052

5153
- uses: actions/upload-artifact@v3
5254
with:

README.md

+34-5
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,8 @@
5454
- Use [timeouts](#timeouts) to avoid hanging CI jobs
5555
- Print [Cypress info](#print-cypress-info) like detected browsers
5656
- Run [tests nightly](#nightly-tests) or on any schedule
57-
- Suppress [test summary](#suppress-test-summary)
57+
- Specify [job summary title](#job-summary-title)
58+
- Suppress [job summary](#suppress-job-summary)
5859
- [More examples](#more-examples)
5960

6061
Examples contained in this repository, based on current Cypress versions, can be found in the [examples](./examples) directory. Examples for [Legacy Configuration](https://on.cypress.io/guides/references/legacy-configuration), which use Cypress `9.7.0`, are no longer maintained. They can be referred to in the [examples/v9](https://github.com/cypress-io/github-action/tree/v5/examples/v9) directory of the [v5](https://github.com/cypress-io/github-action/tree/v5/) branch.
@@ -1457,11 +1458,39 @@ jobs:
14571458

14581459
[![cron example](https://github.com/cypress-io/github-action/workflows/example-cron/badge.svg?branch=master)](.github/workflows/example-cron.yml)
14591460

1460-
### Suppress test summary
1461+
### Job summary title
14611462

1462-
The default test summary can be suppressed by using the parameter `publish-summary` and setting its value to `false`.
1463-
Sometimes users want to publish test summary using a specific action.
1464-
For example, a user running Cypress tests using a matrix and wants to retrieve the test summary for each matrix job and use a specific action that merges reports.
1463+
By default, the action produces a job summary in the GitHub Actions log for each workflow step where `github-action` is used. Each job summary shows a Passing / Failing status, the test counts for Passed, Failed, Pending & Skipped, followed by the Duration of the run. The job summaries are grouped by job.
1464+
1465+
To specify a title for a Job Summary, use the parameter `summary-title`. If no title is specified, then the default "Cypress Results" is used:
1466+
1467+
```yml
1468+
name: Summary titles
1469+
on: push
1470+
jobs:
1471+
tests:
1472+
runs-on: ubuntu-22.04
1473+
steps:
1474+
- uses: actions/checkout@v4
1475+
- name: Cypress headless tests
1476+
uses: cypress-io/github-action@v6
1477+
with:
1478+
summary-title: 'Headless'
1479+
- name: Cypress headed tests
1480+
uses: cypress-io/github-action@v6
1481+
with:
1482+
install: false
1483+
headed: true
1484+
summary-title: 'Headed'
1485+
```
1486+
1487+
The name of the GitHub Actions job is shown at the top of one or more job summaries from the same job. If multiple summaries belong to the same job, then giving them separate titles allows them to be uniquely identified.
1488+
1489+
See the [example-chrome.yml](.github/workflows/example-chrome.yml) workflow, with multiple calls to `cypress-io/github-action` in one job, making use of the `summary-title` parameter. View the [example-chrome.yml - actions log](https://github.com/cypress-io/github-action/actions/workflows/example-chrome.yml) for an example of the resulting job summaries.
1490+
1491+
### Suppress job summary
1492+
1493+
The default job summary can be suppressed by using the parameter `publish-summary` and setting its value to `false`.
14651494

14661495
```yml
14671496
name: Example no summary

action.yml

+4-1
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,12 @@ inputs:
6666
description: 'Whether or not to use headed mode'
6767
required: false
6868
publish-summary:
69-
description: 'Whether or not to publish job summary'
69+
description: 'Whether or not to publish a job summary'
7070
required: false
7171
default: true
72+
summary-title:
73+
description: 'Title for job summary'
74+
required: false
7275
spec:
7376
description: 'Provide a specific specs to run'
7477
required: false

dist/index.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -75298,8 +75298,10 @@ const generateSummary = async (testResults) => {
7529875298
`${testResults.totalDuration / 1000}s` || ''
7529975299
]
7530075300

75301+
const summaryTitle = core.getInput('summary-title')
75302+
7530175303
await core.summary
75302-
.addHeading('Cypress Results', 2)
75304+
.addHeading(summaryTitle ? summaryTitle : 'Cypress Results', 2)
7530375305
.addTable([headers, summaryRows])
7530475306
.addLink(
7530575307
testResults.runUrl ? 'View run in Cypress Cloud' : '',

index.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -902,8 +902,10 @@ const generateSummary = async (testResults) => {
902902
`${testResults.totalDuration / 1000}s` || ''
903903
]
904904

905+
const summaryTitle = core.getInput('summary-title')
906+
905907
await core.summary
906-
.addHeading('Cypress Results', 2)
908+
.addHeading(summaryTitle ? summaryTitle : 'Cypress Results', 2)
907909
.addTable([headers, summaryRows])
908910
.addLink(
909911
testResults.runUrl ? 'View run in Cypress Cloud' : '',

0 commit comments

Comments
 (0)