forked from cypress-io/github-action
-
Notifications
You must be signed in to change notification settings - Fork 0
142 lines (127 loc) · 4.68 KB
/
example-recording.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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
name: example-recording
#
# To set up this workflow to work with your own Cypress Cloud project
# refer to the README in the example directory examples/recording.
#
on:
push:
branches:
- 'master'
pull_request:
workflow_dispatch:
env:
# Set up the Cypress Cloud project ID and record key as environment variables
# If the Actions secret EXAMPLE_PROJECT_ID is not defined then
# the projectId is taken from cypress.json (v9) or cypress.config.js (v10 and later).
# If the Actions secret EXAMPLE_RECORDING_KEY is not defined then recording jobs are skipped.
CYPRESS_PROJECT_ID: ${{ secrets.EXAMPLE_PROJECT_ID }}
CYPRESS_RECORD_KEY: ${{ secrets.EXAMPLE_RECORDING_KEY }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
jobs:
check-record-key:
runs-on: ubuntu-22.04
outputs:
record-key-exists: ${{ steps.record-key-check.outputs.defined }}
steps:
- name: Check for record key
id: record-key-check
run: |
if [ "${{ secrets.EXAMPLE_RECORDING_KEY }}" != '' ]; then
echo "defined=true" >> $GITHUB_OUTPUT;
else
echo "defined=false" >> $GITHUB_OUTPUT;
fi
# ~~~~~~~~~~~~~~~~~~ Cypress v9 and below (using Legacy configuration) ~~~~~~~~~~~~~~~~~~~ #
parallel-v9:
runs-on: ubuntu-22.04
needs: [check-record-key]
if: needs.check-record-key.outputs.record-key-exists == 'true'
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Cypress tests
# normally you would write
# uses: cypress-io/github-action@v5
uses: ./
# let's give this action an ID so we can refer
# to its output values later
id: cypress
# Continue the build in case of an error, as we need to set the
# commit status in the next step, both in case of success and failure
continue-on-error: true
with:
working-directory: examples/v9/recording
record: true
parallel: true
group: Recording example v9
tag: action
# see "outcome" and "conclusion" of a step doc
# https://docs.github.com/en/actions/reference/context-and-expression-syntax-for-github-actions#steps-context
# "output" can be success, failure, cancelled, or skipped
- name: Print Dashboard URL
run: |
echo Cypress finished with: ${{ steps.cypress.outcome }}
echo See results at ${{ steps.cypress.outputs.dashboardUrl }}
group-v9:
runs-on: ubuntu-22.04
needs: [check-record-key]
if: needs.check-record-key.outputs.record-key-exists == 'true'
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Cypress tests
# normally you would write
# uses: cypress-io/github-action@v5
uses: ./
with:
working-directory: examples/v9/recording
record: true
# no parallel flag, just the group name
group: Recording group v9
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Cypress v10 and higher ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ #
parallel:
runs-on: ubuntu-22.04
needs: [check-record-key]
if: needs.check-record-key.outputs.record-key-exists == 'true'
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Cypress tests
# normally you would write
# uses: cypress-io/github-action@v5
uses: ./
# let's give this action an ID so we can refer
# to its output values later
id: cypress
# Continue the build in case of an error, as we need to set the
# commit status in the next step, both in case of success and failure
continue-on-error: true
with:
working-directory: examples/recording
record: true
parallel: true
group: Recording example
tag: action
# see "outcome" and "conclusion" of a step doc
# https://docs.github.com/en/actions/reference/context-and-expression-syntax-for-github-actions#steps-context
# "output" can be success, failure, cancelled, or skipped
- name: Print Dashboard URL
run: |
echo Cypress finished with: ${{ steps.cypress.outcome }}
echo See results at ${{ steps.cypress.outputs.dashboardUrl }}
group:
runs-on: ubuntu-22.04
needs: [check-record-key]
if: needs.check-record-key.outputs.record-key-exists == 'true'
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Cypress tests
# normally you would write
# uses: cypress-io/github-action@v5
uses: ./
with:
working-directory: examples/recording
record: true
# no parallel flag, just the group name
group: Recording group