-
Notifications
You must be signed in to change notification settings - Fork 916
351 lines (316 loc) · 13.5 KB
/
cypress_workflow.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
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
name: Run cypress tests
# trigger on every PR for all branches
on:
pull_request:
branches: ['**']
paths-ignore:
- '**/*.md'
- '.lycheeignore'
- 'changelogs/fragments/**'
workflow_dispatch:
inputs:
test_repo:
description: 'Cypress test repo'
default: 'opensearch-project/opensearch-dashboards-functional-test'
required: true
type: string
test_branch:
description: 'Cypress test branch (default: source branch)'
required: false
type: string
specs:
description: 'Tests to run (default: osd:ciGroup)'
required: false
type: string
pr_number:
description: 'PR Number (optional)'
required: false
type: number
env:
TEST_REPO: ${{ inputs.test_repo != '' && inputs.test_repo || 'opensearch-project/opensearch-dashboards-functional-test' }}
TEST_BRANCH: "${{ inputs.test_branch != '' && inputs.test_branch || github.base_ref }}"
FTR_PATH: 'ftr'
CYPRESS_BROWSER: 'chromium'
CYPRESS_VISBUILDER_ENABLED: true
CYPRESS_DATASOURCE_MANAGEMENT_ENABLED: false
OSD_SNAPSHOT_SKIP_VERIFY_CHECKSUM: true
NODE_OPTIONS: '--max-old-space-size=6144 --dns-result-order=ipv4first'
COMMENT_TAG: '[MANUAL CYPRESS TEST RUN RESULTS]'
COMMENT_SUCCESS_MSG: ':white_check_mark: Cypress test run succeeded!'
COMMENT_FAILURE_MSG: ':x: Cypress test run failed!'
LATEST_VERSION: '2.17.0'
jobs:
cypress-tests:
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
include:
# Standard test configs (groups 1-9)
- group: 1
config: standard
test_location: ftr
- group: 2
config: standard
test_location: ftr
- group: 3
config: standard
test_location: ftr
- group: 4
config: standard
test_location: ftr
- group: 5
config: standard
test_location: ftr
- group: 6
config: standard
test_location: ftr
- group: 7
config: standard
test_location: ftr
- group: 8
config: standard
test_location: ftr
- group: 9
config: standard
test_location: ftr
# Query enhanced tests
- group: 10
config: query_enhanced
test_location: ftr
# Dashboard tests
- group: 11
config: dashboard
test_location: source
container:
image: docker://opensearchstaging/ci-runner:ci-runner-rockylinux8-opensearch-dashboards-integtest-v2
options: --user 1001
env:
START_CMD: ${{ matrix.config == 'query_enhanced' &&
'node ../scripts/opensearch_dashboards --dev --no-base-path --no-watch --savedObjects.maxImportPayloadBytes=10485760 --server.maxPayloadBytes=1759977 --logging.json=false --data.search.aggs.shardDelay.enabled=true --csp.warnLegacyBrowsers=false --uiSettings.overrides["query:enhancements:enabled"]=true --uiSettings.overrides[''home:useNewHomePage'']=true --data_source.enabled=true --opensearch.ignoreVersionMismatch=true' ||
matrix.config == 'dashboard' &&
'node scripts/opensearch_dashboards --dev --no-base-path --no-watch --savedObjects.maxImportPayloadBytes=10485760 --server.maxPayloadBytes=1759977 --logging.json=false --data.search.aggs.shardDelay.enabled=true' ||
'node ../scripts/opensearch_dashboards --dev --no-base-path --no-watch --savedObjects.maxImportPayloadBytes=10485760 --server.maxPayloadBytes=1759977 --logging.json=false --data.search.aggs.shardDelay.enabled=true --csp.warnLegacyBrowsers=false --uiSettings.overrides["query:enhancements:enabled"]=false' }}
OPENSEARCH_SNAPSHOT_CMD: ${{ matrix.config == 'query_enhanced' &&
'/bin/bash -c "./opensearch-2.17.0/opensearch-tar-install.sh &"' ||
matrix.config == 'dashboard' &&
'node scripts/opensearch snapshot -E cluster.routing.allocation.disk.threshold_enabled=false' ||
'node ../scripts/opensearch snapshot -E cluster.routing.allocation.disk.threshold_enabled=false' }}
# prevents extra Cypress installation progress messages
CI: 1
# avoid warnings like "tput: No value for $TERM and no -T specified"
TERM: xterm
name: Run cypress tests (osd:ciGroup${{ matrix.group }})
steps:
- name: Get source information from PR number
if: ${{ github.event_name == 'workflow_dispatch' && inputs.pr_number != '' }}
id: get_pr_info
uses: actions/github-script@v6
with:
script: |
const { data: result } = await github.rest.pulls.get({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: ${{ inputs.pr_number }}
});
core.setOutput('head_name', result.head.repo.full_name);
core.setOutput('head_ref', result.head.ref);
- name: Set source repo from PR number
if: ${{ github.event_name == 'workflow_dispatch' && inputs.pr_number != '' }}
run: |
echo "SOURCE_REPO=${{ steps.get_pr_info.outputs.head_name }}" >> $GITHUB_ENV
echo "SOURCE_BRANCH=${{ steps.get_pr_info.outputs.head_ref }}" >> $GITHUB_ENV
- name: Checkout code
uses: actions/checkout@v2
with:
repository: ${{ env.SOURCE_REPO }}
ref: '${{ env.SOURCE_BRANCH }}'
- name: Setup Node
uses: actions/setup-node@v2
with:
node-version-file: '.nvmrc'
registry-url: 'https://registry.npmjs.org'
- name: Setup Yarn
run: |
npm uninstall -g yarn
npm i -g [email protected]
- name: Run bootstrap
run: yarn osd bootstrap
- name: Build plugins
run: node scripts/build_opensearch_dashboards_platform_plugins --no-examples --workers 12
- name: Checkout FT repo
uses: actions/checkout@v2
with:
path: ${{ env.FTR_PATH }}
repository: ${{ env.TEST_REPO }}
ref: '${{ env.TEST_BRANCH }}'
- name: Setup spec files by input
if: ${{ inputs.specs != '' }}
run: |
echo "SPEC=${{ inputs.specs }}" >> $GITHUB_ENV
# Setup spec files for existing Functional Test repo cypress tests
- name: Setup spec files
if: ${{ inputs.specs == '' && matrix.test_location == 'ftr' }}
working-directory: ${{ env.FTR_PATH }}
shell: bash
run: |
IFS="," read -a SPEC_ARRAY <<< $(yarn --silent osd:ciGroup${{ matrix.group }})
FORMATTED_SPEC=''
for i in "${SPEC_ARRAY[@]}"; do
FORMATTED_SPEC+="cypress/integration/core-opensearch-dashboards/opensearch-dashboards/${i},"
done
echo "SPEC=${FORMATTED_SPEC}" >> $GITHUB_ENV
# Setup spec files for Dashboards in-house cypress tests
- name: Setup spec files for Dashboards tests
if: ${{ inputs.specs == '' && matrix.test_location == 'source' }}
shell: bash
run: |
IFS="," read -a SPEC_ARRAY <<< $(yarn --silent osd:ciGroup${{ matrix.group }})
DASHBOARDS_SPEC=''
for i in "${SPEC_ARRAY[@]}"; do
DASHBOARDS_SPEC+="cypress/integration/core_opensearch_dashboards/${i},"
done
echo "DASHBOARDS_SPEC=${DASHBOARDS_SPEC}" >> $GITHUB_ENV
- name: Get Cypress version
if: ${{ matrix.test_location == 'ftr' }}
id: cypress_version
run: |
echo "name=cypress_version::$(cat ./${{ env.FTR_PATH }}/package.json | jq '.devDependencies.cypress' | tr -d '"')" >> $GITHUB_OUTPUT
- name: Cache Cypress
if: ${{ matrix.test_location == 'ftr' }}
id: cache-cypress
uses: actions/cache@v1
with:
path: ~/.cache/Cypress
key: cypress-cache-v2-${{ runner.os }}-${{ hashFiles('**/package.json') }}
env:
CYPRESS_INSTALL_BINARY: ${{ steps.cypress_version.outputs.cypress_version }}
- run: npx cypress cache list
- run: npx cypress cache path
# Run tests based on configuration
- name: Run FT repo tests with no query enhancements
if: matrix.test_location == 'ftr' && matrix.config == 'standard'
uses: cypress-io/github-action@v2
with:
working-directory: ${{ env.FTR_PATH }}
start: ${{ env.OPENSEARCH_SNAPSHOT_CMD }}, ${{ env.START_CMD }}
wait-on: 'http://localhost:9200, http://localhost:5601'
command: yarn cypress:run-without-security --browser ${{ env.CYPRESS_BROWSER }} --spec ${{ env.SPEC }}
- name: Download OpenSearch
if: matrix.test_location == 'ftr' && matrix.config == 'query_enhanced'
uses: suisei-cn/[email protected]
with:
url: https://artifacts.opensearch.org/releases/bundle/opensearch/${{ env.LATEST_VERSION }}/opensearch-${{ env.LATEST_VERSION }}-linux-x64.tar.gz
- name: Extract OpenSearch
if: matrix.test_location == 'ftr' && matrix.config == 'query_enhanced'
run: |
tar -xzf opensearch-*.tar.gz
rm -f opensearch-*.tar.gz
shell: bash
- name: Remove security plugin
if: matrix.test_location == 'ftr' && matrix.config == 'query_enhanced'
run: |
/bin/bash -c "yes | ./opensearch-${{ env.LATEST_VERSION }}/bin/opensearch-plugin remove opensearch-security"
shell: bash
- name: Run OpenSearch
if: matrix.test_location == 'ftr' && matrix.config == 'query_enhanced'
run: |
/bin/bash -c "./opensearch-2.17.0/opensearch-tar-install.sh &"
sleep 30
shell: bash
- name: Run FT repo tests with query enhancements
if: matrix.test_location == 'ftr' && matrix.config == 'query_enhanced'
uses: cypress-io/github-action@v2
with:
working-directory: ${{ env.FTR_PATH }}
start: ${{ env.START_CMD }}
wait-on: 'http://localhost:9200, http://localhost:5601'
command: yarn cypress:run-without-security --browser ${{ env.CYPRESS_BROWSER }} --spec ${{ env.SPEC }}
# Clear Cypress Cache before running Dashboards tests
- name: Clear Cypress Cache
if: matrix.test_location == 'source'
run: npx cypress cache clear
# Run Dashboards Cypress tests within the source repo
- name: Run Dashboards Cypress tests
if: matrix.test_location == 'source'
uses: cypress-io/github-action@v6
with:
install-command: npx cypress install --force
start: ${{ env.OPENSEARCH_SNAPSHOT_CMD }}, ${{ env.START_CMD }}
wait-on: 'http://localhost:9200, http://localhost:5601'
command: yarn cypress:run-without-security --browser ${{ env.CYPRESS_BROWSER }} --spec ${{ env.DASHBOARDS_SPEC }}
# Screenshots are only captured on failure, will change this once we do visual regression tests
- name: Upload FT repo screenshots
uses: actions/upload-artifact@v3
if: failure() && matrix.test_location == 'ftr'
with:
name: ftr-cypress-screenshots
path: ${{ env.FTR_PATH }}/cypress/screenshots
retention-days: 1
- name: Upload FT repo videos
uses: actions/upload-artifact@v3
if: always() && matrix.test_location == 'ftr'
with:
name: ftr-cypress-videos
path: ${{ env.FTR_PATH }}/cypress/videos
retention-days: 1
- name: Upload FT repo results
uses: actions/upload-artifact@v3
if: always() && matrix.test_location == 'ftr'
with:
name: ftr-cypress-results
path: ${{ env.FTR_PATH }}/cypress/results
retention-days: 1
- name: Upload Dashboards screenshots
if: failure() && matrix.test_location == 'source'
uses: actions/upload-artifact@v3
with:
name: dashboards-cypress-screenshots
path: cypress/screenshots
retention-days: 1
- name: Upload Dashboards repo videos
uses: actions/upload-artifact@v3
if: always() && matrix.test_location == 'source'
with:
name: dashboards-cypress-videos
path: cypress/videos
retention-days: 1
- name: Upload Dashboards repo results
uses: actions/upload-artifact@v3
if: always() && matrix.test_location == 'source'
with:
name: dashboards-cypress-results
path: cypress/results
retention-days: 1
add-comment:
needs: [cypress-tests]
if: ${{ always() && github.event_name == 'workflow_dispatch' && inputs.pr_number != '' }}
permissions:
pull-requests: write
runs-on: ubuntu-latest
steps:
- name: Find Comment
uses: peter-evans/find-comment@v2
id: fc
with:
issue-number: ${{ inputs.pr_number }}
comment-author: 'github-actions[bot]'
body-includes: '${{ env.COMMENT_TAG }}'
- name: Add comment on the PR
uses: peter-evans/create-or-update-comment@v3
with:
comment-id: ${{ steps.fc.outputs.comment-id }}
issue-number: ${{ inputs.pr_number }}
body: |
### ${{ env.COMMENT_TAG }}
#### ${{ needs.cypress-tests.result == 'success' && env.COMMENT_SUCCESS_MSG || env.COMMENT_FAILURE_MSG }}
#### Inputs:
```
Test repo: '${{ env.TEST_REPO }}'
Test branch: '${{ env.TEST_BRANCH }}'
Test spec:
'${{ env.SPEC }}'
```
#### Link to results:
${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
edit-mode: replace