diff --git a/.github/workflows/example-chrome.yml b/.github/workflows/example-chrome.yml index 69c496ec9..7f10d1c49 100644 --- a/.github/workflows/example-chrome.yml +++ b/.github/workflows/example-chrome.yml @@ -28,6 +28,7 @@ jobs: build: npx cypress info working-directory: examples/browser browser: chrome + summary-title: 'Chrome headless' # As of Cypress v8.0 the `cypress run` command # executes tests in `headless` mode by default @@ -47,6 +48,7 @@ jobs: working-directory: examples/browser browser: chrome headed: true + summary-title: 'Chrome headed' - uses: actions/upload-artifact@v3 with: diff --git a/README.md b/README.md index 7124c9d6b..56398d04d 100644 --- a/README.md +++ b/README.md @@ -54,7 +54,8 @@ - Use [timeouts](#timeouts) to avoid hanging CI jobs - Print [Cypress info](#print-cypress-info) like detected browsers - Run [tests nightly](#nightly-tests) or on any schedule -- Suppress [test summary](#suppress-test-summary) +- Specify [job summary title](#job-summary-title) +- Suppress [job summary](#suppress-job-summary) - [More examples](#more-examples) 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: [![cron example](https://github.com/cypress-io/github-action/workflows/example-cron/badge.svg?branch=master)](.github/workflows/example-cron.yml) -### Suppress test summary +### Job summary title -The default test summary can be suppressed by using the parameter `publish-summary` and setting its value to `false`. -Sometimes users want to publish test summary using a specific action. -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. +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. + +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: + +```yml +name: Summary titles +on: push +jobs: + tests: + runs-on: ubuntu-22.04 + steps: + - uses: actions/checkout@v4 + - name: Cypress headless tests + uses: cypress-io/github-action@v6 + with: + summary-title: 'Headless' + - name: Cypress headed tests + uses: cypress-io/github-action@v6 + with: + install: false + headed: true + summary-title: 'Headed' +``` + +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. + +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. + +### Suppress job summary + +The default job summary can be suppressed by using the parameter `publish-summary` and setting its value to `false`. ```yml name: Example no summary diff --git a/action.yml b/action.yml index d5d1b4609..d0cf93cb1 100644 --- a/action.yml +++ b/action.yml @@ -66,9 +66,12 @@ inputs: description: 'Whether or not to use headed mode' required: false publish-summary: - description: 'Whether or not to publish job summary' + description: 'Whether or not to publish a job summary' required: false default: true + summary-title: + description: 'Title for job summary' + required: false spec: description: 'Provide a specific specs to run' required: false diff --git a/dist/index.js b/dist/index.js index 80ce2b240..e74360e84 100644 --- a/dist/index.js +++ b/dist/index.js @@ -75298,8 +75298,10 @@ const generateSummary = async (testResults) => { `${testResults.totalDuration / 1000}s` || '' ] + const summaryTitle = core.getInput('summary-title') + await core.summary - .addHeading('Cypress Results', 2) + .addHeading(summaryTitle ? summaryTitle : 'Cypress Results', 2) .addTable([headers, summaryRows]) .addLink( testResults.runUrl ? 'View run in Cypress Cloud' : '', diff --git a/index.js b/index.js index 2b550e382..a1743a42c 100644 --- a/index.js +++ b/index.js @@ -902,8 +902,10 @@ const generateSummary = async (testResults) => { `${testResults.totalDuration / 1000}s` || '' ] + const summaryTitle = core.getInput('summary-title') + await core.summary - .addHeading('Cypress Results', 2) + .addHeading(summaryTitle ? summaryTitle : 'Cypress Results', 2) .addTable([headers, summaryRows]) .addLink( testResults.runUrl ? 'View run in Cypress Cloud' : '',