-
Notifications
You must be signed in to change notification settings - Fork 84
113 lines (103 loc) · 3.58 KB
/
cypress.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
name: Cypress tests
on:
workflow_dispatch:
inputs:
number:
description: "Pull Request Number"
required: true
jobs:
cypress-react-tests:
runs-on: ubuntu-latest
timeout-minutes: 20
strategy:
fail-fast: false
matrix:
# run 5 copy of the current job in parallel
containers: [1, 2, 3, 4, 5]
container:
image: cypress/browsers:node-18.14.1-chrome-110.0.5481.96-1-ff-109.0-edge-110.0.1587.41-1
options: --user 1001
steps:
- id: get_pull
uses: octokit/request-action@v2.x
with:
route: GET /repos/{owner}/{repo}/pulls/{pull_number}
owner: ${{ github.event.repository.owner.login }}
repo: ${{ github.event.repository.name }}
pull_number: ${{ github.event.inputs.number }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Checkout
uses: actions/checkout@v3
with:
ref: "refs/pull/${{ github.event.inputs.number }}/head"
fetch-depth: 0
- name: Cache central NPM modules
uses: actions/cache@v3
with:
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Cache Cypress binary
uses: actions/cache@v3
with:
path: ~/.cache/Cypress
key: cypress-${{ runner.os }}-cypress-${{ hashFiles('package.json') }}
restore-keys: |
cypress-${{ runner.os }}-cypress-
- name: install dependencies and verify Cypress
env:
# make sure every Cypress install prints minimal information
CI: 1
run: |
npm ci
npx cypress cache path
npx cypress cache list
npx cypress verify
npx cypress info
- name: Cypress React tests
uses: cypress-io/github-action@v5
with:
component: true
install: false
quiet: true
browser: chrome
env:
COMMIT_INFO_BRANCH: ${{ fromJson(steps.get_pull.outputs.data).head.label }}
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
CI: "true"
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SPLIT: ${{ strategy.job-total }}
SPLIT_INDEX: ${{ strategy.job-index }}
- name: Upload Cypress report
uses: actions/upload-artifact@v3
if: always()
with:
name: cypress-reports
path: cypress/reports
retention-days: 10
- name: Report status - success
if: always() && success()
run: |
curl -X POST \
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/${{ github.repository }}/statuses/${{ fromJson(steps.get_pull.outputs.data).head.sha }} \
-d '{
"state": "success",
"context": "Cypress tests",
"description": "workflow completed successfully."
}'
- name: Report status - failed
if: always() && failure()
run: |
curl -X POST \
-H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/${{ github.repository }}/statuses/${{ fromJson(steps.get_pull.outputs.data).head.sha }} \
-d '{
"state": "failure",
"context": "Cypress tests",
"description": "workflow failed."
}'