@cypress/github-action 6.7.16 → 6.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -1,10 +1,28 @@
1
1
  # cypress-io/github-action [![Action status][ci-badge]][ci-workflow] [![cypress][cloud-badge]][cloud-project] [![renovate-app badge][renovate-badge]][renovate-bot]
2
2
 
3
- > [GitHub Action](https://docs.github.com/en/actions) for running [Cypress](https://www.cypress.io) end-to-end and component tests. Includes npm, pnpm and Yarn installation, custom caching and lots of configuration options.
4
-
5
- Placing `use: cypress-io/github-action@v6` into a GitHub Action workflow gives you a simple way to run Cypress. The action takes the project's npm, pnpm or Yarn package manager lock file, installs dependencies and caches these dependencies for future use. It then proceeds to run Cypress end-to-end tests with the built-in Electron browser and provides a test summary after completion.
6
-
7
- If you are testing against a running server like the [Cypress Kitchen Sink showcase example](https://example.cypress.io/) on https://example.cypress.io/ no other parameters are necessary. In other cases where you need to fire up a development server, you can add the [start](#start-server) parameter to the workflow. Browse through the examples to find other useful parameters.
3
+ > [Cypress](https://www.cypress.io) based `cypress-io/github-action` runs [End-to-End](#end-to-end-testing) or [Component](#component-testing) tests in [GitHub Actions](https://docs.github.com/en/actions/) Continuous Integration (CI) workflows, optionally [recording](#record-test-results-on-cypress-cloud) to [Cypress Cloud](https://on.cypress.io/guides/cloud/introduction)
4
+
5
+ ## Introduction
6
+
7
+ In addition to running Cypress tests, the action includes [dependency installation](#installation), [caching](#caching) and more:
8
+
9
+ | Function | Benefits |
10
+ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
11
+ | [Single-line call](#end-to-end-testing) | Simplified use by installing dependencies and running Cypress in one line of workflow code |
12
+ | [Build app](#build-app), [Start server](#start-server) and [Wait for server](#wait-on) options | Convenience of app, server and test coordination |
13
+ | [cypress run](https://docs.cypress.io/app/references/command-line#cypress-run) CLI type options | Improved readability with vertically listed workflow options |
14
+ | [Dependency installation](#installation) based on [npm](https://docs.npmjs.com/cli/configuring-npm/package-lock-json), [pnpm](https://pnpm.io/git#lockfiles) and [Yarn Classic](https://classic.yarnpkg.com/en/docs/yarn-lock) lock files | Reduced command complexity |
15
+ | [Caching](#caching) of Cypress binary and dependencies for [npm](https://docs.npmjs.com/cli/commands/npm-cache) and [Yarn Classic](https://classic.yarnpkg.com/lang/en/docs/cli/cache/) installations | Reduced download bandwidth requirements |
16
+ | [Job summary](#job-summary-title) | Fast access to results overview |
17
+ | [Docker](#docker-image) compatibility | Improved independence from [GitHub-hosted runner image](https://docs.github.com/en/actions/using-github-hosted-runners/using-github-hosted-runners/about-github-hosted-runners) version changes. Fixed Docker environments can be used. |
18
+ | [Recording](#record-test-results-on-cypress-cloud) to Cypress Cloud compatibility including [parallel](#parallel) execution | Improved interpretation of test results through [Cypress Cloud](https://on.cypress.io/cloud) |
19
+ | [Live examples](#examples) | Speeds up introduction and troubleshooting |
20
+ | [Yarn Modern](#yarn-modern) usage and cache examples | Extends usage beyond [Yarn Classic](https://classic.yarnpkg.com/) |
21
+ | [pnpm cache examples](#pnpm) | Reduced download bandwidth requirements for [pnpm](https://pnpm.io/) |
22
+ | [Debug](#debugging) enabled | Improved workflow troubleshooting |
23
+ | [Ping utility](#debugging-waiting-for-url-to-respond) | Improved server reachability troubleshooting |
24
+
25
+ The following examples demonstrate the actions' functions.
8
26
 
9
27
  ## Examples
10
28
 
@@ -21,12 +39,11 @@ If you are testing against a running server like the [Cypress Kitchen Sink showc
21
39
  - Run only some [spec files](#specs)
22
40
  - Test [project in subfolder](#project)
23
41
  - [Record results](#record-test-results-on-cypress-cloud) on Cypress Cloud
24
- - Storing the [Project ID and Record Key](#project-id-and-record-key)
25
42
  - Getting [Git information](#git-information) environment variables
26
43
  - Getting [PR and URL](#automatic-pr-number-and-url-detection) automatically
27
44
  - Overwriting [Merge SHA into SHA](#merge-sha-into-sha) message
28
45
  - Tag [recordings](#tag-recordings)
29
- - Specify [auto cancel](#specify-auto-cancel-after-failures) after failures
46
+ - Specify [auto cancel](#auto-cancel-after-failures) after failures
30
47
  - Store [test artifacts](#artifacts) on GitHub
31
48
  - [Quiet output](#quiet-flag)
32
49
  - Set Cypress [config values](#config)
@@ -37,7 +54,6 @@ If you are testing against a running server like the [Cypress Kitchen Sink showc
37
54
  - [Start server](#start-server) before running the tests
38
55
  - [Start multiple servers](#start-multiple-servers) before running the tests
39
56
  - [Wait for server](#wait-on) to respond before running the tests
40
- - [`wait-on` with Node.js 18+](#wait-on-with-nodejs-18) workarounds
41
57
  - Use [custom install command](#custom-install-command)
42
58
  - Use [command prefix](#command-prefix)
43
59
  - Use [own custom test command](#custom-test-command)
@@ -365,9 +381,13 @@ For more information, visit [the Cypress command-line docs](https://on.cypress.i
365
381
 
366
382
  ### Record test results on Cypress Cloud
367
383
 
368
- By setting the parameter `record` to `true`, you can record your test results into the [Cypress Cloud](https://on.cypress.io/cloud). Read the [Cypress Cloud documentation](https://on.cypress.io/guides/cloud/introduction) to learn how to sign up and create a Cypress Cloud project.
384
+ By setting the parameter `record` to `true`, you can record your test results into [Cypress Cloud](https://on.cypress.io/cloud). Read the [Cypress Cloud setup](https://on.cypress.io/cloud/get-started/setup) documentation to learn how to sign up to Cypress Cloud, to create and set up a [Cloud project](https://on.cypress.io/cloud/account-management/projects) to get the required `projectId` and record key for recording.
385
+
386
+ - The `projectId` can either be stored in the [Cypress Configuration File](https://on.cypress.io/app/references/configuration#Configuration-File) or passed to the action as an environment variable `CYPRESS_PROJECT_ID`. In the example below, it is retrieved from a [GitHub secret](https://docs.github.com/en/actions/security-for-github-actions/security-guides/using-secrets-in-github-actions) variable.
369
387
 
370
- We recommend passing the `GITHUB_TOKEN` secret (created by the GH Action automatically) as an environment variable. This will allow correctly identifying every build and avoid confusion when re-running a build.
388
+ - The record key is passed to the action as an environment variable `CYPRESS_RECORD_KEY`. We recommend you treat this value as sensitive and store it as a [GitHub secret](https://docs.github.com/en/actions/security-for-github-actions/security-guides/using-secrets-in-github-actions) variable, so that access is restricted.
389
+
390
+ - We recommend passing the `GITHUB_TOKEN` secret (created by the GH Action automatically) as an environment variable. This will allow correctly identifying every build and avoid confusion when re-running a build.
371
391
 
372
392
  ```yml
373
393
  name: Cypress tests
@@ -385,40 +405,16 @@ jobs:
385
405
  with:
386
406
  record: true
387
407
  env:
408
+ # pass the Cypress Cloud project ID as an environment variable or store it in the Cypress configuration file
409
+ CYPRESS_PROJECT_ID: ${{ secrets.EXAMPLE_PROJECT_ID }}
410
+ # pass the Cypress Cloud record key as an environment variable
411
+ CYPRESS_RECORD_KEY: ${{ secrets.EXAMPLE_RECORDING_KEY }}
388
412
  # pass GitHub token to allow accurately detecting a build vs a re-run build
389
413
  GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
390
414
  ```
391
415
 
392
416
  [![recording example](https://github.com/cypress-io/github-action/actions/workflows/example-recording.yml/badge.svg)](.github/workflows/example-recording.yml)
393
417
 
394
- ### Project ID and Record Key
395
-
396
- To record the project needs `projectId` and `recordKey`.
397
-
398
- Typically, the `projectId` is stored in the [Cypress Configuration File](https://docs.cypress.io/guides/references/configuration#Configuration-File), while the `recordKey` is set as a [CLI parameter](https://docs.cypress.io/guides/guides/command-line#cypress-run-record-key-lt-record-key-gt). If you want to avoid this, both the `projectId` and `recordKey` can be provided as environment variables using [GitHub secrets](https://docs.github.com/en/actions/security-guides/using-secrets-in-github-actions).
399
-
400
- ```yml
401
- name: Cypress tests
402
- on: push
403
- jobs:
404
- cypress-run:
405
- name: Cypress run
406
- runs-on: ubuntu-24.04
407
- steps:
408
- - name: Checkout
409
- uses: actions/checkout@v4
410
-
411
- - name: Cypress run
412
- uses: cypress-io/github-action@v6
413
- with:
414
- record: true
415
- env:
416
- # pass the Cypress Cloud record key as an environment variable
417
- CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
418
- # pass the project ID from the secrets through environment variable
419
- CYPRESS_PROJECT_ID: ${{ secrets.PROJECT_ID }}
420
- ```
421
-
422
418
  ### Git information
423
419
 
424
420
  Cypress uses the [@cypress/commit-info](https://github.com/cypress-io/commit-info) package to associate Git details (branch, commit message, author) with each run. It typically uses Git commands, expecting a .git folder. In Docker or similar environments where .git is absent, or if you need different data in the Cypress Cloud, Git information can be passed via custom environment variables.
@@ -433,7 +429,6 @@ jobs:
433
429
  steps:
434
430
  - name: Checkout
435
431
  uses: actions/checkout@v4
436
-
437
432
  - name: Cypress run
438
433
  uses: cypress-io/github-action@v6
439
434
  with:
@@ -441,6 +436,7 @@ jobs:
441
436
  env:
442
437
  # Get the short ref name of the branch that triggered the workflow run
443
438
  COMMIT_INFO_BRANCH: ${{ github.ref_name }}
439
+ CYPRESS_RECORD_KEY: ${{ secrets.EXAMPLE_RECORDING_KEY }}
444
440
  ```
445
441
 
446
442
  Please refer to the [Cypress Cloud Git information environment variables](https://on.cypress.io/guides/continuous-integration/introduction#Git-information) section in our documentation for more examples.
@@ -473,7 +469,7 @@ jobs:
473
469
  - run: echo "PR number is $CYPRESS_PULL_REQUEST_ID"
474
470
  - run: echo "PR URL is $CYPRESS_PULL_REQUEST_URL"
475
471
  env:
476
- CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
472
+ CYPRESS_RECORD_KEY: ${{ secrets.EXAMPLE_RECORDING_KEY }}
477
473
  GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
478
474
  ```
479
475
 
@@ -514,6 +510,7 @@ jobs:
514
510
  COMMIT_INFO_MESSAGE: ${{github.event.pull_request.title}}
515
511
  # re-enable PR comment bot
516
512
  COMMIT_INFO_SHA: ${{github.event.pull_request.head.sha}}
513
+ CYPRESS_RECORD_KEY: ${{ secrets.EXAMPLE_RECORDING_KEY }}
517
514
  ```
518
515
 
519
516
  See [issue 124](https://github.com/cypress-io/github-action/issues/124#issuecomment-1076826988) for details.
@@ -531,7 +528,7 @@ jobs:
531
528
  # let's make sure our "app" works on several versions of Node
532
529
  strategy:
533
530
  matrix:
534
- node: [18, 20, 22, 23]
531
+ node: [20, 22, 23]
535
532
  name: E2E on Node v${{ matrix.node }}
536
533
  steps:
537
534
  - name: Setup Node
@@ -549,7 +546,7 @@ jobs:
549
546
  record: true
550
547
  tag: node-${{ matrix.node }}
551
548
  env:
552
- CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
549
+ CYPRESS_RECORD_KEY: ${{ secrets.EXAMPLE_RECORDING_KEY }}
553
550
  GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
554
551
  ```
555
552
 
@@ -557,9 +554,9 @@ The recording will have tags as labels on the run.
557
554
 
558
555
  ![Tags](images/tags.png)
559
556
 
560
- You can pass multiple tags using commas like `tag: node-18,nightly,staging`.
557
+ You can pass multiple tags using commas like `tag: node-22,nightly,staging`.
561
558
 
562
- ### Specify auto cancel after failures
559
+ ### Auto cancel after failures
563
560
 
564
561
  Specify the number of failed tests that will cancel a run when using the [Cypress Cloud Auto Cancellation](https://docs.cypress.io/cloud/features/smart-orchestration/run-cancellation) feature.
565
562
 
@@ -583,7 +580,7 @@ jobs:
583
580
  # Cancel the run after 2 failed tests
584
581
  auto-cancel-after-failures: 2
585
582
  env:
586
- CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
583
+ CYPRESS_RECORD_KEY: ${{ secrets.EXAMPLE_RECORDING_KEY }}
587
584
  GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
588
585
  ```
589
586
 
@@ -724,7 +721,7 @@ jobs:
724
721
  group: 'Actions example'
725
722
  env:
726
723
  # pass the Cypress Cloud record key as an environment variable
727
- CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
724
+ CYPRESS_RECORD_KEY: ${{ secrets.EXAMPLE_RECORDING_KEY }}
728
725
  # Recommended: pass the GitHub token lets this action correctly
729
726
  # determine the unique run id necessary to re-run the checks
730
727
  GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
@@ -739,7 +736,7 @@ If you use the GitHub Actions facility for [Re-running workflows and jobs](https
739
736
  To optimize runs when there are failing tests present, refer to optional [Cypress Cloud Smart Orchestration](https://docs.cypress.io/cloud/features/smart-orchestration/overview/) Premium features:
740
737
 
741
738
  - [Spec Prioritization](https://docs.cypress.io/cloud/features/smart-orchestration/spec-prioritization)
742
- - [Auto Cancellation](https://docs.cypress.io/guides/cloud/smart-orchestration/run-cancellation). See also [Specify auto cancel after failures](#specify-auto-cancel-after-failures) for details of how to set this option in a Cypress GH Action workflow.
739
+ - [Auto Cancellation](https://docs.cypress.io/guides/cloud/smart-orchestration/run-cancellation). See also [Auto cancel after failures](#auto-cancel-after-failures) for details of how to set this option in a Cypress GitHub Action workflow.
743
740
 
744
741
  During staged rollout of a new GitHub-hosted runner version, GitHub may provide a mixture of current and new image versions used by the container matrix. It is recommended to use a [Docker image](#docker-image) in the parallel job run which avoids any Cypress Cloud errors due to browser major version mismatch from the two different image versions. A [Docker image](#docker-image) is not necessary if testing against the default built-in Electron browser because this browser version is fixed by the Cypress version in use and it is unaffected by any GitHub runner image rollout.
745
742
 
@@ -815,7 +812,7 @@ jobs:
815
812
  - name: Cypress run
816
813
  uses: cypress-io/github-action@v6
817
814
  with:
818
- # Linux and MacOS
815
+ # Linux and macOS
819
816
  start: npm start
820
817
  # Takes precedences on Windows
821
818
  start-windows: npm run start:windows:server
@@ -918,14 +915,6 @@ See [example-wait-on.yml](.github/workflows/example-wait-on.yml) workflow file.
918
915
 
919
916
  If this action times out waiting for the server to respond, please see [Debugging](#debugging) section in this README file.
920
917
 
921
- #### `wait-on` with Node.js 18+
922
-
923
- Under Node.js version 18 and later, `wait-on` may fail to recognize that a `localhost` server is running. This affects development web servers which do not listen on both IPv4 and IPv6 network stacks.
924
-
925
- - Check your server documentation to see if it can be started using `0.0.0.0` (all addresses) and use this if available. If this option is not available or does not resolve the issue then carry on to the next steps:
926
- - If the action log shows that `wait-on` is failing to connect to `127.0.0.1`, replace `localhost` by `[::1]` (the IPv6 loopback address)
927
- - If the action log shows that `wait-on` is failing to connect to `::1`, replace `localhost` by `127.0.0.1` (the IPv4 loopback address)
928
-
929
918
  ### Custom install command
930
919
 
931
920
  The action installs dependencies based on a package manager lock file using default commands described in the [Installation](#installation) section below. If you want to overwrite the default install command you can use the `install-command` option:
@@ -942,7 +931,19 @@ If you do not commit a lock file to the repository, you cannot use the action to
942
931
 
943
932
  ### Command prefix
944
933
 
945
- You can prefix the default test command using the `command-prefix` option. This is useful for example when running [Percy](https://docs.percy.io/docs/cypress), which requires the test command to be wrapped with `percy exec --`.
934
+ You can prefix a test command using the `command-prefix` parameter. This is useful, for example, when running [BrowserStack Percy](https://www.browserstack.com/docs/percy/integrate/cypress), which requires the test command to be prefixed with `percy exec --`. When this parameter is used, the action constructs and executes a CLI command using [npx](https://docs.npmjs.com/cli/v11/commands/npx) in the following form:
935
+
936
+ ```shell
937
+ npx <command-prefix> cypress run <cli run options>
938
+ ```
939
+
940
+ where the `<command-prefix>` is the literal string value from the `command-prefix` parameter and `<cli run options>` are put together from action parameters such as the value of the `browser` parameter. The complete constructed command is shown in the logs. For the example below, this is shown as:
941
+
942
+ ```text
943
+ Cypress test command: npx percy exec -- npx cypress run --browser chrome
944
+ ```
945
+
946
+ Since `command-prefix` is run using `npx`, it is compatible with [npm](https://docs.npmjs.com/cli/v11/) and [Yarn Classic](https://classic.yarnpkg.com/). It may also be used with [pnpm](https://pnpm.io/settings#nodelinker) and [Yarn Modern](https://yarnpkg.com/configuration/yarnrc#nodeLinker) when they are configured for `nodeLinker` compatibility with the `node_modules` directory structure of npm. An alternative to using `command-prefix` is to pass a complete [command](#custom-test-command) parameter instead, including the exact command to be passed to the CLI.
946
947
 
947
948
  ```yml
948
949
  name: Visual
@@ -956,14 +957,12 @@ jobs:
956
957
  - name: Cypress run
957
958
  uses: cypress-io/github-action@v6
958
959
  with:
959
- start: npm start
960
- # quote the url to be safe against YML parsing surprises
961
- wait-on: 'http://localhost:8080'
962
- # the entire command will automatically be prefixed with "npm"
963
- # and we need the second "npm" to execute "cypress run ..." command line
964
960
  command-prefix: 'percy exec -- npx'
961
+ browser: chrome
965
962
  ```
966
963
 
964
+ If `command-prefix` is used, then no [job summary](#job-summary-title) is produced, since it runs Cypress with a CLI [cypress run](https://on.cypress.io/app/references/command-line#cypress-run) command instead of using the [Cypress Module API](https://docs.cypress.io/app/references/module-api). The `command` parameter overrides the `command-prefix` parameter, preventing these two parameters from being used together.
965
+
967
966
  ### Custom test command
968
967
 
969
968
  You can overwrite the Cypress run command with your own command.
@@ -1007,7 +1006,7 @@ jobs:
1007
1006
  ci-build-id: '${{ github.sha }}-${{ github.workflow }}-${{ github.event_name }}'
1008
1007
  env:
1009
1008
  # pass the Cypress Cloud record key as an environment variable
1010
- CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
1009
+ CYPRESS_RECORD_KEY: ${{ secrets.EXAMPLE_RECORDING_KEY }}
1011
1010
  GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
1012
1011
  ```
1013
1012
 
@@ -1129,7 +1128,7 @@ jobs:
1129
1128
 
1130
1129
  The package manager `pnpm` is not pre-installed in [GitHub Actions runner images](https://github.com/actions/runner-images) (unlike `npm` and `yarn`) and so it must be installed in a separate workflow step (see below). If the action finds a `pnpm-lock.yaml` file, it uses the [pnpm](https://pnpm.io/cli/install) command `pnpm install --frozen-lockfile` by default to install dependencies.
1131
1130
 
1132
- The example below follows [pnpm recommendations](https://pnpm.io/continuous-integration#github-actions) for installing pnpm and caching the [pnpm store](https://pnpm.io/cli/store). Add [side-effects-cache=false](https://pnpm.io/npmrc#side-effects-cache) to an `.npmrc` file in your project to allow pnpm to install the Cypress binary even if the Cypress npm module has been cached by pnpm.
1131
+ The example below follows [pnpm recommendations](https://pnpm.io/continuous-integration#github-actions) for installing pnpm and caching the [pnpm store](https://pnpm.io/cli/store). Follow the [Cypress pnpm configuration instructions](https://on.cypress.io/install#pnpm-Configuration) and apply them to your project, to enable pnpm to install the Cypress binary.
1133
1132
 
1134
1133
  ```yaml
1135
1134
  name: example-basic-pnpm
@@ -1205,7 +1204,9 @@ jobs:
1205
1204
 
1206
1205
  ### Yarn Modern
1207
1206
 
1208
- To install dependencies using a `yarn.lock` file from [Yarn Modern](https://yarnpkg.com/) (Yarn 2 and later) you need to override the default [Yarn 1 (Classic)](https://classic.yarnpkg.com/) installation command `yarn --frozen-lockfile`. You can do this by using the `install-command` parameter and specifying `yarn install` for example:
1207
+ To install dependencies using a `yarn.lock` file from [Yarn Modern](https://yarnpkg.com/) (Yarn 2 and later) you need to override the default [Yarn 1 (Classic)](https://classic.yarnpkg.com/) installation command `yarn --frozen-lockfile`. You can do this by using the `install-command` parameter and specifying `yarn install` as in the example below.
1208
+
1209
+ The action supports built-in caching of Yarn Classic dependencies only. To cache Yarn Modern dependencies additionally use [actions/setup-node](https://github.com/actions/setup-node) and specify `cache: yarn`.
1209
1210
 
1210
1211
  ```yaml
1211
1212
  name: example-yarn-modern
@@ -1216,6 +1217,13 @@ jobs:
1216
1217
  steps:
1217
1218
  - name: Checkout
1218
1219
  uses: actions/checkout@v4
1220
+ - run: corepack enable # (experimental and optional)
1221
+ - name: Set up Yarn cache
1222
+ uses: actions/setup-node@v4
1223
+ with:
1224
+ node-version: 22
1225
+ cache: yarn
1226
+ cache-dependency-path: examples/yarn-modern/yarn.lock
1219
1227
  - name: Cypress run
1220
1228
  uses: cypress-io/github-action@v6
1221
1229
  with:
@@ -1232,6 +1240,8 @@ This example covers the [`.yarnrc.yml`](https://yarnpkg.com/configuration/yarnrc
1232
1240
 
1233
1241
  When using [Yarn Modern](https://yarnpkg.com/) (Yarn 2 and later) with [Plug'n'Play](https://yarnpkg.com/features/pnp) enabled, you will need to use the `command` parameter to run [`yarn`](https://yarnpkg.com/cli/run) instead of [`npx`](https://docs.npmjs.com/cli/v9/commands/npx).
1234
1242
 
1243
+ See the above [Yarn Modern](#yarn-modern) section for information on caching Yarn Modern dependencies.
1244
+
1235
1245
  ```yaml
1236
1246
  name: example-yarn-modern-pnp
1237
1247
  on: push
@@ -1293,7 +1303,7 @@ jobs:
1293
1303
  # let's make sure our "app" works on several versions of Node
1294
1304
  strategy:
1295
1305
  matrix:
1296
- node: [18, 20, 22, 23]
1306
+ node: [20, 22, 23]
1297
1307
  name: E2E on Node v${{ matrix.node }}
1298
1308
  steps:
1299
1309
  - name: Setup Node
@@ -1311,7 +1321,7 @@ jobs:
1311
1321
  group: Tests on Node v${{ matrix.node }}
1312
1322
  cache-key: node-v${{ matrix.node }}-on-${{ runner.os }}-hash-${{ hashFiles('yarn.lock') }}
1313
1323
  env:
1314
- CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
1324
+ CYPRESS_RECORD_KEY: ${{ secrets.EXAMPLE_RECORDING_KEY }}
1315
1325
  GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
1316
1326
  ```
1317
1327
 
@@ -1327,7 +1337,7 @@ jobs:
1327
1337
  runs-on: ubuntu-24.04
1328
1338
  strategy:
1329
1339
  matrix:
1330
- node: [18, 20, 22, 23]
1340
+ node: [20, 22, 23]
1331
1341
  name: E2E on Node v${{ matrix.node }}
1332
1342
  steps:
1333
1343
  - uses: actions/setup-node@v4
@@ -1414,15 +1424,75 @@ jobs:
1414
1424
 
1415
1425
  ### More examples
1416
1426
 
1417
- <!-- prettier-ignore-start -->
1418
- | Name | Description |
1419
- | ------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------- |
1420
- | [cypress-io/cypress-example-kitchensink](https://github.com/cypress-io/cypress-example-kitchensink) | Runs every API command in Cypress using various CI platforms including GitHub Actions |
1421
- | [cypress-io/cypress-realworld-app](https://github.com/cypress-io/cypress-realworld-app) | A real-world example payment application. Uses GitHub Actions and CircleCI. |
1422
- | [cypress-gh-action-monorepo](https://github.com/bahmutov/cypress-gh-action-monorepo) | Splits install and running tests commands, runs Cypress from sub-folder |
1423
- | [cypress-examples](https://github.com/bahmutov/cypress-examples) | Shows separate install job from parallel test jobs |
1424
- | [cypress-gh-action-split-jobs](https://github.com/bahmutov/cypress-gh-action-split-jobs) | Shows a separate install job with the build step, and another job that runs the tests |
1425
- <!-- prettier-ignore-end -->
1427
+ | Name | Description |
1428
+ | --------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------- |
1429
+ | [cypress-io/cypress-example-kitchensink](https://github.com/cypress-io/cypress-example-kitchensink) | Runs every API command in Cypress using various CI platforms including GitHub Actions |
1430
+ | [cypress-io/cypress-realworld-app](https://github.com/cypress-io/cypress-realworld-app) | A real-world example payment application. Uses GitHub Actions and CircleCI. |
1431
+ | [cypress-gh-action-monorepo](https://github.com/bahmutov/cypress-gh-action-monorepo) | Splits install and running tests commands, runs Cypress from sub-folder |
1432
+ | [cypress-examples](https://github.com/bahmutov/cypress-examples) | Shows separate install job from parallel test jobs |
1433
+ | [cypress-gh-action-split-jobs](https://github.com/bahmutov/cypress-gh-action-split-jobs) | Shows a separate install job with the build step, and another job that runs the tests |
1434
+
1435
+ ## Migration
1436
+
1437
+ ### Migrating from CLI command
1438
+
1439
+ To migrate from Cypress [CLI run command options](https://on.cypress.io/command-line#Options) to Cypress GitHub Action parameters, check the [CLI Run Option / Action Parameter](#cli-run-option--action-parameter) table below. In most cases, the name of the action parameter is the same as the long form of the `cypress run` CLI option.
1440
+
1441
+ Create a [GitHub Actions workflow](https://docs.github.com/en/actions/writing-workflows/quickstart) referring to [Workflow syntax for GitHub Actions](https://docs.github.com/en/actions/writing-workflows/workflow-syntax-for-github-actions). The action `cypress-io/github-action@v6` is invoked with the `uses` keyword. Cypress GitHub Action input parameters are specified under the [with](https://docs.github.com/en/actions/writing-workflows/workflow-syntax-for-github-actions#jobsjob_idstepswith) keyword.
1442
+
1443
+ If you have previously been using a [CLI command](https://on.cypress.io/command-line#cypress-run) to run Cypress locally or in a CI environment, you will be familiar with testing commands like this:
1444
+
1445
+ ```shell
1446
+ npx cypress run --spec cypress/e2e/spec.cy.js --browser chrome
1447
+ ```
1448
+
1449
+ or you may be using a script defined in your project's `package.json` file, such as:
1450
+
1451
+ ```json
1452
+ "cy:e2e:chrome": "cypress run --spec cypress/e2e/spec.cy.js --browser chrome"
1453
+ ```
1454
+
1455
+ Here is the equivalent GitHub Actions example workflow. The action runs Cypress by passing the action parameters (`browser` and `spec`) programmatically to the [Cypress Module API](https://on.cypress.io/module-api) without using any CLI. The complete workflow also checks out the repo and installs dependencies before running Cypress.
1456
+
1457
+ ```yml
1458
+ name: CLI migration example
1459
+ on: push
1460
+ jobs:
1461
+ cypress-run:
1462
+ runs-on: ubuntu-24.04
1463
+ steps:
1464
+ - name: Check out repo
1465
+ uses: actions/checkout@v4
1466
+ - name: Cypress run # install dependencies and run Cypress E2E tests
1467
+ uses: cypress-io/github-action@v6 # replaces CLI cypress run
1468
+ with:
1469
+ browser: chrome # replaces CLI option --browser chrome
1470
+ spec: cypress/e2e/spec.cy.js # replaces CLI option --spec cypress/e2e/spec.cy.js
1471
+ ```
1472
+
1473
+ #### CLI Run Option / Action Parameter
1474
+
1475
+ | CLI Option `cypress run` | Action Parameter | Description |
1476
+ | ------------------------------ | ----------------------------------------------------------- | ---------------------------------------------------------------------------------------------------- |
1477
+ | `--auto-cancel-after-failures` | [`auto-cancel-after-failures`](#auto-cancel-after-failures) | Set the failed test threshold for auto cancellation or disable auto cancellation for Cloud recording |
1478
+ | `--browser`, `-b` | [`browser`](#browser) | Select browser that Cypress runs in. A filesystem path to a browser can also be used. |
1479
+ | `--ci-build-id` | [`ci-build-id`](#custom-build-id) | Specify a unique identifier for a run to enable grouping or parallelization for Cloud recording |
1480
+ | `--component` | [`component`](#component-testing) | Run component tests |
1481
+ | `--config`, `-c` | [`config`](#config) | Specify configuration |
1482
+ | `--config-file`, `-C` | [`config-file`](#config-file) | Specify configuration file |
1483
+ | `--e2e` | [`component: false`](#component-testing) (default) | Run end to end tests |
1484
+ | `--env`, `-e` | [`env`](#env) | Specify environment variables |
1485
+ | `--group` | [`group`](#parallel) | Group recorded tests together under a single run for Cloud recording |
1486
+ | `--headed` | [`headed`](#headed) | Display the browser instead of running headlessly |
1487
+ | `--headless` | [`headed: false`](#headed) (default) | Hide the browser instead of running headed |
1488
+ | `--parallel` | [`parallel`](#parallel) | Run recorded specs in parallel across multiple machines for Cloud recording |
1489
+ | `--project`, `-P` | [`project`](#project) | Path to a specific project |
1490
+ | `--quiet`, `-q` | [`quiet`](#quiet-flag) | Reduce output to `stdout` |
1491
+ | `--record` | [`record`](#record-test-results-on-cypress-cloud) | Record the test run to Cypress Cloud |
1492
+ | `--spec`, `-s` | [`spec`](#specs) | Specify the spec files to run |
1493
+ | `--tag`, `-t` | [`tag`](#tag-recordings) | Identify a run with a tag or tags |
1494
+
1495
+ There is no equivalent action parameter for the CLI options `help`, `key`, `--no-exit`, `--no-runner-ui`, `port`, `reporter`, `reporter-options` or `runner-ui`. See the section [Record test results on Cypress Cloud](#record-test-results-on-cypress-cloud) for information on passing a Cypress Cloud record key to the action.
1426
1496
 
1427
1497
  ## Notes
1428
1498
 
@@ -1438,6 +1508,29 @@ This action installs local dependencies using lock files. Ensure that exactly on
1438
1508
 
1439
1509
  See section [Yarn Modern](#yarn-modern) for information about using Yarn version 2 and later.
1440
1510
 
1511
+ ### Caching
1512
+
1513
+ When the action installs dependencies, it also caches these where possible using GitHub Actions [@actions/cache](https://github.com/actions/toolkit/tree/main/packages/cache).
1514
+
1515
+ #### Cypress binary cache
1516
+
1517
+ The Cypress binary is saved to the `$HOME/.cache/Cypress` directory or to a location defined by the environment variable `CYPRESS_CACHE_FOLDER`. This location is then cached by GitHub Actions and carries the cache label `cypress-<platform-and-architecture>-hash`.
1518
+
1519
+ #### Package Manager cache
1520
+
1521
+ Based on the package manager lock file, the action caches the following package manager cache locations:
1522
+
1523
+ | Lock file | Package Manager | Cached location |
1524
+ | ------------------- | ------------------------------------------------------------------- | ------------------- |
1525
+ | `package-lock.json` | [npm](https://docs.npmjs.com/cli/commands/npm-cache) | `$HOME/.npm` |
1526
+ | `yarn.lock` | [Yarn Classic](https://classic.yarnpkg.com/lang/en/docs/cli/cache/) | `$HOME/.cache/yarn` |
1527
+
1528
+ The cache carries the label `npm-<platform-and-architecture>-hash`.
1529
+ In the cache label, `npm` refers to the npm public registry at https://registry.npmjs.org from which both the above package managers download npm modules by default.
1530
+
1531
+ Note that the Cypress GitHub action does not include any built-in caching for pnpm and Yarn Modern.
1532
+ GitHub Actions however provides [actions/setup-node](https://github.com/actions/setup-node) which includes functionality to optionally cache npm, Yarn and pnpm dependencies. This can be added to any GitHub Actions workflow if needed. Examples are shown above for [pnpm](#pnpm) and [Yarn Modern](#yarn-modern).
1533
+
1441
1534
  ## Debugging
1442
1535
 
1443
1536
  This action uses the [debug](https://github.com/debug-js/debug#readme) module to output additional verbose logs. You can see these debug messages by setting the following environment variable:
@@ -1528,7 +1621,7 @@ This is an example of using the step output `resultsUrl`:
1528
1621
  with:
1529
1622
  record: true
1530
1623
  env:
1531
- CYPRESS_RECORD_KEY: ${{ secrets.RECORDING_KEY }}
1624
+ CYPRESS_RECORD_KEY: ${{ secrets.EXAMPLE_RECORDING_KEY }}
1532
1625
  - name: Print Cypress Cloud URL
1533
1626
  if: always()
1534
1627
  run: |
@@ -1666,7 +1759,7 @@ jobs:
1666
1759
 
1667
1760
  Node.js is required to run this action. The recommended version `v6` supports:
1668
1761
 
1669
- - **Node.js** 18.x, 20.x, 22.x and 23.x
1762
+ - **Node.js** 20.x, 22.x and 23.x
1670
1763
 
1671
1764
  and is generally aligned with [Node.js's release schedule](https://github.com/nodejs/Release).
1672
1765
 
package/action.yml CHANGED
@@ -1,100 +1,115 @@
1
- # https://help.github.com/en/actions/automating-your-workflow-with-github-actions/metadata-syntax-for-github-actions
1
+ # https://docs.github.com/en/actions/sharing-automations/creating-actions/metadata-syntax-for-github-actions
2
2
  name: 'Cypress.io'
3
3
  description: 'GitHub Action for running Cypress end-to-end and component tests'
4
4
  author: 'Cypress-io'
5
5
  inputs:
6
- record:
7
- description: 'Sends test results to Cypress Cloud'
8
- required: false
9
- default: false
6
+ # inputs passed to Cypress Module API https://on.cypress.io/module-api
7
+ # Action options names are the same as Cypress Module API options names, except where noted
8
+ # and Cypress CLI option names https://on.cypress.io/command-line#Options are used instead
10
9
  auto-cancel-after-failures:
11
10
  description: 'Overrides the global Cloud configuration to set the failed test threshold for auto cancellation or to disable auto cancellation when recording to the Cloud (requires Cypress 12.x or later)'
12
11
  required: false
12
+ browser:
13
+ description: 'Name of the browser to use'
14
+ required: false
15
+ ci-build-id:
16
+ description: 'ID associates multiple CI machines to one test run'
17
+ required: false
18
+ component: # translates to Module API testingType e2e (default / false) or component (true)
19
+ description: 'Lets the action know that Cypress is running component tests and not e2e tests'
20
+ required: false
21
+ default: false
13
22
  config:
14
23
  description: 'Set configuration values. Separate multiple values with a comma. The values set here override any values set in your configuration file.'
15
24
  required: false
16
25
  config-file:
17
- description: 'Path to the cypress config file where configuration values are set.'
26
+ description: 'Path to the cypress config file where configuration values are set'
18
27
  required: false
19
28
  default: ''
20
29
  env:
21
30
  description: 'Sets Cypress environment variables'
22
31
  required: false
23
- browser:
24
- description: 'Name of the browser to use'
25
- required: false
26
- command:
27
- description: 'Command that overrides cypress run'
32
+ group:
33
+ description: 'Group setting for recording tests'
28
34
  required: false
29
- start:
30
- description: 'Command for starting local server in the background'
35
+ headed:
36
+ description: 'Whether or not to use headed mode'
31
37
  required: false
32
- start-windows:
33
- description: 'A different start command on Windows'
38
+ # headless: # not used (default and equivalent to headed: false)
39
+ # key: # not used. Pass this option using CYPRESS_RECORD_KEY as a secret environment variable
40
+ # exit: # not used
41
+ parallel:
42
+ description: 'Whether or not to load balance recorded tests using multiple containers'
34
43
  required: false
35
- build:
36
- description: 'Command to run build step before starting tests'
44
+ # port: # not used
45
+ project:
46
+ description: 'Path of project to run'
37
47
  required: false
38
- install:
39
- description: 'Whether or not to run install'
48
+ quiet:
49
+ description: 'Whether or not to silence any Cypress specific output from stdout'
40
50
  required: false
41
- install-command:
42
- description: 'Custom install command to use'
51
+ record:
52
+ description: 'Sends test results to Cypress Cloud'
43
53
  required: false
44
- runTests:
45
- description: 'Whether or not to run tests'
54
+ default: false
55
+ # reporter: # not used
56
+ # reporterOptions: # not used
57
+ # runnerUi: # not used
58
+ # slowTestThreshold # not used
59
+ spec:
60
+ description: 'Provide specific specs to run'
46
61
  required: false
47
- wait-on:
48
- description: 'Local server URL to wait for'
62
+ tag:
63
+ description: 'Tag setting for tests'
49
64
  required: false
50
- wait-on-timeout:
51
- description: 'Amount of time to wait for wait-on url to be available'
65
+ #
66
+ # inputs used internally by action, not passed to Cypress Module API
67
+ #
68
+ build:
69
+ description: 'Command to run build step before starting tests'
52
70
  required: false
53
- parallel:
54
- description: 'Whether or not to load balance tests using multiple containers'
71
+ cache-key:
72
+ description: 'Custom cache key'
55
73
  required: false
56
- group:
57
- description: 'Group setting for tests'
74
+ command: # Using this option overrides passing inputs to the Cypress Module API
75
+ description: 'Command that overrides cypress run'
58
76
  required: false
59
- tag:
60
- description: 'Tag setting for tests'
77
+ command-prefix:
78
+ description: 'You can prefix the default test command using the command-prefix option.'
61
79
  required: false
62
- working-directory:
63
- description: 'Working directory containing Cypress folder'
80
+ install:
81
+ description: 'Whether or not to run install'
64
82
  required: false
65
- headed:
66
- description: 'Whether or not to use headed mode'
83
+ install-command:
84
+ description: 'Custom install command to use'
67
85
  required: false
68
86
  publish-summary:
69
87
  description: 'Whether or not to publish a job summary'
70
88
  required: false
71
89
  default: true
72
- summary-title:
73
- description: 'Title for job summary'
74
- required: false
75
- spec:
76
- description: 'Provide a specific specs to run'
90
+ runTests:
91
+ description: 'Whether or not to run tests'
77
92
  required: false
78
- project:
79
- description: 'Path of project to run'
93
+ start:
94
+ description: 'Command for starting local server in the background'
80
95
  required: false
81
- command-prefix:
82
- description: 'You can prefix the default test command using the command-prefix option.'
96
+ start-windows:
97
+ description: 'A different start command on Windows'
83
98
  required: false
84
- ci-build-id:
85
- description: 'ID associates multiple CI machines to one test run'
99
+ summary-title:
100
+ description: 'Title for job summary'
86
101
  required: false
87
- cache-key:
88
- description: 'Custom cache key'
102
+ wait-on:
103
+ description: 'Local server URL to wait for'
89
104
  required: false
90
- quiet:
91
- description: 'Whether or not to silence any Cypress specific output from stdout'
105
+ wait-on-timeout:
106
+ description: 'Amount of time to wait for wait-on URL to be available'
92
107
  required: false
93
- component:
94
- description: 'Lets the action know that Cypress is running component tests and not e2e tests'
108
+ working-directory:
109
+ description: 'Working directory containing Cypress folder'
95
110
  required: false
96
- default: false
97
111
  outputs:
112
+ # derived from Cypress Module API https://on.cypress.io/module-api#Results runUrl
98
113
  dashboardUrl:
99
114
  description: 'Cypress Cloud URL if the run was recorded (deprecated)'
100
115
  resultsUrl:
package/dist/index.js CHANGED
@@ -93982,10 +93982,58 @@ const runTestsUsingCommandLine = async () => {
93982
93982
 
93983
93983
  return exec.exec(quote(npxPath), cmd, opts)
93984
93984
  }
93985
+ /**
93986
+ * Validate input parameters for consistency when command parameter is used
93987
+ * Output GitHub actions annotation warning if ignored parameters are used
93988
+ */
93989
+ const commandIgnoredBooleanInputs = [
93990
+ // parameter name, default value
93991
+ ['component', false],
93992
+ ['headed', false],
93993
+ ['parallel', false],
93994
+ ['quiet', false],
93995
+ ['record', false],
93996
+ ['publish-summary', true]
93997
+ ]
93998
+ const commandIgnoredStringInputs = [
93999
+ 'auto-cancel-after-failures',
94000
+ 'browser',
94001
+ 'ci-build-id',
94002
+ 'config',
94003
+ 'config-file',
94004
+ 'env',
94005
+ 'group',
94006
+ 'project',
94007
+ 'spec',
94008
+ 'tag',
94009
+ 'command-prefix',
94010
+ 'summary-title'
94011
+ ]
94012
+ let ignoredInputParameters = []
94013
+ const validateCustomCommand = () => {
94014
+ commandIgnoredBooleanInputs.forEach((input) => {
94015
+ const inputParameter = input[0]
94016
+ const inputDefault = input[1]
94017
+ if (getInputBool(inputParameter) !== inputDefault) {
94018
+ ignoredInputParameters.push(inputParameter)
94019
+ }
94020
+ })
94021
+ commandIgnoredStringInputs.forEach((input) => {
94022
+ if (core.getInput(input)) {
94023
+ ignoredInputParameters.push(input)
94024
+ }
94025
+ })
94026
+ if (ignoredInputParameters.length > 0) {
94027
+ core.warning(
94028
+ `command parameter is used and the following other parameters are ignored: ${ignoredInputParameters.sort().join(', ')}.`
94029
+ )
94030
+ }
94031
+ }
93985
94032
 
93986
94033
  /**
93987
94034
  * Run Cypress tests by collecting input parameters
93988
94035
  * and using Cypress module API to run tests.
94036
+ * If command parameter is specified, then run using @actions/exec instead.
93989
94037
  * @see https://on.cypress.io/module-api
93990
94038
  */
93991
94039
  const runTests = async () => {
@@ -94014,6 +94062,7 @@ const runTests = async () => {
94014
94062
 
94015
94063
  if (customCommand) {
94016
94064
  console.log('Using custom test command: %s', customCommand)
94065
+ validateCustomCommand() // catch ignored parameters and output warning
94017
94066
  return execCommand(customCommand, true, 'run tests')
94018
94067
  }
94019
94068
 
@@ -94030,6 +94079,7 @@ const runTests = async () => {
94030
94079
  debug(`requiring cypress dependency, cwd is ${process.cwd()}`)
94031
94080
  debug(`working directory ${workingDirectory}`)
94032
94081
  debug(`resolved cypress ${cypressModulePath}`)
94082
+ debug(`GitHub JavaScript Action Node.js version ${process.version}`)
94033
94083
 
94034
94084
  if (core.getInput('group')) {
94035
94085
  cypressOptions.group = core.getInput('group')
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cypress/github-action",
3
- "version": "6.7.16",
3
+ "version": "6.9.0",
4
4
  "description": "GitHub Action for running Cypress end-to-end and component tests",
5
5
  "private": false,
6
6
  "main": "dist/index.js",
@@ -15,7 +15,10 @@
15
15
  "format": "prettier --write index.js src/ping.js action.yml",
16
16
  "format:markdown": "prettier --write \"**/*.md\"",
17
17
  "format:markdown:check": "prettier --check \"**/*.md\"",
18
+ "format:all": "prettier --write .",
19
+ "format:all:check": "prettier --check .",
18
20
  "lint": "eslint",
21
+ "lint:fix": "eslint --fix",
19
22
  "check:markdown-links": "find *.md docs/*.md -print0 | xargs -0 -n1 markdown-link-check",
20
23
  "update:cypress": "./scripts/update-cypress-latest.sh",
21
24
  "prepare": "husky"
@@ -54,10 +57,10 @@
54
57
  "@types/node": "22.13.10",
55
58
  "@vercel/ncc": "0.38.1",
56
59
  "eslint": "9.21.0",
57
- "eslint-plugin-cypress": "4.2.0",
60
+ "eslint-plugin-cypress": "4.2.1",
58
61
  "globals": "16.0.0",
59
62
  "husky": "9.1.7",
60
- "markdown-link-check": "3.13.6",
63
+ "markdown-link-check": "3.13.7",
61
64
  "prettier": "3.5.3"
62
65
  },
63
66
  "publishConfig": {