Skip to content

Commit

Permalink
Use Cypress GitHub action (#326)
Browse files Browse the repository at this point in the history
* add GitHub workflow that uses Cypress GH action https://github.com/cypress-io/github-action
  • Loading branch information
bahmutov committed Dec 2, 2019
1 parent 34e73f1 commit 29c3859
Show file tree
Hide file tree
Showing 3 changed files with 96 additions and 6 deletions.
23 changes: 20 additions & 3 deletions .github/workflows/parallel.yml
Expand Up @@ -3,9 +3,7 @@
# good list of examples at http://www.thedreaming.org/2019/09/10/github-ci/
name: Cypress parallel tests

# trigger on regular "internal" pushes and on pull requests
# from external forks
on: [push, pull_request]
on: push

jobs:
install:
Expand All @@ -26,6 +24,25 @@ jobs:
run: |
npm i -g @bahmutov/print-env
print-env GITHUB
print-env BUILD
print-env ACTIONS
cat $GITHUB_EVENT_PATH
# https://help.github.com/en/actions/automating-your-workflow-with-github-actions/contexts-and-expression-syntax-for-github-actions#contexts
- name: Print job object
run: echo '${{ toJson(job) }}'

- name: Print steps object
run: echo '${{ toJson(steps) }}'

- name: Print runner object
run: echo '${{ toJson(runner) }}'

- name: Print strategy object
run: echo '${{ toJson(strategy) }}'

- name: Print matrix object
run: echo '${{ toJson(matrix) }}'

# Restore the previous NPM modules and Cypress binary archives.
# Any updated archives will be saved automatically after the entire
Expand Down
4 changes: 1 addition & 3 deletions .github/workflows/single.yml
Expand Up @@ -2,9 +2,7 @@
# https://help.github.com/en/articles/configuring-a-workflow
name: Cypress tests

# trigger on regular "internal" pushes and on pull requests
# from external forks
on: [push, pull_request]
on: push

jobs:
test1:
Expand Down
75 changes: 75 additions & 0 deletions .github/workflows/using-action.yml
@@ -0,0 +1,75 @@
# Note: make sure to use the same version of cypress-io/github-action
# in all jobs, otherwise the last version wins I believe
name: Using Cypress GH Action

on: push

jobs:
single-run:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v1
- name: Cypress run
uses: cypress-io/github-action@v1
timeout-minutes: 10
with:
build: npm run build
start: npm start

parallel-runs:
name: Parallel 4x
runs-on: ubuntu-latest
strategy:
matrix:
# run 4 copies of the current job in parallel
# the actual items in the array do not matter
# we just need to "force" GitHub CI to create 4 jobs
machines: [1, 2, 3, 4]
steps:
- name: Checkout
uses: actions/checkout@v1

# because of "record" and "parallel" parameters
# these containers will load balance all found tests among themselves
- name: run tests
uses: cypress-io/github-action@v1
timeout-minutes: 5
with:
record: true
parallel: true
group: GH Action parallel
start: npm start
env:
# pass the Dashboard record key as an environment variable
CYPRESS_RECORD_KEY: ${{ secrets.dashboardRecordKey }}

parallel-runs-across-platforms:
name: every OS
strategy:
matrix:
# run 2 copies of the current job in parallel
# and they will load balance all specs
os: ['ubuntu-latest', 'windows-latest', 'macos-latest']
machines: [1, 2]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout
uses: actions/checkout@v1

# because of "record" and "parallel" parameters
# these containers will load balance all found tests among themselves
- name: run tests
uses: cypress-io/github-action@v1
timeout-minutes: 10
with:
record: true
parallel: true
group: Parallel 2x on ${{ matrix.os }}
# on Mac and Linux we can use "npm start"
start: npm start
# but for this particular project on Windows we need a different start command
start-windows: npm run start:ci:windows
env:
# pass the Dashboard record key as an environment variable
CYPRESS_RECORD_KEY: ${{ secrets.dashboardRecordKey }}

0 comments on commit 29c3859

Please sign in to comment.