forked from saleor/saleor-dashboard
-
Notifications
You must be signed in to change notification settings - Fork 0
264 lines (238 loc) · 9.77 KB
/
tests-nightly.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
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
name: Execute nightly tests
on:
workflow_dispatch:
inputs:
tags:
required: true
description: 'Select tests to run'
default: '@allEnv'
type: choice
options:
- '@allEnv'
- '@critical'
- '@stable'
environment:
required: true
description: 'Environment to run tests against'
default: 'https://automation-dashboard.staging.saleor.cloud/'
type: choice
options:
- https://automation-dashboard.staging.saleor.cloud/
- https://master.staging.saleor.cloud/
- https://latest.staging.saleor.cloud/
- https://qa.staging.saleor.cloud/
- Other
otherEnvironment:
required: false
description: 'Type env if "Other" option is selected'
type: string
default: 'https://vXX.staging.saleor.cloud/'
schedule:
- cron: '00 2 * * 1-5'
repository_dispatch:
types: [automation-tests-event]
jobs:
revert-automation-env-to-snap:
if: ${{ github.event.inputs.environment == null && github.event_name != 'repository_dispatch' }}
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: 16
- name: Install saleor cli
id: install-saleor-cli
run: npm i -g @saleor/cli
- name: Cache node modules
uses: actions/cache@v2
env:
cache-name: cache-node-modules-cli
with:
path: ~/.npm
key: ${{ runner.os }}-qa-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-qa-${{ env.cache-name }}-
${{ runner.os }}-qa-
${{ runner.os }}-
- name: Write config file
id: write-config-file
env:
ACCESS_TOKEN: ${{ secrets.CLOUD_ACCESS_TOKEN }}
run: echo '{"token":"Token ${{ secrets.CLOUD_ACCESS_TOKEN }}","telemetry":"false","organization_slug":"qa","organization_name":"QA","environment_id":"lHECN87U"}' > ~/.config/saleor.json
- name: revert snapshot
env:
CI: true
SALEOR_CLI_ENV: staging
run: npx saleor backup restore 6tOoEwCh --skip-webhooks-update
- name: Notify Slack
if: ${{ failure() }}
uses: rtCamp/action-slack-notify@v2
env:
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK_SNAP_RESTORE }}
SLACK_USERNAME: RevertSnapshotBot
SLACK_COLOR: ${{ job.status }}
SLACK_TITLE: "Revert to snapshot job failed"
SLACK_MESSAGE: "https://github.com/saleor/saleor-dashboard/actions/workflows/tests-nightly.yml"
MSG_MINIMAL: true
run-tests-in-parallel:
needs: ['revert-automation-env-to-snap']
if: ${{ always() && github.event_name != 'repository_dispatch' }} #Wait for revert-automation-env-to-snap, bot run always, even if skipped
runs-on: ubuntu-latest
outputs:
status: ${{ steps.cypress.outcome }}
container: cypress/browsers:node14.16.0-chrome89-ff86
strategy:
fail-fast: false
matrix:
# run copies of the current job in parallel
containers: [1, 2, 3, 4]
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Check if other env
id: get-typed-env-uri
if: ${{ github.event.inputs.environment == 'Other' }}
run: |
echo "::set-output name=ENV_URI::${{github.event.inputs.otherEnvironment}}"
- name: Get env
id: get-env-uri
env:
DEFAULT_ENV_URI: 'https://automation-dashboard.staging.saleor.cloud/'
TYPED_ENV_URI: ''
run: |
echo "::set-output name=ENV_URI::${{ steps.get-typed-env-uri.outputs.ENV_URI || github.event.inputs.environment || env.DEFAULT_ENV_URI }}"
- name: Setup Node
uses: actions/setup-node@v3
with:
node-version: 14
- name: Cypress run
id: cypress
continue-on-error: true
if: ${{ github.event.inputs.tests != 'Critical' && github.event_name != 'repository_dispatch'}}
uses: cypress-io/github-action@v4
env:
API_URI: ${{ steps.get-env-uri.outputs.ENV_URI }}graphql/
APP_MOUNT_URI: ${{ secrets.APP_MOUNT_URI }}
CYPRESS_baseUrl: ${{ steps.get-env-uri.outputs.ENV_URI }}dashboard/
CYPRESS_USER_NAME: ${{ secrets.CYPRESS_USER_NAME }}
CYPRESS_SECOND_USER_NAME: ${{ secrets.CYPRESS_SECOND_USER_NAME }}
CYPRESS_USER_PASSWORD: ${{ secrets.CYPRESS_USER_PASSWORD }}
CYPRESS_PERMISSIONS_USERS_PASSWORD: ${{ secrets.CYPRESS_PERMISSIONS_USERS_PASSWORD }}
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CYPRESS_mailHogUrl: ${{ secrets.CYPRESS_MAILHOG }}
COMMIT_INFO_MESSAGE: All tests triggered via ${{ github.event_name}} on ${{ steps.get-env-uri.outputs.ENV_URI }}
CYPRESS_grepTags: ${{ github.event.inputs.tags }}
STRIPE_SECRET_KEY: ${{ secrets.STRIPE_SECRET_KEY }}
STRIPE_PUBLIC_KEY: ${{ secrets.STRIPE_PUBLIC_KEY }}
with:
parallel: true
group: 'UI - Chrome'
record: true
tag: ${{ steps.get-env-uri.outputs.ENV_URI }},${{ github.event.inputs.tags }}
get-url:
if: ${{ github.event_name == 'repository_dispatch' && (github.event.client_payload.environment == 'SANDBOX' || github.event.client_payload.environment == 'STAGING')}}
runs-on: ubuntu-latest
timeout-minutes: 30
outputs:
url: ${{ steps.get-url.outputs.url }}
env:
TOKEN: ${{ secrets.CLOUD_ACCESS_TOKEN }}
VERSION: ${{github.event.client_payload.version}}
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup Node
uses: actions/setup-node@v1
with:
node-version: 14
- name: Install dependencies
run: |
cd .github/workflows
npm ci
- name: get-url
id: get-url
run: |
node .github/workflows/getUrlForReleaseTests.js \
--version $VERSION \
--token "$TOKEN"
run-tests-on-release:
if: ${{ github.event_name == 'repository_dispatch' && (github.event.client_payload.environment == 'SANDBOX' || github.event.client_payload.environment == 'STAGING')}}
needs: get-url
runs-on: ubuntu-latest
outputs:
status: ${{ steps.cypress.outcome }}
dashboard_url: ${{ steps.cypress.outputs.dashboardUrl }}
container: cypress/browsers:node14.16.0-chrome89-ff86
strategy:
fail-fast: false
matrix:
# run copies of the current job in parallel
containers: [1, 2, 3, 4, 5, 6]
steps:
- name: Get branch
id: branch
env:
version: ${{github.event.client_payload.version}}
run: |
echo "::set-output name=ref::$(echo $version | grep -ohE "[0-9]\.[0-9]+" )"
- name: Checkout
uses: actions/checkout@v3
with:
ref: ${{ steps.branch.outputs.ref }}
- name: Cypress run - automatically
id: cypress
continue-on-error: true
uses: cypress-io/github-action@v4
env:
API_URI: ${{ needs.get-url.outputs.url }}graphql/
APP_MOUNT_URI: ${{ secrets.APP_MOUNT_URI }}
CYPRESS_baseUrl: ${{ needs.get-url.outputs.url }}dashboard/
CYPRESS_USER_NAME: ${{ secrets.CYPRESS_USER_NAME }}
CYPRESS_SECOND_USER_NAME: ${{ secrets.CYPRESS_SECOND_USER_NAME }}
CYPRESS_USER_PASSWORD: ${{ secrets.CYPRESS_USER_PASSWORD }}
CYPRESS_PERMISSIONS_USERS_PASSWORD: ${{ secrets.CYPRESS_PERMISSIONS_USERS_PASSWORD }}
STRIPE_SECRET_KEY: ${{ secrets.STRIPE_SECRET_KEY }}
STRIPE_PUBLIC_KEY: ${{ secrets.STRIPE_PUBLIC_KEY }}
CYPRESS_RECORD_KEY: ${{ secrets.CYPRESS_RECORD_KEY }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CYPRESS_mailHogUrl: ${{ secrets.CYPRESS_MAILHOG }}
COMMIT_INFO_MESSAGE: Critical triggered via release - ${{github.event.client_payload.project}} ${{github.event.client_payload.version}}, ${{github.event.client_payload.pullRequestUrl}}
CYPRESS_grepTags: '@stable'
with:
parallel: true
group: 'UI - Chrome'
record: true
tag: ${{github.event.client_payload.project}}, ${{github.event.client_payload.environment}}, Critical, https://v${{ steps.version.outputs.formatted_version }}.staging.saleor.cloud
add-review-and-merge-patch:
if: ${{ always() && (needs.run-tests-on-release.outputs.status == 'success' || needs.run-tests-on-release.outputs.status == 'failure') }}
runs-on: ubuntu-latest
needs: [run-tests-on-release]
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup Node
uses: actions/setup-node@v1
with:
node-version: 14
- name: Install dependencies
run: |
cd .github/workflows
npm ci
- name: Add review and merge if patch DASHBOARD
env:
tests_status: ${{ needs.run-tests-on-release.outputs.status}}
version: ${{github.event.client_payload.version}}
pull_request_number: ${{ github.event.client_payload.pullRequestNumber}}
auto_release: ${{github.event.client_payload.autoRelease}}
dashboard_url: ${{ needs.run-tests-on-release.outputs.dashboard_url}}
run: |
export GITHUB_TOKEN=$( \
curl --request GET --url ${{ secrets.VAULT_URL}} --header "Authorization: JWT ${{ secrets.VAULT_JWT }}" | jq -r .token \
)
node .github/workflows/approveAndMergeReleasePR.js \
--version $version \
--pull_request_number $pull_request_number \
--auto_release $auto_release \
--dashboard_url $dashboard_url