@cypress/github-action 4.2.0 → 5.0.1
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 +118 -118
- package/dist/index.js +754 -13
- package/package.json +7 -7
package/README.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# cypress-io/github-action [![renovate-app badge][renovate-badge]][renovate-app] [](https://github.com/cypress-io/github-action/actions)
|
|
2
2
|
|
|
3
|
-
> [GitHub Action](https://
|
|
3
|
+
> [GitHub Action](https://docs.github.com/en/actions) for running [Cypress](https://www.cypress.io) end-to-end tests. Includes NPM installation, custom caching and lots of configuration options.
|
|
4
4
|
|
|
5
5
|
## Examples
|
|
6
6
|
|
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
- Specify [environment variables](#env)
|
|
15
15
|
- Run only some [spec files](#specs)
|
|
16
16
|
- Test [project in subfolder](#project)
|
|
17
|
-
- [Record results](#record-test-results-on-cypress-
|
|
17
|
+
- [Record results](#record-test-results-on-cypress-cloud) on Cypress Cloud
|
|
18
18
|
- Tag [recordings](#tag-recordings)
|
|
19
19
|
- [Quiet output](#quiet-flag)
|
|
20
20
|
- Store [test artifacts](#artifacts) on GitHub
|
|
@@ -29,7 +29,7 @@
|
|
|
29
29
|
- use [custom install command](#custom-install-command)
|
|
30
30
|
- use [command prefix](#command-prefix)
|
|
31
31
|
- use [own custom test command](#custom-test-command)
|
|
32
|
-
- pass [custom build id](#custom-build-id) when recording to
|
|
32
|
+
- pass [custom build id](#custom-build-id) when recording to Cypress Cloud
|
|
33
33
|
- generate a [robust custom build id](#robust-custom-build-id) to allow re-running the workflow
|
|
34
34
|
- use different [working-directory](#working-directory)
|
|
35
35
|
- use [custom cache key](#custom-cache-key)
|
|
@@ -52,11 +52,11 @@ jobs:
|
|
|
52
52
|
runs-on: ubuntu-20.04
|
|
53
53
|
steps:
|
|
54
54
|
- name: Checkout
|
|
55
|
-
uses: actions/checkout@
|
|
55
|
+
uses: actions/checkout@v3
|
|
56
56
|
# Install NPM dependencies, cache them correctly
|
|
57
57
|
# and run all Cypress tests
|
|
58
58
|
- name: Cypress run
|
|
59
|
-
uses: cypress-io/github-action@
|
|
59
|
+
uses: cypress-io/github-action@v5
|
|
60
60
|
```
|
|
61
61
|
|
|
62
62
|
[](.github/workflows/example-basic.yml)
|
|
@@ -69,18 +69,18 @@ The workflow file [.github/workflows/example-basic.yml](.github/workflows/exampl
|
|
|
69
69
|
|
|
70
70
|
**Best practice:**
|
|
71
71
|
|
|
72
|
-
Our examples specify the tag of the action to use listing only the major version `@
|
|
72
|
+
Our examples specify the tag of the action to use listing only the major version `@v5`
|
|
73
73
|
|
|
74
74
|
```yml
|
|
75
75
|
- name: Cypress run
|
|
76
|
-
uses: cypress-io/github-action@
|
|
76
|
+
uses: cypress-io/github-action@v5
|
|
77
77
|
```
|
|
78
78
|
|
|
79
|
-
When using `cypress-io/github-action@
|
|
79
|
+
When using `cypress-io/github-action@v5` from your workflow file, you automatically will be using the latest [tagged version from this repository](https://github.com/cypress-io/github-action/tags). If you want to precisely control the version of this module, use the full tag version, for example:
|
|
80
80
|
|
|
81
81
|
```yml
|
|
82
82
|
- name: Cypress run
|
|
83
|
-
uses: cypress-io/github-action@
|
|
83
|
+
uses: cypress-io/github-action@v5.x.x
|
|
84
84
|
```
|
|
85
85
|
|
|
86
86
|
By using the full version tag, you will avoid accidentally using a newer version of the action.
|
|
@@ -98,8 +98,8 @@ jobs:
|
|
|
98
98
|
# let's make sure our tests pass on Chrome browser
|
|
99
99
|
name: E2E on Chrome
|
|
100
100
|
steps:
|
|
101
|
-
- uses: actions/checkout@
|
|
102
|
-
- uses: cypress-io/github-action@
|
|
101
|
+
- uses: actions/checkout@v3
|
|
102
|
+
- uses: cypress-io/github-action@v5
|
|
103
103
|
with:
|
|
104
104
|
browser: chrome
|
|
105
105
|
```
|
|
@@ -120,8 +120,8 @@ jobs:
|
|
|
120
120
|
image: cypress/browsers:node12.16.1-chrome80-ff73
|
|
121
121
|
options: --user 1001
|
|
122
122
|
steps:
|
|
123
|
-
- uses: actions/checkout@
|
|
124
|
-
- uses: cypress-io/github-action@
|
|
123
|
+
- uses: actions/checkout@v3
|
|
124
|
+
- uses: cypress-io/github-action@v5
|
|
125
125
|
with:
|
|
126
126
|
browser: firefox
|
|
127
127
|
```
|
|
@@ -139,8 +139,8 @@ jobs:
|
|
|
139
139
|
tests:
|
|
140
140
|
runs-on: windows-latest
|
|
141
141
|
steps:
|
|
142
|
-
- uses: actions/checkout@
|
|
143
|
-
- uses: cypress-io/github-action@
|
|
142
|
+
- uses: actions/checkout@v3
|
|
143
|
+
- uses: cypress-io/github-action@v5
|
|
144
144
|
with:
|
|
145
145
|
browser: edge
|
|
146
146
|
```
|
|
@@ -160,8 +160,8 @@ jobs:
|
|
|
160
160
|
cypress-run:
|
|
161
161
|
runs-on: ubuntu-20.04
|
|
162
162
|
steps:
|
|
163
|
-
- uses: actions/checkout@
|
|
164
|
-
- uses: cypress-io/github-action@
|
|
163
|
+
- uses: actions/checkout@v3
|
|
164
|
+
- uses: cypress-io/github-action@v5
|
|
165
165
|
with:
|
|
166
166
|
browser: chrome
|
|
167
167
|
headed: true
|
|
@@ -181,8 +181,8 @@ jobs:
|
|
|
181
181
|
# and Firefox v70 pre-installed
|
|
182
182
|
container: cypress/browsers:node12.13.0-chrome78-ff70
|
|
183
183
|
steps:
|
|
184
|
-
- uses: actions/checkout@
|
|
185
|
-
- uses: cypress-io/github-action@
|
|
184
|
+
- uses: actions/checkout@v3
|
|
185
|
+
- uses: cypress-io/github-action@v5
|
|
186
186
|
with:
|
|
187
187
|
browser: chrome
|
|
188
188
|
```
|
|
@@ -199,10 +199,10 @@ jobs:
|
|
|
199
199
|
runs-on: ubuntu-20.04
|
|
200
200
|
steps:
|
|
201
201
|
- name: Checkout
|
|
202
|
-
uses: actions/checkout@
|
|
202
|
+
uses: actions/checkout@v3
|
|
203
203
|
|
|
204
204
|
- name: Cypress run with env
|
|
205
|
-
uses: cypress-io/github-action@
|
|
205
|
+
uses: cypress-io/github-action@v5
|
|
206
206
|
with:
|
|
207
207
|
env: host=api.dev.local,port=4222
|
|
208
208
|
```
|
|
@@ -217,10 +217,10 @@ jobs:
|
|
|
217
217
|
runs-on: ubuntu-20.04
|
|
218
218
|
steps:
|
|
219
219
|
- name: Checkout
|
|
220
|
-
uses: actions/checkout@
|
|
220
|
+
uses: actions/checkout@v3
|
|
221
221
|
|
|
222
222
|
- name: Cypress run with env
|
|
223
|
-
uses: cypress-io/github-action@
|
|
223
|
+
uses: cypress-io/github-action@v5
|
|
224
224
|
env:
|
|
225
225
|
CYPRESS_host: api.dev.local
|
|
226
226
|
CYPRESS_port: 4222
|
|
@@ -243,10 +243,10 @@ jobs:
|
|
|
243
243
|
runs-on: ubuntu-20.04
|
|
244
244
|
steps:
|
|
245
245
|
- name: Checkout
|
|
246
|
-
uses: actions/checkout@
|
|
246
|
+
uses: actions/checkout@v3
|
|
247
247
|
|
|
248
248
|
- name: Cypress run
|
|
249
|
-
uses: cypress-io/github-action@
|
|
249
|
+
uses: cypress-io/github-action@v5
|
|
250
250
|
with:
|
|
251
251
|
spec: cypress/integration/spec1.js
|
|
252
252
|
```
|
|
@@ -274,16 +274,16 @@ jobs:
|
|
|
274
274
|
runs-on: ubuntu-20.04
|
|
275
275
|
steps:
|
|
276
276
|
- name: Checkout
|
|
277
|
-
uses: actions/checkout@
|
|
277
|
+
uses: actions/checkout@v3
|
|
278
278
|
- name: Cypress run
|
|
279
|
-
uses: cypress-io/github-action@
|
|
279
|
+
uses: cypress-io/github-action@v5
|
|
280
280
|
with:
|
|
281
281
|
project: ./some/nested/folder
|
|
282
282
|
```
|
|
283
283
|
|
|
284
284
|
For more information, visit [the Cypress command-line docs](https://on.cypress.io/command-line#cypress-run-project-lt-project-path-gt).
|
|
285
285
|
|
|
286
|
-
### Record test results on Cypress
|
|
286
|
+
### Record test results on Cypress Cloud
|
|
287
287
|
|
|
288
288
|
```yml
|
|
289
289
|
name: Cypress tests
|
|
@@ -294,14 +294,14 @@ jobs:
|
|
|
294
294
|
runs-on: ubuntu-20.04
|
|
295
295
|
steps:
|
|
296
296
|
- name: Checkout
|
|
297
|
-
uses: actions/checkout@
|
|
297
|
+
uses: actions/checkout@v3
|
|
298
298
|
|
|
299
299
|
- name: Cypress run
|
|
300
|
-
uses: cypress-io/github-action@
|
|
300
|
+
uses: cypress-io/github-action@v5
|
|
301
301
|
with:
|
|
302
302
|
record: true
|
|
303
303
|
env:
|
|
304
|
-
# pass the
|
|
304
|
+
# pass the Cypress Cloud record key as an environment variable
|
|
305
305
|
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
|
|
306
306
|
# pass GitHub token to allow accurately detecting a build vs a re-run build
|
|
307
307
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
@@ -313,7 +313,7 @@ jobs:
|
|
|
313
313
|
|
|
314
314
|
**Tip 2:** 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.
|
|
315
315
|
|
|
316
|
-
**Tip 3:** if running on `pull_request` event, the commit message is "merge SHA into SHA", which is not what you want probably. You can overwrite the commit message sent to
|
|
316
|
+
**Tip 3:** if running on `pull_request` event, the commit message is "merge SHA into SHA", which is not what you want probably. You can overwrite the commit message sent to Cypress Cloud by setting an environment variable. See [issue 124](https://github.com/cypress-io/github-action/issues/124#issuecomment-653180260) for details.
|
|
317
317
|
|
|
318
318
|
**Tip 4:** to record the project needs `projectId`. Typically this value is saved in the `cypress.json` file. If you want to avoid this, pass the project id using an environment variable:
|
|
319
319
|
|
|
@@ -326,14 +326,14 @@ jobs:
|
|
|
326
326
|
runs-on: ubuntu-20.04
|
|
327
327
|
steps:
|
|
328
328
|
- name: Checkout
|
|
329
|
-
uses: actions/checkout@
|
|
329
|
+
uses: actions/checkout@v3
|
|
330
330
|
|
|
331
331
|
- name: Cypress run
|
|
332
|
-
uses: cypress-io/github-action@
|
|
332
|
+
uses: cypress-io/github-action@v5
|
|
333
333
|
with:
|
|
334
334
|
record: true
|
|
335
335
|
env:
|
|
336
|
-
# pass the
|
|
336
|
+
# pass the Cypress Cloud record key as an environment variable
|
|
337
337
|
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
|
|
338
338
|
# pass GitHub token to allow accurately detecting a build vs a re-run build
|
|
339
339
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
@@ -353,7 +353,7 @@ jobs:
|
|
|
353
353
|
runs-on: ubuntu-latest
|
|
354
354
|
steps:
|
|
355
355
|
- name: Checkout
|
|
356
|
-
uses: actions/checkout@
|
|
356
|
+
uses: actions/checkout@v3
|
|
357
357
|
# Install NPM dependencies, cache them correctly
|
|
358
358
|
# and run all Cypress tests with `quiet` parameter
|
|
359
359
|
- name: Cypress run
|
|
@@ -382,16 +382,16 @@ jobs:
|
|
|
382
382
|
name: E2E on Node v${{ matrix.node }}
|
|
383
383
|
steps:
|
|
384
384
|
- name: Setup Node
|
|
385
|
-
uses: actions/setup-node@
|
|
385
|
+
uses: actions/setup-node@v3
|
|
386
386
|
with:
|
|
387
387
|
node-version: ${{ matrix.node }}
|
|
388
388
|
- run: node -v
|
|
389
389
|
|
|
390
390
|
- name: Checkout
|
|
391
|
-
uses: actions/checkout@
|
|
391
|
+
uses: actions/checkout@v3
|
|
392
392
|
|
|
393
393
|
- name: Cypress run
|
|
394
|
-
uses: cypress-io/github-action@
|
|
394
|
+
uses: cypress-io/github-action@v5
|
|
395
395
|
with:
|
|
396
396
|
record: true
|
|
397
397
|
tag: node-${{ matrix.node }}
|
|
@@ -408,7 +408,7 @@ You can pass multiple tags using commas like `tag: node-10,nightly,staging`.
|
|
|
408
408
|
|
|
409
409
|
### Artifacts
|
|
410
410
|
|
|
411
|
-
If you don't record the test run on Cypress
|
|
411
|
+
If you don't record the test run on Cypress Cloud, you can still store generated videos and screenshots as CI artifacts. See [cypress-gh-action-example](https://github.com/bahmutov/cypress-gh-action-example) and the workflow example below
|
|
412
412
|
|
|
413
413
|
```yml
|
|
414
414
|
name: Artifacts
|
|
@@ -418,21 +418,21 @@ jobs:
|
|
|
418
418
|
runs-on: ubuntu-20.04
|
|
419
419
|
name: Artifacts
|
|
420
420
|
steps:
|
|
421
|
-
- uses: actions/checkout@
|
|
422
|
-
- uses: cypress-io/github-action@
|
|
421
|
+
- uses: actions/checkout@v3
|
|
422
|
+
- uses: cypress-io/github-action@v5
|
|
423
423
|
# after the test run completes
|
|
424
424
|
# store videos and any screenshots
|
|
425
425
|
# NOTE: screenshots will be generated only if E2E test failed
|
|
426
426
|
# thus we store screenshots only on failures
|
|
427
427
|
# Alternative: create and commit an empty cypress/screenshots folder
|
|
428
428
|
# to always have something to upload
|
|
429
|
-
- uses: actions/upload-artifact@
|
|
429
|
+
- uses: actions/upload-artifact@v3
|
|
430
430
|
if: failure()
|
|
431
431
|
with:
|
|
432
432
|
name: cypress-screenshots
|
|
433
433
|
path: cypress/screenshots
|
|
434
434
|
# Test run video was always captured, so this action uses "always()" condition
|
|
435
|
-
- uses: actions/upload-artifact@
|
|
435
|
+
- uses: actions/upload-artifact@v3
|
|
436
436
|
if: always()
|
|
437
437
|
with:
|
|
438
438
|
name: cypress-videos
|
|
@@ -452,10 +452,10 @@ jobs:
|
|
|
452
452
|
runs-on: ubuntu-20.04
|
|
453
453
|
steps:
|
|
454
454
|
- name: Checkout
|
|
455
|
-
uses: actions/checkout@
|
|
455
|
+
uses: actions/checkout@v3
|
|
456
456
|
|
|
457
457
|
- name: Cypress run
|
|
458
|
-
uses: cypress-io/github-action@
|
|
458
|
+
uses: cypress-io/github-action@v5
|
|
459
459
|
with:
|
|
460
460
|
config: pageLoadTimeout=100000,baseUrl=http://localhost:3000
|
|
461
461
|
```
|
|
@@ -475,17 +475,17 @@ jobs:
|
|
|
475
475
|
runs-on: ubuntu-20.04
|
|
476
476
|
steps:
|
|
477
477
|
- name: Checkout
|
|
478
|
-
uses: actions/checkout@
|
|
478
|
+
uses: actions/checkout@v3
|
|
479
479
|
|
|
480
480
|
- name: Cypress run
|
|
481
|
-
uses: cypress-io/github-action@
|
|
481
|
+
uses: cypress-io/github-action@v5
|
|
482
482
|
with:
|
|
483
483
|
config-file: tests/cypress-config.json
|
|
484
484
|
```
|
|
485
485
|
|
|
486
486
|
### Parallel
|
|
487
487
|
|
|
488
|
-
**Note:** Cypress parallelization requires [Cypress
|
|
488
|
+
**Note:** Cypress parallelization requires [Cypress Cloud](https://on.cypress.io/dashboard-introduction) account.
|
|
489
489
|
|
|
490
490
|
You can spin multiple containers running in parallel using `strategy: matrix` argument. Just add more dummy items to the `containers: [1, 2, ...]` array to spin more free or paid containers. Then use `record` and `parallel` parameters to [load balance tests](https://on.cypress.io/parallelization)
|
|
491
491
|
|
|
@@ -501,7 +501,7 @@ jobs:
|
|
|
501
501
|
strategy:
|
|
502
502
|
# when one test fails, DO NOT cancel the other
|
|
503
503
|
# containers, because this will kill Cypress processes
|
|
504
|
-
# leaving
|
|
504
|
+
# leaving Cypress Cloud hanging ...
|
|
505
505
|
# https://github.com/cypress-io/github-action/issues/48
|
|
506
506
|
fail-fast: false
|
|
507
507
|
matrix:
|
|
@@ -509,18 +509,18 @@ jobs:
|
|
|
509
509
|
containers: [1, 2, 3]
|
|
510
510
|
steps:
|
|
511
511
|
- name: Checkout
|
|
512
|
-
uses: actions/checkout@
|
|
512
|
+
uses: actions/checkout@v3
|
|
513
513
|
|
|
514
514
|
# because of "record" and "parallel" parameters
|
|
515
515
|
# these containers will load balance all found tests among themselves
|
|
516
516
|
- name: Cypress run
|
|
517
|
-
uses: cypress-io/github-action@
|
|
517
|
+
uses: cypress-io/github-action@v5
|
|
518
518
|
with:
|
|
519
519
|
record: true
|
|
520
520
|
parallel: true
|
|
521
521
|
group: 'Actions example'
|
|
522
522
|
env:
|
|
523
|
-
# pass the
|
|
523
|
+
# pass the Cypress Cloud record key as an environment variable
|
|
524
524
|
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
|
|
525
525
|
# Recommended: pass the GitHub token lets this action correctly
|
|
526
526
|
# determine the unique run id necessary to re-run the checks
|
|
@@ -529,9 +529,9 @@ jobs:
|
|
|
529
529
|
|
|
530
530
|

|
|
531
531
|
|
|
532
|
-
**Warning ⚠️:** Cypress actions use `GITHUB_TOKEN` to get the correct branch and the number of jobs run, making it possible to re-run without the need of pushing an empty commit. If you don't want to use the `GITHUB_TOKEN` you can still run your tests without problem with the only note that Cypress
|
|
532
|
+
**Warning ⚠️:** Cypress actions use `GITHUB_TOKEN` to get the correct branch and the number of jobs run, making it possible to re-run without the need of pushing an empty commit. If you don't want to use the `GITHUB_TOKEN` you can still run your tests without problem with the only note that Cypress Cloud's API connects parallel jobs into a single logical run using GitHub commit SHA plus workflow name. If you attempt to re-run GitHub checks, Cypress Cloud thinks the run has already ended. In order to truly rerun parallel jobs, push an empty commit with `git commit --allow-empty -m "re-run checks" && git push`. As another work around you can generate and cache a custom build id, read [Adding a unique build number to GitHub Actions](https://medium.com/attest-engineering/adding-a-unique-github-build-identifier-7aa2e83cadca)
|
|
533
533
|
|
|
534
|
-
The Cypress GH Action does not spawn or create any additional containers - it only links the multiple containers spawned using the matrix strategy into a single logical
|
|
534
|
+
The Cypress GH Action does not spawn or create any additional containers - it only links the multiple containers spawned using the matrix strategy into a single logical Cypress Cloud run and into splitting the specs amongst the machines. See the [Cypress parallelization](https://on.cypress.io/parallelization) guide for the explanation.
|
|
535
535
|
|
|
536
536
|
### Component tests
|
|
537
537
|
|
|
@@ -539,10 +539,10 @@ You can run [Cypress component tests](https://on.cypress.io/component-testing) i
|
|
|
539
539
|
|
|
540
540
|
```yml
|
|
541
541
|
- name: Run E2E tests 🧪
|
|
542
|
-
uses: cypress-io/github-action@
|
|
542
|
+
uses: cypress-io/github-action@v5
|
|
543
543
|
|
|
544
544
|
- name: Run Component tests 🧪
|
|
545
|
-
uses: cypress-io/github-action@
|
|
545
|
+
uses: cypress-io/github-action@v5
|
|
546
546
|
with:
|
|
547
547
|
# we have already installed everything
|
|
548
548
|
install: false
|
|
@@ -550,7 +550,7 @@ You can run [Cypress component tests](https://on.cypress.io/component-testing) i
|
|
|
550
550
|
component: true
|
|
551
551
|
```
|
|
552
552
|
|
|
553
|
-
See the example project [component-test](
|
|
553
|
+
See the example project [component-test](examples/v10/component-tests/) and the [example-component-test-workflow](.github/workflows/example-component-test.yml) for more details.
|
|
554
554
|
|
|
555
555
|
### Build app
|
|
556
556
|
|
|
@@ -564,9 +564,9 @@ jobs:
|
|
|
564
564
|
runs-on: ubuntu-20.04
|
|
565
565
|
steps:
|
|
566
566
|
- name: Checkout
|
|
567
|
-
uses: actions/checkout@
|
|
567
|
+
uses: actions/checkout@v3
|
|
568
568
|
- name: Cypress run
|
|
569
|
-
uses: cypress-io/github-action@
|
|
569
|
+
uses: cypress-io/github-action@v5
|
|
570
570
|
with:
|
|
571
571
|
build: npm run build
|
|
572
572
|
```
|
|
@@ -583,9 +583,9 @@ jobs:
|
|
|
583
583
|
runs-on: ubuntu-20.04
|
|
584
584
|
steps:
|
|
585
585
|
- name: Checkout
|
|
586
|
-
uses: actions/checkout@
|
|
586
|
+
uses: actions/checkout@v3
|
|
587
587
|
- name: Cypress run
|
|
588
|
-
uses: cypress-io/github-action@
|
|
588
|
+
uses: cypress-io/github-action@v5
|
|
589
589
|
with:
|
|
590
590
|
start: npm start
|
|
591
591
|
```
|
|
@@ -600,9 +600,9 @@ jobs:
|
|
|
600
600
|
runs-on: ubuntu-20.04
|
|
601
601
|
steps:
|
|
602
602
|
- name: Checkout
|
|
603
|
-
uses: actions/checkout@
|
|
603
|
+
uses: actions/checkout@v3
|
|
604
604
|
- name: Cypress run
|
|
605
|
-
uses: cypress-io/github-action@
|
|
605
|
+
uses: cypress-io/github-action@v5
|
|
606
606
|
with:
|
|
607
607
|
# Linux and MacOS
|
|
608
608
|
start: npm start
|
|
@@ -626,9 +626,9 @@ jobs:
|
|
|
626
626
|
runs-on: ubuntu-18.04
|
|
627
627
|
steps:
|
|
628
628
|
- name: Checkout
|
|
629
|
-
uses: actions/checkout@
|
|
629
|
+
uses: actions/checkout@v3
|
|
630
630
|
- name: Cypress run
|
|
631
|
-
uses: cypress-io/github-action@
|
|
631
|
+
uses: cypress-io/github-action@v5
|
|
632
632
|
with:
|
|
633
633
|
start: npm run api, npm run web
|
|
634
634
|
```
|
|
@@ -656,9 +656,9 @@ jobs:
|
|
|
656
656
|
runs-on: ubuntu-20.04
|
|
657
657
|
steps:
|
|
658
658
|
- name: Checkout
|
|
659
|
-
uses: actions/checkout@
|
|
659
|
+
uses: actions/checkout@v3
|
|
660
660
|
- name: Cypress run
|
|
661
|
-
uses: cypress-io/github-action@
|
|
661
|
+
uses: cypress-io/github-action@v5
|
|
662
662
|
with:
|
|
663
663
|
start: npm start
|
|
664
664
|
# quote the url to be safe against YML parsing surprises
|
|
@@ -670,7 +670,7 @@ jobs:
|
|
|
670
670
|
By default, `wait-on` will retry for 60 seconds. You can pass a custom timeout in seconds using `wait-on-timeout`.
|
|
671
671
|
|
|
672
672
|
```yml
|
|
673
|
-
- uses: cypress-io/github-action@
|
|
673
|
+
- uses: cypress-io/github-action@v5
|
|
674
674
|
with:
|
|
675
675
|
start: npm start
|
|
676
676
|
wait-on: 'http://localhost:8080/status'
|
|
@@ -683,7 +683,7 @@ See also [ to wait for the server to respond. For example, if you want to use [wait-on](https://github.com/jeffbski/wait-on) utility to ping the server and run the Cypress tests after the server responds:
|
|
698
698
|
|
|
699
699
|
```yml
|
|
700
|
-
- uses: cypress-io/github-action@
|
|
700
|
+
- uses: cypress-io/github-action@v5
|
|
701
701
|
with:
|
|
702
702
|
start: npm start
|
|
703
703
|
wait-on: 'npx wait-on --timeout 5000 http://localhost:3000'
|
|
@@ -712,7 +712,7 @@ If this action times out waiting for the server to respond, please see [Debuggin
|
|
|
712
712
|
If you want to overwrite the install command
|
|
713
713
|
|
|
714
714
|
```yml
|
|
715
|
-
- uses: cypress-io/github-action@
|
|
715
|
+
- uses: cypress-io/github-action@v5
|
|
716
716
|
with:
|
|
717
717
|
install-command: yarn --frozen-lockfile --silent
|
|
718
718
|
```
|
|
@@ -731,9 +731,9 @@ jobs:
|
|
|
731
731
|
runs-on: ubuntu-20.04
|
|
732
732
|
steps:
|
|
733
733
|
- name: Checkout
|
|
734
|
-
uses: actions/checkout@
|
|
734
|
+
uses: actions/checkout@v3
|
|
735
735
|
- name: Cypress run
|
|
736
|
-
uses: cypress-io/github-action@
|
|
736
|
+
uses: cypress-io/github-action@v5
|
|
737
737
|
with:
|
|
738
738
|
start: npm start
|
|
739
739
|
# quote the url to be safe against YML parsing surprises
|
|
@@ -752,10 +752,10 @@ You can overwrite the Cypress run command with your own
|
|
|
752
752
|
```yml
|
|
753
753
|
steps:
|
|
754
754
|
- name: Checkout 🛎
|
|
755
|
-
uses: actions/checkout@
|
|
755
|
+
uses: actions/checkout@v3
|
|
756
756
|
|
|
757
757
|
- name: Custom tests 🧪
|
|
758
|
-
uses: cypress-io/github-action@
|
|
758
|
+
uses: cypress-io/github-action@v5
|
|
759
759
|
with:
|
|
760
760
|
command: npm run e2e:ci
|
|
761
761
|
```
|
|
@@ -777,24 +777,24 @@ jobs:
|
|
|
777
777
|
# run 3 copies of the current job in parallel
|
|
778
778
|
containers: [1, 2, 3]
|
|
779
779
|
steps:
|
|
780
|
-
- uses: actions/checkout@
|
|
781
|
-
- uses: cypress-io/github-action@
|
|
780
|
+
- uses: actions/checkout@v3
|
|
781
|
+
- uses: cypress-io/github-action@v5
|
|
782
782
|
with:
|
|
783
783
|
record: true
|
|
784
784
|
parallel: true
|
|
785
785
|
group: 'Actions example'
|
|
786
786
|
ci-build-id: '${{ github.sha }}-${{ github.workflow }}-${{ github.event_name }}'
|
|
787
787
|
env:
|
|
788
|
-
# pass the
|
|
788
|
+
# pass the Cypress Cloud record key as an environment variable
|
|
789
789
|
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
|
|
790
790
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
|
791
791
|
```
|
|
792
792
|
|
|
793
|
-
**Tip:** see GitHub Actions
|
|
793
|
+
**Tip:** see [Learn GitHub Actions](https://docs.github.com/en/actions/learn-github-actions), with sections on Expressions, Contexts and Environment variables.
|
|
794
794
|
|
|
795
795
|
### Robust custom build id
|
|
796
796
|
|
|
797
|
-
If you re-run the GitHub workflow, if you use the same custom build id during recording,
|
|
797
|
+
If you re-run the GitHub workflow, if you use the same custom build id during recording, Cypress Cloud will cancel the run with "Build already finished" error. To avoid this, you need to generate a _new_ custom build id on every workflow re-run. A good solution showing in the [example-custom-ci-build-id.yml](./.github/workflows/example-custom-ci-build-id.yml) file is to run a common job first that just generates a new random ID. This ID can be used by the testing jobs to tie the build together. If the user re-runs the workflow a new unique build id is generated, allowing recording the new Cypress Cloud run.
|
|
798
798
|
|
|
799
799
|
```yml
|
|
800
800
|
jobs:
|
|
@@ -812,14 +812,14 @@ jobs:
|
|
|
812
812
|
smoke-tests:
|
|
813
813
|
needs: ['prepare']
|
|
814
814
|
steps:
|
|
815
|
-
- uses: actions/checkout@
|
|
816
|
-
- uses: cypress-io/github-action@
|
|
815
|
+
- uses: actions/checkout@v3
|
|
816
|
+
- uses: cypress-io/github-action@v5
|
|
817
817
|
with:
|
|
818
818
|
record: true
|
|
819
819
|
parallel: true
|
|
820
820
|
ci-build-id: ${{ needs.prepare.outputs.uuid }}
|
|
821
821
|
env:
|
|
822
|
-
# pass the
|
|
822
|
+
# pass the Cypress Cloud record key as an environment variable
|
|
823
823
|
CYPRESS_RECORD_KEY: ${{ secrets.EXAMPLE_RECORDING_KEY }}
|
|
824
824
|
```
|
|
825
825
|
|
|
@@ -846,8 +846,8 @@ jobs:
|
|
|
846
846
|
cypress-run:
|
|
847
847
|
runs-on: ubuntu-20.04
|
|
848
848
|
steps:
|
|
849
|
-
- uses: actions/checkout@
|
|
850
|
-
- uses: cypress-io/github-action@
|
|
849
|
+
- uses: actions/checkout@v3
|
|
850
|
+
- uses: cypress-io/github-action@v5
|
|
851
851
|
with:
|
|
852
852
|
start: npm start
|
|
853
853
|
working-directory: e2e
|
|
@@ -891,7 +891,7 @@ jobs:
|
|
|
891
891
|
|
|
892
892
|
# Cypress has its own package.json in folder "e2e"
|
|
893
893
|
- name: Install Cypress and run tests
|
|
894
|
-
uses: cypress-io/github-action@
|
|
894
|
+
uses: cypress-io/github-action@v5
|
|
895
895
|
with:
|
|
896
896
|
working-directory: e2e
|
|
897
897
|
```
|
|
@@ -900,7 +900,7 @@ See [cypress-gh-action-subfolders](https://github.com/bahmutov/cypress-gh-action
|
|
|
900
900
|
|
|
901
901
|
### Yarn workspaces
|
|
902
902
|
|
|
903
|
-
This action should discover Yarn workspace correctly. For example, see folder [examples/start-and-yarn-workspaces](examples/start-and-yarn-workspaces) and workflow file [example-start-and-yarn-workspaces.yml](.github/workflows/example-start-and-yarn-workspaces.yml)
|
|
903
|
+
This action should discover Yarn workspace correctly. For example, see folder [examples/v10/start-and-yarn-workspaces](examples/v10/start-and-yarn-workspaces) and workflow file [example-start-and-yarn-workspaces.yml](.github/workflows/example-start-and-yarn-workspaces.yml)
|
|
904
904
|
|
|
905
905
|
```yaml
|
|
906
906
|
name: example-start-and-yarn-workspaces
|
|
@@ -912,10 +912,10 @@ jobs:
|
|
|
912
912
|
# and tests in a subfolder like "workspace-1"
|
|
913
913
|
runs-on: ubuntu-latest
|
|
914
914
|
steps:
|
|
915
|
-
- uses: actions/checkout@
|
|
916
|
-
- uses: cypress-io/github-action@
|
|
915
|
+
- uses: actions/checkout@v3
|
|
916
|
+
- uses: cypress-io/github-action@v5
|
|
917
917
|
with:
|
|
918
|
-
working-directory: examples/start-and-yarn-workspaces/workspace-1
|
|
918
|
+
working-directory: examples/v10/start-and-yarn-workspaces/workspace-1
|
|
919
919
|
build: yarn run build
|
|
920
920
|
start: yarn start
|
|
921
921
|
wait-on: 'http://localhost:5000'
|
|
@@ -940,15 +940,15 @@ jobs:
|
|
|
940
940
|
name: E2E on Node v${{ matrix.node }}
|
|
941
941
|
steps:
|
|
942
942
|
- name: Setup Node
|
|
943
|
-
uses: actions/setup-node@
|
|
943
|
+
uses: actions/setup-node@v3
|
|
944
944
|
with:
|
|
945
945
|
node-version: ${{ matrix.node }}
|
|
946
946
|
- name: Checkout
|
|
947
|
-
uses: actions/checkout@
|
|
947
|
+
uses: actions/checkout@v3
|
|
948
948
|
# run Cypress tests and record them under the same run
|
|
949
949
|
# associated with commit SHA and just give a different group name
|
|
950
950
|
- name: Cypress run
|
|
951
|
-
uses: cypress-io/github-action@
|
|
951
|
+
uses: cypress-io/github-action@v5
|
|
952
952
|
with:
|
|
953
953
|
record: true
|
|
954
954
|
group: Tests on Node v${{ matrix.node }}
|
|
@@ -973,11 +973,11 @@ jobs:
|
|
|
973
973
|
node: [10, 12]
|
|
974
974
|
name: E2E on Node v${{ matrix.node }}
|
|
975
975
|
steps:
|
|
976
|
-
- uses: actions/setup-node@
|
|
976
|
+
- uses: actions/setup-node@v3
|
|
977
977
|
with:
|
|
978
978
|
node-version: ${{ matrix.node }}
|
|
979
|
-
- uses: actions/checkout@
|
|
980
|
-
- uses: cypress-io/github-action@
|
|
979
|
+
- uses: actions/checkout@v3
|
|
980
|
+
- uses: cypress-io/github-action@v5
|
|
981
981
|
```
|
|
982
982
|
|
|
983
983
|
[](.github/workflows/example-node-versions.yml)
|
|
@@ -997,13 +997,13 @@ jobs:
|
|
|
997
997
|
steps:
|
|
998
998
|
- uses: actions/checkout@master
|
|
999
999
|
- name: Install dependencies
|
|
1000
|
-
uses: cypress-io/github-action@
|
|
1000
|
+
uses: cypress-io/github-action@v5
|
|
1001
1001
|
with:
|
|
1002
1002
|
# just perform install
|
|
1003
1003
|
runTests: false
|
|
1004
1004
|
- run: yarn lint
|
|
1005
1005
|
- name: Run e2e tests
|
|
1006
|
-
uses: cypress-io/github-action@
|
|
1006
|
+
uses: cypress-io/github-action@v5
|
|
1007
1007
|
with:
|
|
1008
1008
|
# we have already installed all dependencies above
|
|
1009
1009
|
install: false
|
|
@@ -1022,7 +1022,7 @@ Finally, you might not need this GH Action at all. For example, if you want to s
|
|
|
1022
1022
|
If the project has many dependencies, but you want to install just Cypress you can combine this action with `actions/cache` and `npm i cypress` commands yourself.
|
|
1023
1023
|
|
|
1024
1024
|
```yml
|
|
1025
|
-
- uses: actions/checkout@
|
|
1025
|
+
- uses: actions/checkout@v3
|
|
1026
1026
|
- uses: actions/cache@v2
|
|
1027
1027
|
with:
|
|
1028
1028
|
path: |
|
|
@@ -1030,7 +1030,7 @@ If the project has many dependencies, but you want to install just Cypress you c
|
|
|
1030
1030
|
node_modules
|
|
1031
1031
|
key: my-cache-${{ runner.os }}-${{ hashFiles('package-lock.json') }}
|
|
1032
1032
|
- run: npm i cypress
|
|
1033
|
-
- uses: cypress-io/github-action@
|
|
1033
|
+
- uses: cypress-io/github-action@v5
|
|
1034
1034
|
with:
|
|
1035
1035
|
install: false
|
|
1036
1036
|
```
|
|
@@ -1051,8 +1051,8 @@ jobs:
|
|
|
1051
1051
|
# to prevent a hanging process from using all your CI minutes
|
|
1052
1052
|
timeout-minutes: 10
|
|
1053
1053
|
steps:
|
|
1054
|
-
- uses: actions/checkout@
|
|
1055
|
-
- uses: cypress-io/github-action@
|
|
1054
|
+
- uses: actions/checkout@v3
|
|
1055
|
+
- uses: cypress-io/github-action@v5
|
|
1056
1056
|
# you can specify individual step timeout too
|
|
1057
1057
|
timeout-minutes: 5
|
|
1058
1058
|
```
|
|
@@ -1064,7 +1064,7 @@ See [cypress-gh-action-example](https://github.com/bahmutov/cypress-gh-action-ex
|
|
|
1064
1064
|
<!-- prettier-ignore-start -->
|
|
1065
1065
|
Name | Description
|
|
1066
1066
|
--- | ---
|
|
1067
|
-
[cypress-gh-action-small-example](https://github.com/bahmutov/cypress-gh-action-small-example) | Runs tests and records them on Cypress
|
|
1067
|
+
[cypress-gh-action-small-example](https://github.com/bahmutov/cypress-gh-action-small-example) | Runs tests and records them on Cypress Cloud
|
|
1068
1068
|
[cypress-gh-action-example](https://github.com/bahmutov/cypress-gh-action-example) | uses Yarn, and runs in parallel on several versions of Node, different browsers, and more.
|
|
1069
1069
|
[cypress-gh-action-monorepo](https://github.com/bahmutov/cypress-gh-action-monorepo) | splits install and running tests commands, runs Cypress from sub-folder
|
|
1070
1070
|
[cypress-gh-action-subfolders](https://github.com/bahmutov/cypress-gh-action-subfolders) | separate folder for Cypress dependencies
|
|
@@ -1099,7 +1099,7 @@ You can set the environment variable using GitHub UI interface, or in the workfl
|
|
|
1099
1099
|
|
|
1100
1100
|
```yml
|
|
1101
1101
|
- name: Cypress tests with debug logs
|
|
1102
|
-
uses: cypress-io/github-action@
|
|
1102
|
+
uses: cypress-io/github-action@v5
|
|
1103
1103
|
env:
|
|
1104
1104
|
DEBUG: '@cypress/github-action'
|
|
1105
1105
|
```
|
|
@@ -1112,7 +1112,7 @@ The above `ACTIONS_STEP_DEBUG` setting enables the debug logs from the action it
|
|
|
1112
1112
|
|
|
1113
1113
|
```yml
|
|
1114
1114
|
- name: Cypress tests with debug logs
|
|
1115
|
-
uses: cypress-io/github-action@
|
|
1115
|
+
uses: cypress-io/github-action@v5
|
|
1116
1116
|
env:
|
|
1117
1117
|
DEBUG: 'cypress:*'
|
|
1118
1118
|
```
|
|
@@ -1146,7 +1146,7 @@ Read [DEVELOPMENT.md](DEVELOPMENT.md)
|
|
|
1146
1146
|
|
|
1147
1147
|
- Read our blog post [Drastically Simplify Testing on CI with Cypress GitHub Action](https://www.cypress.io/blog/2019/11/20/drastically-simplify-your-testing-with-cypress-github-action/)
|
|
1148
1148
|
- Read [Test the Preview Vercel Deploys](https://glebbahmutov.com/blog/develop-preview-test/) blog post
|
|
1149
|
-
- [
|
|
1149
|
+
- [Creating actions](https://docs.github.com/en/actions/creating-actions) docs
|
|
1150
1150
|
- practice using the Cypress GitHub Action by following the [Cypress on CI Workshop](https://github.com/cypress-io/cypress-workshop-ci)
|
|
1151
1151
|
|
|
1152
1152
|
## Extras
|
|
@@ -1157,11 +1157,11 @@ If you add `workflow_dispatch` event to your workflow, you will be able to start
|
|
|
1157
1157
|
|
|
1158
1158
|
### Outputs
|
|
1159
1159
|
|
|
1160
|
-
This GH Action sets an output `dashboardUrl` if the run was recorded on [Cypress
|
|
1160
|
+
This GH Action sets an output `dashboardUrl` if the run was recorded on [Cypress Cloud](https://on.cypress.io/dashboard-introduction), see [action.yml](action.yml). To use this output:
|
|
1161
1161
|
|
|
1162
1162
|
```yml
|
|
1163
1163
|
- name: Cypress tests
|
|
1164
|
-
uses: cypress-io/github-action@
|
|
1164
|
+
uses: cypress-io/github-action@v5
|
|
1165
1165
|
# let's give this action an ID so we can refer
|
|
1166
1166
|
# to its output values later
|
|
1167
1167
|
id: cypress
|
|
@@ -1172,7 +1172,7 @@ This GH Action sets an output `dashboardUrl` if the run was recorded on [Cypress
|
|
|
1172
1172
|
record: true
|
|
1173
1173
|
env:
|
|
1174
1174
|
CYPRESS_RECORD_KEY: ${{ secrets.RECORDING_KEY }}
|
|
1175
|
-
- name: Print
|
|
1175
|
+
- name: Print Cypress Cloud URL
|
|
1176
1176
|
run: |
|
|
1177
1177
|
echo Cypress finished with: ${{ steps.cypress.outcome }}
|
|
1178
1178
|
echo See results at ${{ steps.cypress.outputs.dashboardUrl }}
|
|
@@ -1196,7 +1196,7 @@ jobs:
|
|
|
1196
1196
|
# https://github.com/cypress-io/cypress-docker-images/tree/master/included
|
|
1197
1197
|
container: cypress/included:3.8.3
|
|
1198
1198
|
steps:
|
|
1199
|
-
- uses: actions/checkout@
|
|
1199
|
+
- uses: actions/checkout@v3
|
|
1200
1200
|
- run: cypress run
|
|
1201
1201
|
```
|
|
1202
1202
|
|
|
@@ -1214,9 +1214,9 @@ jobs:
|
|
|
1214
1214
|
runs-on: ubuntu-20.04
|
|
1215
1215
|
steps:
|
|
1216
1216
|
- name: Checkout
|
|
1217
|
-
uses: actions/checkout@
|
|
1217
|
+
uses: actions/checkout@v3
|
|
1218
1218
|
- name: Cypress run
|
|
1219
|
-
uses: cypress-io/github-action@
|
|
1219
|
+
uses: cypress-io/github-action@v5
|
|
1220
1220
|
with:
|
|
1221
1221
|
build: npx cypress info
|
|
1222
1222
|
```
|
|
@@ -1231,16 +1231,16 @@ jobs:
|
|
|
1231
1231
|
runs-on: ubuntu-20.04
|
|
1232
1232
|
steps:
|
|
1233
1233
|
- name: Checkout
|
|
1234
|
-
uses: actions/checkout@
|
|
1234
|
+
uses: actions/checkout@v3
|
|
1235
1235
|
- name: Cypress install
|
|
1236
|
-
uses: cypress-io/github-action@
|
|
1236
|
+
uses: cypress-io/github-action@v5
|
|
1237
1237
|
with:
|
|
1238
1238
|
# just perform install
|
|
1239
1239
|
runTests: false
|
|
1240
1240
|
- name: Cypress info
|
|
1241
1241
|
run: npx cypress info
|
|
1242
1242
|
- name: Cypress run
|
|
1243
|
-
uses: cypress-io/github-action@
|
|
1243
|
+
uses: cypress-io/github-action@v5
|
|
1244
1244
|
with:
|
|
1245
1245
|
# we have already installed all dependencies above
|
|
1246
1246
|
install: false
|
|
@@ -1262,9 +1262,9 @@ jobs:
|
|
|
1262
1262
|
runs-on: ubuntu-20.04
|
|
1263
1263
|
steps:
|
|
1264
1264
|
- name: Checkout
|
|
1265
|
-
uses: actions/checkout@
|
|
1265
|
+
uses: actions/checkout@v3
|
|
1266
1266
|
- name: Cypress nightly tests 🌃
|
|
1267
|
-
uses: cypress-io/github-action@
|
|
1267
|
+
uses: cypress-io/github-action@v5
|
|
1268
1268
|
```
|
|
1269
1269
|
|
|
1270
1270
|
See the [example-cron.yml](./.github/workflows/example-cron.yml) workflow.
|