@cypress/github-action 6.7.15 → 6.8.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 +156 -73
- package/action.yml +70 -55
- package/dist/index.js +5 -2
- package/package.json +7 -4
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
|
-
> [
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
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](#
|
|
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
|
|
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
|
-
|
|
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
|
[](.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.
|
|
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: [
|
|
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.
|
|
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
|

|
|
559
556
|
|
|
560
|
-
You can pass multiple tags using commas like `tag: node-
|
|
557
|
+
You can pass multiple tags using commas like `tag: node-22,nightly,staging`.
|
|
561
558
|
|
|
562
|
-
###
|
|
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.
|
|
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.
|
|
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 [
|
|
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
|
|
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:
|
|
@@ -1007,7 +996,7 @@ jobs:
|
|
|
1007
996
|
ci-build-id: '${{ github.sha }}-${{ github.workflow }}-${{ github.event_name }}'
|
|
1008
997
|
env:
|
|
1009
998
|
# pass the Cypress Cloud record key as an environment variable
|
|
1010
|
-
CYPRESS_RECORD_KEY: ${{ secrets.
|
|
999
|
+
CYPRESS_RECORD_KEY: ${{ secrets.EXAMPLE_RECORDING_KEY }}
|
|
1011
1000
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
1012
1001
|
```
|
|
1013
1002
|
|
|
@@ -1129,7 +1118,7 @@ jobs:
|
|
|
1129
1118
|
|
|
1130
1119
|
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
1120
|
|
|
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).
|
|
1121
|
+
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
1122
|
|
|
1134
1123
|
```yaml
|
|
1135
1124
|
name: example-basic-pnpm
|
|
@@ -1205,7 +1194,9 @@ jobs:
|
|
|
1205
1194
|
|
|
1206
1195
|
### Yarn Modern
|
|
1207
1196
|
|
|
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`
|
|
1197
|
+
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.
|
|
1198
|
+
|
|
1199
|
+
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
1200
|
|
|
1210
1201
|
```yaml
|
|
1211
1202
|
name: example-yarn-modern
|
|
@@ -1216,6 +1207,13 @@ jobs:
|
|
|
1216
1207
|
steps:
|
|
1217
1208
|
- name: Checkout
|
|
1218
1209
|
uses: actions/checkout@v4
|
|
1210
|
+
- run: corepack enable # (experimental and optional)
|
|
1211
|
+
- name: Set up Yarn cache
|
|
1212
|
+
uses: actions/setup-node@v4
|
|
1213
|
+
with:
|
|
1214
|
+
node-version: 22
|
|
1215
|
+
cache: yarn
|
|
1216
|
+
cache-dependency-path: examples/yarn-modern/yarn.lock
|
|
1219
1217
|
- name: Cypress run
|
|
1220
1218
|
uses: cypress-io/github-action@v6
|
|
1221
1219
|
with:
|
|
@@ -1232,6 +1230,8 @@ This example covers the [`.yarnrc.yml`](https://yarnpkg.com/configuration/yarnrc
|
|
|
1232
1230
|
|
|
1233
1231
|
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
1232
|
|
|
1233
|
+
See the above [Yarn Modern](#yarn-modern) section for information on caching Yarn Modern dependencies.
|
|
1234
|
+
|
|
1235
1235
|
```yaml
|
|
1236
1236
|
name: example-yarn-modern-pnp
|
|
1237
1237
|
on: push
|
|
@@ -1293,7 +1293,7 @@ jobs:
|
|
|
1293
1293
|
# let's make sure our "app" works on several versions of Node
|
|
1294
1294
|
strategy:
|
|
1295
1295
|
matrix:
|
|
1296
|
-
node: [
|
|
1296
|
+
node: [20, 22, 23]
|
|
1297
1297
|
name: E2E on Node v${{ matrix.node }}
|
|
1298
1298
|
steps:
|
|
1299
1299
|
- name: Setup Node
|
|
@@ -1311,7 +1311,7 @@ jobs:
|
|
|
1311
1311
|
group: Tests on Node v${{ matrix.node }}
|
|
1312
1312
|
cache-key: node-v${{ matrix.node }}-on-${{ runner.os }}-hash-${{ hashFiles('yarn.lock') }}
|
|
1313
1313
|
env:
|
|
1314
|
-
CYPRESS_RECORD_KEY: ${{ secrets.
|
|
1314
|
+
CYPRESS_RECORD_KEY: ${{ secrets.EXAMPLE_RECORDING_KEY }}
|
|
1315
1315
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
1316
1316
|
```
|
|
1317
1317
|
|
|
@@ -1327,7 +1327,7 @@ jobs:
|
|
|
1327
1327
|
runs-on: ubuntu-24.04
|
|
1328
1328
|
strategy:
|
|
1329
1329
|
matrix:
|
|
1330
|
-
node: [
|
|
1330
|
+
node: [20, 22, 23]
|
|
1331
1331
|
name: E2E on Node v${{ matrix.node }}
|
|
1332
1332
|
steps:
|
|
1333
1333
|
- uses: actions/setup-node@v4
|
|
@@ -1414,15 +1414,75 @@ jobs:
|
|
|
1414
1414
|
|
|
1415
1415
|
### More examples
|
|
1416
1416
|
|
|
1417
|
-
|
|
1418
|
-
|
|
|
1419
|
-
|
|
|
1420
|
-
| [cypress-io/cypress-
|
|
1421
|
-
| [cypress-
|
|
1422
|
-
| [cypress-
|
|
1423
|
-
| [cypress-
|
|
1424
|
-
|
|
1425
|
-
|
|
1417
|
+
| Name | Description |
|
|
1418
|
+
| --------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------- |
|
|
1419
|
+
| [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 |
|
|
1420
|
+
| [cypress-io/cypress-realworld-app](https://github.com/cypress-io/cypress-realworld-app) | A real-world example payment application. Uses GitHub Actions and CircleCI. |
|
|
1421
|
+
| [cypress-gh-action-monorepo](https://github.com/bahmutov/cypress-gh-action-monorepo) | Splits install and running tests commands, runs Cypress from sub-folder |
|
|
1422
|
+
| [cypress-examples](https://github.com/bahmutov/cypress-examples) | Shows separate install job from parallel test jobs |
|
|
1423
|
+
| [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 |
|
|
1424
|
+
|
|
1425
|
+
## Migration
|
|
1426
|
+
|
|
1427
|
+
### Migrating from CLI command
|
|
1428
|
+
|
|
1429
|
+
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.
|
|
1430
|
+
|
|
1431
|
+
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.
|
|
1432
|
+
|
|
1433
|
+
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:
|
|
1434
|
+
|
|
1435
|
+
```shell
|
|
1436
|
+
npx cypress run --spec cypress/e2e/spec.cy.js --browser chrome
|
|
1437
|
+
```
|
|
1438
|
+
|
|
1439
|
+
or you may be using a script defined in your project's `package.json` file, such as:
|
|
1440
|
+
|
|
1441
|
+
```json
|
|
1442
|
+
"cy:e2e:chrome": "cypress run --spec cypress/e2e/spec.cy.js --browser chrome"
|
|
1443
|
+
```
|
|
1444
|
+
|
|
1445
|
+
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.
|
|
1446
|
+
|
|
1447
|
+
```yml
|
|
1448
|
+
name: CLI migration example
|
|
1449
|
+
on: push
|
|
1450
|
+
jobs:
|
|
1451
|
+
cypress-run:
|
|
1452
|
+
runs-on: ubuntu-24.04
|
|
1453
|
+
steps:
|
|
1454
|
+
- name: Check out repo
|
|
1455
|
+
uses: actions/checkout@v4
|
|
1456
|
+
- name: Cypress run # install dependencies and run Cypress E2E tests
|
|
1457
|
+
uses: cypress-io/github-action@v6 # replaces CLI cypress run
|
|
1458
|
+
with:
|
|
1459
|
+
browser: chrome # replaces CLI option --browser chrome
|
|
1460
|
+
spec: cypress/e2e/spec.cy.js # replaces CLI option --spec cypress/e2e/spec.cy.js
|
|
1461
|
+
```
|
|
1462
|
+
|
|
1463
|
+
#### CLI Run Option / Action Parameter
|
|
1464
|
+
|
|
1465
|
+
| CLI Option `cypress run` | Action Parameter | Description |
|
|
1466
|
+
| ------------------------------ | ----------------------------------------------------------- | ---------------------------------------------------------------------------------------------------- |
|
|
1467
|
+
| `--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 |
|
|
1468
|
+
| `--browser`, `-b` | [`browser`](#browser) | Select browser that Cypress runs in. A filesystem path to a browser can also be used. |
|
|
1469
|
+
| `--ci-build-id` | [`ci-build-id`](#custom-build-id) | Specify a unique identifier for a run to enable grouping or parallelization for Cloud recording |
|
|
1470
|
+
| `--component` | [`component`](#component-testing) | Run component tests |
|
|
1471
|
+
| `--config`, `-c` | [`config`](#config) | Specify configuration |
|
|
1472
|
+
| `--config-file`, `-C` | [`config-file`](#config-file) | Specify configuration file |
|
|
1473
|
+
| `--e2e` | [`component: false`](#component-testing) (default) | Run end to end tests |
|
|
1474
|
+
| `--env`, `-e` | [`env`](#env) | Specify environment variables |
|
|
1475
|
+
| `--group` | [`group`](#parallel) | Group recorded tests together under a single run for Cloud recording |
|
|
1476
|
+
| `--headed` | [`headed`](#headed) | Display the browser instead of running headlessly |
|
|
1477
|
+
| `--headless` | [`headed: false`](#headed) (default) | Hide the browser instead of running headed |
|
|
1478
|
+
| `--parallel` | [`parallel`](#parallel) | Run recorded specs in parallel across multiple machines for Cloud recording |
|
|
1479
|
+
| `--project`, `-P` | [`project`](#project) | Path to a specific project |
|
|
1480
|
+
| `--quiet`, `-q` | [`quiet`](#quiet-flag) | Reduce output to `stdout` |
|
|
1481
|
+
| `--record` | [`record`](#record-test-results-on-cypress-cloud) | Record the test run to Cypress Cloud |
|
|
1482
|
+
| `--spec`, `-s` | [`spec`](#specs) | Specify the spec files to run |
|
|
1483
|
+
| `--tag`, `-t` | [`tag`](#tag-recordings) | Identify a run with a tag or tags |
|
|
1484
|
+
|
|
1485
|
+
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
1486
|
|
|
1427
1487
|
## Notes
|
|
1428
1488
|
|
|
@@ -1438,6 +1498,29 @@ This action installs local dependencies using lock files. Ensure that exactly on
|
|
|
1438
1498
|
|
|
1439
1499
|
See section [Yarn Modern](#yarn-modern) for information about using Yarn version 2 and later.
|
|
1440
1500
|
|
|
1501
|
+
### Caching
|
|
1502
|
+
|
|
1503
|
+
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).
|
|
1504
|
+
|
|
1505
|
+
#### Cypress binary cache
|
|
1506
|
+
|
|
1507
|
+
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`.
|
|
1508
|
+
|
|
1509
|
+
#### Package Manager cache
|
|
1510
|
+
|
|
1511
|
+
Based on the package manager lock file, the action caches the following package manager cache locations:
|
|
1512
|
+
|
|
1513
|
+
| Lock file | Package Manager | Cached location |
|
|
1514
|
+
| ------------------- | ------------------------------------------------------------------- | ------------------- |
|
|
1515
|
+
| `package-lock.json` | [npm](https://docs.npmjs.com/cli/commands/npm-cache) | `$HOME/.npm` |
|
|
1516
|
+
| `yarn.lock` | [Yarn Classic](https://classic.yarnpkg.com/lang/en/docs/cli/cache/) | `$HOME/.cache/yarn` |
|
|
1517
|
+
|
|
1518
|
+
The cache carries the label `npm-<platform-and-architecture>-hash`.
|
|
1519
|
+
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.
|
|
1520
|
+
|
|
1521
|
+
Note that the Cypress GitHub action does not include any built-in caching for pnpm and Yarn Modern.
|
|
1522
|
+
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).
|
|
1523
|
+
|
|
1441
1524
|
## Debugging
|
|
1442
1525
|
|
|
1443
1526
|
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 +1611,7 @@ This is an example of using the step output `resultsUrl`:
|
|
|
1528
1611
|
with:
|
|
1529
1612
|
record: true
|
|
1530
1613
|
env:
|
|
1531
|
-
CYPRESS_RECORD_KEY: ${{ secrets.
|
|
1614
|
+
CYPRESS_RECORD_KEY: ${{ secrets.EXAMPLE_RECORDING_KEY }}
|
|
1532
1615
|
- name: Print Cypress Cloud URL
|
|
1533
1616
|
if: always()
|
|
1534
1617
|
run: |
|
|
@@ -1666,7 +1749,7 @@ jobs:
|
|
|
1666
1749
|
|
|
1667
1750
|
Node.js is required to run this action. The recommended version `v6` supports:
|
|
1668
1751
|
|
|
1669
|
-
- **Node.js**
|
|
1752
|
+
- **Node.js** 20.x, 22.x and 23.x
|
|
1670
1753
|
|
|
1671
1754
|
and is generally aligned with [Node.js's release schedule](https://github.com/nodejs/Release).
|
|
1672
1755
|
|
package/action.yml
CHANGED
|
@@ -1,100 +1,115 @@
|
|
|
1
|
-
# https://
|
|
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
|
-
|
|
7
|
-
|
|
8
|
-
|
|
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
|
-
|
|
24
|
-
description: '
|
|
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
|
-
|
|
30
|
-
description: '
|
|
35
|
+
headed:
|
|
36
|
+
description: 'Whether or not to use headed mode'
|
|
31
37
|
required: false
|
|
32
|
-
|
|
33
|
-
|
|
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
|
-
|
|
36
|
-
|
|
44
|
+
# port: # not used
|
|
45
|
+
project:
|
|
46
|
+
description: 'Path of project to run'
|
|
37
47
|
required: false
|
|
38
|
-
|
|
39
|
-
description: 'Whether or not to
|
|
48
|
+
quiet:
|
|
49
|
+
description: 'Whether or not to silence any Cypress specific output from stdout'
|
|
40
50
|
required: false
|
|
41
|
-
|
|
42
|
-
description: '
|
|
51
|
+
record:
|
|
52
|
+
description: 'Sends test results to Cypress Cloud'
|
|
43
53
|
required: false
|
|
44
|
-
|
|
45
|
-
|
|
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
|
-
|
|
48
|
-
description: '
|
|
62
|
+
tag:
|
|
63
|
+
description: 'Tag setting for tests'
|
|
49
64
|
required: false
|
|
50
|
-
|
|
51
|
-
|
|
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
|
-
|
|
54
|
-
description: '
|
|
71
|
+
cache-key:
|
|
72
|
+
description: 'Custom cache key'
|
|
55
73
|
required: false
|
|
56
|
-
|
|
57
|
-
description: '
|
|
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
|
-
|
|
60
|
-
description: '
|
|
77
|
+
command-prefix:
|
|
78
|
+
description: 'You can prefix the default test command using the command-prefix option.'
|
|
61
79
|
required: false
|
|
62
|
-
|
|
63
|
-
description: '
|
|
80
|
+
install:
|
|
81
|
+
description: 'Whether or not to run install'
|
|
64
82
|
required: false
|
|
65
|
-
|
|
66
|
-
description: '
|
|
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
|
-
|
|
73
|
-
description: '
|
|
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
|
-
|
|
79
|
-
description: '
|
|
93
|
+
start:
|
|
94
|
+
description: 'Command for starting local server in the background'
|
|
80
95
|
required: false
|
|
81
|
-
|
|
82
|
-
description: '
|
|
96
|
+
start-windows:
|
|
97
|
+
description: 'A different start command on Windows'
|
|
83
98
|
required: false
|
|
84
|
-
|
|
85
|
-
description: '
|
|
99
|
+
summary-title:
|
|
100
|
+
description: 'Title for job summary'
|
|
86
101
|
required: false
|
|
87
|
-
|
|
88
|
-
description: '
|
|
102
|
+
wait-on:
|
|
103
|
+
description: 'Local server URL to wait for'
|
|
89
104
|
required: false
|
|
90
|
-
|
|
91
|
-
description: '
|
|
105
|
+
wait-on-timeout:
|
|
106
|
+
description: 'Amount of time to wait for wait-on URL to be available'
|
|
92
107
|
required: false
|
|
93
|
-
|
|
94
|
-
description: '
|
|
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
|
@@ -93785,7 +93785,8 @@ const getCiBuildId = async () => {
|
|
|
93785
93785
|
GITHUB_SHA,
|
|
93786
93786
|
GITHUB_TOKEN,
|
|
93787
93787
|
GITHUB_RUN_ID,
|
|
93788
|
-
GITHUB_REPOSITORY
|
|
93788
|
+
GITHUB_REPOSITORY,
|
|
93789
|
+
GITHUB_API_URL
|
|
93789
93790
|
} = process.env
|
|
93790
93791
|
|
|
93791
93792
|
const [owner, repo] = GITHUB_REPOSITORY.split('/')
|
|
@@ -93798,7 +93799,8 @@ const getCiBuildId = async () => {
|
|
|
93798
93799
|
)
|
|
93799
93800
|
|
|
93800
93801
|
const client = new Octokit({
|
|
93801
|
-
auth: GITHUB_TOKEN
|
|
93802
|
+
auth: GITHUB_TOKEN,
|
|
93803
|
+
baseUrl: GITHUB_API_URL
|
|
93802
93804
|
})
|
|
93803
93805
|
|
|
93804
93806
|
const resp = await client.request(
|
|
@@ -94028,6 +94030,7 @@ const runTests = async () => {
|
|
|
94028
94030
|
debug(`requiring cypress dependency, cwd is ${process.cwd()}`)
|
|
94029
94031
|
debug(`working directory ${workingDirectory}`)
|
|
94030
94032
|
debug(`resolved cypress ${cypressModulePath}`)
|
|
94033
|
+
debug(`GitHub JavaScript Action Node.js version ${process.version}`)
|
|
94031
94034
|
|
|
94032
94035
|
if (core.getInput('group')) {
|
|
94033
94036
|
cypressOptions.group = core.getInput('group')
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cypress/github-action",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.8.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"
|
|
@@ -51,13 +54,13 @@
|
|
|
51
54
|
"devDependencies": {
|
|
52
55
|
"@eslint/js": "9.21.0",
|
|
53
56
|
"@stylistic/eslint-plugin": "4.2.0",
|
|
54
|
-
"@types/node": "22.13.
|
|
57
|
+
"@types/node": "22.13.10",
|
|
55
58
|
"@vercel/ncc": "0.38.1",
|
|
56
59
|
"eslint": "9.21.0",
|
|
57
|
-
"eslint-plugin-cypress": "4.1
|
|
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.
|
|
63
|
+
"markdown-link-check": "3.13.7",
|
|
61
64
|
"prettier": "3.5.3"
|
|
62
65
|
},
|
|
63
66
|
"publishConfig": {
|