-
Notifications
You must be signed in to change notification settings - Fork 38
403 lines (378 loc) · 16.1 KB
/
dashboards-notifications-test-and-build-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
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
##
# Copyright OpenSearch Contributors
# SPDX-License-Identifier: Apache-2.0
##
name: Test and Build Dashboards Notifications
on: [pull_request, push]
env:
PLUGIN_NAME: notifications-dashboards
OPENSEARCH_DASHBOARDS_VERSION: 'main'
NOTIFICATIONS_PLUGIN_VERSION: 'main'
OPENSEARCH_VERSION: '3.0.0-SNAPSHOT'
jobs:
Get-CI-Image-Tag:
uses: opensearch-project/opensearch-build/.github/workflows/get-ci-image-tag.yml@main
with:
product: opensearch-dashboards
tests-linux:
needs: Get-CI-Image-Tag
env:
JEST_TEST_ARGS: ${{ matrix.jest_test_args }}
# prevents extra Cypress installation progress messages
CI: 1
# avoid warnings like "tput: No value for $TERM and no -T specified"
TERM: xterm
WORKING_DIR: ${{ matrix.working_directory }}.
strategy:
# This setting says that all jobs should finish, even if one fails
fail-fast: false
matrix:
os: [ ubuntu-latest ]
include:
- os: ubuntu-latest
os_build_args: -x integTest -x jacocoTestReport
jest_test_args: --coverage
cypress_cache_folder: ~/.cache/Cypress
name: Test and Build Dashboards Notifications on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
container:
# using the same image which is used by opensearch-build team to build the OpenSearch Distribution
# this image tag is subject to change as more dependencies and updates will arrive over time
image: ${{ needs.Get-CI-Image-Tag.outputs.ci-image-version-linux }}
# need to switch to root so that github actions can install runner binary on container without permission issues.
options: --user root
steps:
- name: Install cypress
run: |
#ftrepo_package="https://raw.githubusercontent.com/opensearch-project/opensearch-dashboards-functional-test/${{ env.OPENSEARCH_DASHBOARDS_VERSION }}/package.json"
#echo ftrepo_package $ftrepo_package
#cypress_version=$(curl -o- $ftrepo_package | jq -r .devDependencies.cypress)
#cd ./OpenSearch-Dashboards/plugins/dashboards-notifications
#cypress_version=`jq -r .devDependencies.cypress package.json`
#echo cypress_version $cypress_version
su `id -un 1000` -c "source $NVM_DIR/nvm.sh && nvm use && node -v && yarn -v && npm install -g cypress@^6.0.0 && cd ~/.cache/Cypress && ls && pwd"
#cd plugins/dashboards-notifications
netstat -ntlp
exit 1
- name: Set up JDK
uses: actions/setup-java@v2
with:
distribution: temurin # Temurin is a distribution of adoptium
java-version: 11
- name: Checkout Plugin
uses: actions/checkout@v2
with:
path: notifications
repository: opensearch-project/notifications
ref: '2.x'
- name: Check out the notifications repo
uses: actions/checkout@v2
with:
repository: opensearch-project/notifications
ref: ${{ env.NOTIFICATIONS_PLUGIN_VERSION }}
path: notifications
- name: Run Opensearch with plugin
working-directory: ${{ env.WORKING_DIR }}
run: |
chown -R 1000:1000 `pwd`
cd notifications/notifications
su `id -un 1000` -c "nohup ./gradlew run -Dopensearch.version=${{ env.OPENSEARCH_VERSION }} -x integTest -x jacocoTestReport &"
timeout 300 bash -c 'while [[ "$(curl -s -o /dev/null -w ''%{http_code}'' localhost:9200)" != "200" ]]; do sleep 5; done'
shell: bash
env:
_JAVA_OPTIONS: ${{ matrix.os_java_options }}
- name: Checkout Notification Dashboards plugin
uses: actions/checkout@v2
with:
path: dashboards-notifications
- name: Checkout OpenSearch Dashboards
uses: actions/checkout@v2
with:
repository: opensearch-project/Opensearch-Dashboards
ref: ${{ env.OPENSEARCH_DASHBOARDS_VERSION }}
path: OpenSearch-Dashboards
- name: Move Notifications to Plugins Dir
run: |
mv dashboards-notifications OpenSearch-Dashboards/plugins/dashboards-notifications
- name: OpenSearch Dashboards Plugin Bootstrap and build
run: |
chown -R 1000:1000 `pwd`
cd ./OpenSearch-Dashboards/
su `id -un 1000` -c "source $NVM_DIR/nvm.sh && nvm use && node -v && yarn -v &&
cd ./plugins/dashboards-notifications &&
whoami && yarn osd bootstrap && yarn build"
- name: Run unit tests
uses: nick-fields/retry@v2
with:
timeout_minutes: 30
max_attempts: 1
command: cd ./OpenSearch-Dashboards/plugins/dashboards-notifications; su `id -un 1000` -c "yarn test:jest ${{ env.JEST_TEST_ARGS }}"
shell: bash
- name: Run OpenSearch Dashboards server
run: |
cd ./OpenSearch-Dashboards
su `id -un 1000` -c 'source $NVM_DIR/nvm.sh && nvm use && node -v && yarn -v && nohup yarn start --no-base-path --no-watch --server.host="0.0.0.0" &'
timeout 900 bash -c 'while [[ "$(curl -s http://localhost:5601/api/status | jq -r '.status.overall.state')" != "green" ]]; do echo sleeping 5; sleep 5; done'
curl -sk localhost:5601/api/status | jq
netstat -anp tcp | grep LISTEN | grep 5601 || netstat -ntlp | grep 5601
shell: bash
# - name: Add sleep to wait for bundle build completion
# run: |
# sleep 300
# # sleep two more minutes to make sure all the bundles have been built.
# shell: bash
- name: Install cypress
run: |
#ftrepo_package="https://raw.githubusercontent.com/opensearch-project/opensearch-dashboards-functional-test/${{ env.OPENSEARCH_DASHBOARDS_VERSION }}/package.json"
#echo ftrepo_package $ftrepo_package
#cypress_version=$(curl -o- $ftrepo_package | jq -r .devDependencies.cypress)
cd ./OpenSearch-Dashboards/plugins/dashboards-notifications
cypress_version=`jq -r .devDependencies.cypress package.json`
echo cypress_version $cypress_version
#su `id -un 1000` -c "source $NVM_DIR/nvm.sh && nvm use && node -v && yarn -v && npm install -g cypress@$cypress_version"
source $NVM_DIR/nvm.sh && nvm use && node -v && yarn -v && npm install -g cypress@$cypress_version
ls -l ~/.cache/Cypress
#cd plugins/dashboards-notifications
netstat -ntlp
yarn run cypress run
#- name: Run Cypress tests
# uses: cypress-io/github-action@v2
# with:
# working-directory: OpenSearch-Dashboards/plugins/dashboards-notifications
# command: su `id -un 1000` -c "cd ../../ && source $NVM_DIR/nvm.sh && nvm use && node -v && yarn -v && cd - && yarn run cypress run"
# wait-on: 'http://localhost:5601'
# Screenshots are only captured on failure, will change this once we do visual regression tests
- uses: actions/upload-artifact@v1
if: failure()
with:
name: cypress-screenshots-${{ matrix.os }}
path: OpenSearch-Dashboards/plugins/dashboards-notifications/.cypress/screenshots
# Test run video was always captured, so this action uses "always()" condition
- uses: actions/upload-artifact@v1
if: always()
with:
name: cypress-videos-${{ matrix.os }}
path: OpenSearch-Dashboards/plugins/dashboards-notifications/.cypress/videos
- name: Upload coverage
uses: codecov/codecov-action@v1
with:
flags: dashboards-notifications
directory: OpenSearch-Dashboards/plugins/
token: ${{ secrets.CODECOV_TOKEN }}
- name: Upload Artifact
uses: actions/upload-artifact@v1
with:
name: dashboards-notifications
path: OpenSearch-Dashboards/plugins/dashboards-notifications/build
# tests-windows-macos:
# env:
# JEST_TEST_ARGS: ${{ matrix.jest_test_args }}
# # prevents extra Cypress installation progress messages
# CI: 1
# # avoid warnings like "tput: No value for $TERM and no -T specified"
# TERM: xterm
# WORKING_DIR: ${{ matrix.working_directory }}.
# strategy:
# # This setting says that all jobs should finish, even if one fails
# fail-fast: false
# matrix:
# # TODO: macos-latest was removed due to CI flakiness, we can revisit adding it back later
# os: [ windows-latest ]
# include:
# - os: windows-latest
# os_build_args: -x integTest -x jacocoTestReport
# working_directory: X:\
# os_java_options: -Xmx4096M
# cypress_cache_folder: ~/AppData/Local/Cypress/Cache
# # TODO: Add back when macos-latest is back in the test matrix
## - os: macos-latest
## cypress_cache_folder: ~/Library/Caches/Cypress
#
#
# name: Test and Build Dashboards Notifications on ${{ matrix.os }}
# runs-on: ${{ matrix.os }}
#
# steps:
# - name: Set up JDK
# uses: actions/setup-java@v2
# with:
# distribution: temurin # Temurin is a distribution of adoptium
# java-version: 11
#
# - name: Checkout Plugin
# uses: actions/checkout@v2
# with:
# path: notifications
# repository: opensearch-project/notifications
# ref: '2.x'
#
# # This is a hack, but this step creates a link to the X: mounted drive, which makes the path
# # short enough to work on Windows
# - name: Shorten Path
# if: ${{ matrix.os == 'windows-latest' }}
# run: |
# git config --system core.longpaths true
# subst 'X:' .
#
# - name: enable long paths in git
# if: ${{ matrix.os == 'windows-latest' }}
# run: |
# # enable long paths to fix "path too long" errors when cloning repos in windows
# git config --system core.longpaths true
# shell: bash
#
# - name: Check out the notifications repo
# uses: actions/checkout@v2
# with:
# repository: opensearch-project/notifications
# ref: ${{ env.NOTIFICATIONS_PLUGIN_VERSION }}
# path: notifications
#
# - name: Run Opensearch with plugin
# working-directory: ${{ env.WORKING_DIR }}
# run: |
# # Install coreutils for macOS since timeout doesn't seem to available on that OS even when forcing bash shell
# if [ "$RUNNER_OS" == "macOS" ]; then
# brew install coreutils
# fi
# cd notifications/notifications
# ./gradlew run -Dopensearch.version=${{ env.OPENSEARCH_VERSION }} -x integTest -x jacocoTestReport &
# timeout 300 bash -c 'while [[ "$(curl -s -o /dev/null -w ''%{http_code}'' localhost:9200)" != "200" ]]; do sleep 5; done'
# shell: bash
# env:
# _JAVA_OPTIONS: ${{ matrix.os_java_options }}
#
# - name: Checkout Notification Dashboards plugin
# uses: actions/checkout@v2
# with:
# path: dashboards-notifications
# - name: Checkout OpenSearch Dashboards
# uses: actions/checkout@v2
# with:
# repository: opensearch-project/Opensearch-Dashboards
# ref: ${{ env.OPENSEARCH_DASHBOARDS_VERSION }}
# path: OpenSearch-Dashboards
#
# - name: Setup Node
# uses: actions/setup-node@v3
# with:
# node-version-file: './OpenSearch-Dashboards/.nvmrc'
# registry-url: 'https://registry.npmjs.org'
#
# - name: Install correct yarn version for OpenSearch Dashboards
# # Need to use bash to avoid having a windows/linux specific step
# shell: bash
# run: |
# YARN_VERSION=$(node -p "require('./OpenSearch-Dashboards/package.json').engines.yarn")
# echo "Installing yarn@$YARN_VERSION"
# npm i -g yarn@$YARN_VERSION
#
# - run: node -v
# - run: yarn -v
#
# - name: Set npm to use bash for shell
# if: ${{ matrix.os == 'windows-latest' }}
# run: |
# # Sets Windows to use bash for npm shell so the script commands work as intended
# npm config set script-shell "C:\\Program Files\\git\\bin\\bash.exe"
#
# - name: Move Notifications to Plugins Dir
# run: |
# mv dashboards-notifications OpenSearch-Dashboards/plugins/dashboards-notifications
#
# - name: OpenSearch Dashboards Plugin Bootstrap
# run: |
# cd ./OpenSearch-Dashboards/plugins/dashboards-notifications
# yarn osd bootstrap
#
# - name: Build Artifact
# run: |
# cd ./OpenSearch-Dashboards/plugins/dashboards-notifications
# yarn build
#
# - name: Run unit tests
# uses: nick-fields/retry@v2
# with:
# timeout_minutes: 30
# max_attempts: 1
# command: cd ./OpenSearch-Dashboards/plugins/dashboards-notifications; yarn test:jest ${{ env.JEST_TEST_ARGS }}
# shell: bash
#
# - name: Run OpenSearch Dashboards server
# run: |
# cd ./OpenSearch-Dashboards
# yarn start --no-base-path --no-watch --server.host="0.0.0.0" &
# timeout 900 bash -c 'while [[ "$(curl -s http://localhost:5601/api/status | jq -r '.status.overall.state')" != "green" ]]; do echo sleeping 5; sleep 5; done'
# curl -sk localhost:5601/api/status | jq
# netstat -anp tcp | grep LISTEN | grep 5601 || netstat -ntlp | grep 5601
# shell: bash
#
# - name: Add sleep to wait for bundle build completion
# run: |
# sleep 300
# # sleep two more minutes to make sure all the bundles have been built.
# shell: bash
#
# - name: Install Cypress
# run: |
# cd ./OpenSearch-Dashboards/plugins/dashboards-notifications
# # This will install Cypress in case the binary is missing which can happen on Windows and Mac
# # If the binary exists, this will exit quickly so it should not be an expensive operation
# npx cypress install
# shell: bash
#
# - name: Get Cypress version
# id: cypress_version
# run: |
# cd ./OpenSearch-Dashboards/plugins/dashboards-notifications
# echo "::set-output name=cypress_version::$(cat ./package.json | jq '.dependencies.cypress' | tr -d '"')"
#
# - name: Cache Cypress
# id: cache-cypress
# uses: actions/cache@v2
# with:
# path: ${{ matrix.cypress_cache_folder }}
# key: cypress-cache-v2-${{ runner.os }}-${{ hashFiles('OpenSearch-Dashboards/plugins/dashboards-notifications/package.json') }}
#
# - name: Reset npm's script shell
# if: ${{ matrix.os == 'windows-latest' }}
# run: |
# # Resetting npm's script shell for Windows so `yarn run cypress` doesn't have conflicts
# npm config delete script-shell
#
# - name: Run Cypress tests
# uses: cypress-io/github-action@v2
# with:
# working-directory: OpenSearch-Dashboards/plugins/dashboards-notifications
# command: yarn run cypress run
# wait-on: 'http://localhost:5601'
# env:
# CYPRESS_CACHE_FOLDER: ${{ matrix.cypress_cache_folder }}
#
# # Screenshots are only captured on failure, will change this once we do visual regression tests
# - uses: actions/upload-artifact@v1
# if: failure()
# with:
# name: cypress-screenshots-${{ matrix.os }}
# path: OpenSearch-Dashboards/plugins/dashboards-notifications/.cypress/screenshots
#
# # Test run video was always captured, so this action uses "always()" condition
# - uses: actions/upload-artifact@v1
# if: always()
# with:
# name: cypress-videos-${{ matrix.os }}
# path: OpenSearch-Dashboards/plugins/dashboards-notifications/.cypress/videos
#
# - name: Upload coverage
# if: ${{ matrix.os == 'ubuntu-latest' }}
# uses: codecov/codecov-action@v1
# with:
# flags: dashboards-notifications
# directory: OpenSearch-Dashboards/plugins/
# token: ${{ secrets.CODECOV_TOKEN }}
#
# - name: Upload Artifact
# uses: actions/upload-artifact@v1
# with:
# name: dashboards-notifications
# path: OpenSearch-Dashboards/plugins/dashboards-notifications/build