forked from cypress-io/github-action
-
Notifications
You must be signed in to change notification settings - Fork 0
163 lines (144 loc) · 4.73 KB
/
example-env.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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
name: example-env
on:
push:
branches:
- 'master'
pull_request:
workflow_dispatch:
env:
# pass an environment variable to Cypress
# a test can get its value like this
# Cypress.env('environmentName') // 'staging'
# see https://on.cypress.io/env
CYPRESS_environmentName: staging
jobs:
# ~~~~~~~~~~~~~~~~~~ Cypress v9 and below (using Legacy configuration) ~~~~~~~~~~~~~~~~~~~ #
e2e-v9:
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v3
# in the tests below, only the environment
# variable 'environmentName' will be set
- name: Cypress run with env
uses: ./
with:
working-directory: examples/v9/env
spec: cypress/integration/without-env-spec.js
with-env-v9:
# in the tests below, in addition to 'environmentName'
# we are passing additional environment variables
# using "--env" command line option
# see https://on.cypress.io/configuration
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Cypress run with env
uses: ./
with:
working-directory: examples/v9/env
# additional env variables to pass to Cypress specs
# variables are automatically casted
# Cypress.env('host') // 'http://api.dev.local'
# Cypress.env('apiPort') // 4222
env: host=http://api.dev.local,apiPort=4222
spec: cypress/integration/spec.js
with-action-env-v9:
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Cypress run with env
uses: ./
# GH Actions workflow syntax allows
# each step to add more environment variables
# via additional "env" blocks
env:
CYPRESS_apiPort: 4222
CYPRESS_host: http://api.dev.local
with:
working-directory: examples/v9/env
spec: cypress/integration/spec.js
combined-env-v9:
# combination of all 3 ways to pass environment variables
# 'environmentName' value comes from the workflow's environment
# 'apiPort' comes from the step's "env" block
# 'host' is defined in the action's "with: env:" parameter
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Cypress run with env
uses: ./
env:
CYPRESS_apiPort: 4222
with:
env: host=http://api.dev.local
working-directory: examples/v9/env
spec: cypress/integration/spec.js
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Cypress v10 and higher ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ #
e2e:
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v3
# in the tests below, only the environment
# variable 'environmentName' will be set
- name: Cypress run with env
uses: ./
with:
working-directory: examples/env
spec: cypress/e2e/without-env.cy.js
with-env:
# in the tests below, in addition to 'environmentName'
# we are passing additional environment variables
# using "--env" command line option
# see https://on.cypress.io/configuration
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Cypress run with env
uses: ./
with:
working-directory: examples/env
# additional env variables to pass to Cypress specs
# variables are automatically casted
# Cypress.env('host') // 'http://api.dev.local'
# Cypress.env('apiPort') // 4222
env: host=http://api.dev.local,apiPort=4222
spec: cypress/e2e/spec.cy.js
with-action-env:
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Cypress run with env
uses: ./
# GH Actions workflow syntax allows
# each step to add more environment variables
# via additional "env" blocks
env:
CYPRESS_apiPort: 4222
CYPRESS_host: http://api.dev.local
with:
working-directory: examples/env
spec: cypress/e2e/spec.cy.js
combined-env:
# combination of all 3 ways to pass environment variables
# 'environmentName' value comes from the workflow's environment
# 'apiPort' comes from the step's "env" block
# 'host' is defined in the action's "with: env:" parameter
runs-on: ubuntu-22.04
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Cypress run with env
uses: ./
env:
CYPRESS_apiPort: 4222
with:
env: host=http://api.dev.local
working-directory: examples/env
spec: cypress/e2e/spec.cy.js