You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+49Lines changed: 49 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -70,6 +70,7 @@ The following examples demonstrate the actions' functions.
70
70
- Use [custom cache key](#custom-cache-key)
71
71
- Run tests on multiple [Node versions](#node-versions)
72
72
- Split [install and tests](#split-install-and-tests) into separate jobs
73
+
- Split [install and tests](#split-install-and-test-with-artifacts) with artifacts
73
74
- Use [custom install commands](#custom-install)
74
75
- Install [only Cypress](#install-cypress-only) to avoid installing all dependencies
75
76
- Use [timeouts](#timeouts) to avoid hanging CI jobs
@@ -1386,6 +1387,54 @@ jobs:
1386
1387
1387
1388
See [cypress-gh-action-monorepo](https://github.com/bahmutov/cypress-gh-action-monorepo) for a working example.
1388
1389
1390
+
### Split install and test with artifacts
1391
+
1392
+
If your test job(s) first need a build step, you can split the jobs into a separate build job followed by test jobs. You pass the build results to any subsequent jobs using [GitHub Actions artifacts](https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/storing-and-sharing-data-from-a-workflow).
1393
+
1394
+
In the build job, use [upload-artifact](https://github.com/actions/upload-artifact) to store the build results, then in subsequent jobs use [download-artifact](https://github.com/actions/download-artifact) to restore them.
1395
+
1396
+
Your tests jobs may use a [GitHub Actions matrix strategy](https://docs.github.com/en/actions/writing-workflows/choosing-what-your-workflow-does/running-variations-of-jobs-in-a-workflow), such as when recording to [Cypress Cloud](https://on.cypress.io/cloud-introduction) with [parallel jobs](#parallel).
1397
+
1398
+
```yml
1399
+
name: Split build and test
1400
+
on: push
1401
+
jobs:
1402
+
build:
1403
+
runs-on: ubuntu-24.04
1404
+
steps:
1405
+
- uses: actions/checkout@v4
1406
+
- name: Build app
1407
+
uses: cypress-io/github-action@v6
1408
+
with:
1409
+
runTests: false # only build app, don't test yet
1410
+
build: npm run build
1411
+
- name: Store build artifacts
1412
+
uses: actions/upload-artifact@v4
1413
+
with:
1414
+
name: app
1415
+
path: build
1416
+
if-no-files-found: error
1417
+
retention-days: 1
1418
+
1419
+
test:
1420
+
needs: build
1421
+
runs-on: ubuntu-24.04
1422
+
steps:
1423
+
- uses: actions/checkout@v4
1424
+
- name: Restore build artifacts
1425
+
uses: actions/download-artifact@v4
1426
+
with:
1427
+
name: app
1428
+
path: build
1429
+
1430
+
- name: Cypress tests
1431
+
uses: cypress-io/github-action@v6
1432
+
with:
1433
+
start: npm start # start server using the build artifacts
1434
+
```
1435
+
1436
+
[](.github/workflows/example-build-artifacts.yml)
1437
+
1389
1438
### Custom install
1390
1439
1391
1440
Finally, you might not need this GH Action at all. For example, if you want to split the npm dependencies installation from the Cypress binary installation, then it makes no sense to use this action. Instead you can install and cache Cypress yourself.
0 commit comments