13
13
jobs :
14
14
tests :
15
15
name : Run Cypress E2E tests
16
- runs-on : ubuntu-latest
16
+ strategy :
17
+ matrix :
18
+ os : [ubuntu-latest, windows-latest]
19
+ include :
20
+ - os : windows-latest
21
+ cypress_cache_folder : ~/AppData/Local/Cypress/Cache
22
+ - os : ubuntu-latest
23
+ cypress_cache_folder : ~/.cache/Cypress
24
+ runs-on : ${{ matrix.os }}
17
25
env :
18
26
# prevents extra Cypress installation progress messages
19
27
CI : 1
@@ -25,55 +33,98 @@ jobs:
25
33
with :
26
34
# TODO: Parse this from security analytics plugin (https://github.com/opensearch-project/security-analytics/issues/170)
27
35
java-version : 11
36
+
37
+ - name : Enable longer filenames
38
+ if : ${{ matrix.os == 'windows-latest' }}
39
+ run : git config --system core.longpaths true
40
+
28
41
- name : Checkout security analytics
29
42
uses : actions/checkout@v2
30
43
with :
31
44
path : security-analytics
32
45
repository : opensearch-project/security-analytics
33
46
ref : ${{ env.SECURITY_ANALYTICS_BRANCH }}
47
+
34
48
- name : Run opensearch with plugin
35
49
run : |
36
50
cd security-analytics
37
51
./gradlew run -Dopensearch.version=${{ env.OPENSEARCH_VERSION }} &
38
52
sleep 300
39
- # timeout 300 bash -c 'while [[ "$(curl -s -o /dev/null -w ''%{http_code}'' localhost:9200)" != "200" ]]; do sleep 5; done'
40
- - name : Checkout Security Analytics Dashboards plugin
41
- uses : actions/checkout@v2
42
- with :
43
- path : security-analytics-dashboards-plugin
53
+ shell : bash
54
+
44
55
- name : Checkout OpenSearch-Dashboards
45
56
uses : actions/checkout@v2
46
57
with :
47
58
repository : opensearch-project/OpenSearch-Dashboards
48
59
path : OpenSearch-Dashboards
49
60
ref : ${{ env.OPENSEARCH_DASHBOARDS_VERSION }}
61
+
62
+ - name : Checkout Security Analytics Dashboards plugin
63
+ uses : actions/checkout@v2
64
+ with :
65
+ path : OpenSearch-Dashboards/plugins/security-analytics-dashboards-plugin
66
+
50
67
- name : Get node and yarn versions
51
68
id : versions
52
69
run : |
53
70
echo "::set-output name=node_version::$(node -p "(require('./OpenSearch-Dashboards/package.json').engines.node).match(/[.0-9]+/)[0]")"
54
71
echo "::set-output name=yarn_version::$(node -p "(require('./OpenSearch-Dashboards/package.json').engines.yarn).match(/[.0-9]+/)[0]")"
72
+
55
73
- name : Setup node
56
74
uses : actions/setup-node@v1
57
75
with :
58
76
node-version : ${{ steps.versions.outputs.node_version }}
59
77
registry-url : ' https://registry.npmjs.org'
78
+
60
79
- name : Install correct yarn version for OpenSearch-Dashboards
61
80
run : |
62
81
npm uninstall -g yarn
63
82
echo "Installing yarn ${{ steps.versions_step.outputs.yarn_version }}"
64
83
npm i -g yarn@${{ steps.versions.outputs.yarn_version }}
84
+
65
85
- name : Bootstrap plugin/OpenSearch-Dashboards
66
86
run : |
67
- mkdir -p OpenSearch-Dashboards/plugins
68
- mv security-analytics-dashboards-plugin OpenSearch-Dashboards/plugins
69
87
cd OpenSearch-Dashboards/plugins/security-analytics-dashboards-plugin
70
88
yarn osd bootstrap
89
+
71
90
- name : Run OpenSearch-Dashboards server
72
91
run : |
73
92
cd OpenSearch-Dashboards
74
93
yarn start --no-base-path --no-watch &
75
- sleep 300
76
- # timeout 300 bash -c 'while [[ "$(curl -s localhost:5601/api/status | jq -r '.status.overall.state')" != "green" ]]; do sleep 5; done'
94
+ shell : bash
95
+
96
+ # Window is slow so wait longer
97
+ - name : Sleep until OSD server starts - windows
98
+ if : ${{ matrix.os == 'windows-latest' }}
99
+ run : Start-Sleep -s 400
100
+ shell : powershell
101
+
102
+ - name : Sleep until OSD server starts - non-windows
103
+ if : ${{ matrix.os != 'windows-latest' }}
104
+ run : sleep 300
105
+ shell : bash
106
+
107
+ - name : Install Cypress
108
+ run : |
109
+ cd OpenSearch-Dashboards/plugins/security-analytics-dashboards-plugin
110
+ # This will install Cypress in case the binary is missing which can happen on Windows and Mac
111
+ # If the binary exists, this will exit quickly so it should not be an expensive operation
112
+ npx cypress install
113
+ shell : bash
114
+
115
+ - name : Get Cypress version
116
+ id : cypress_version
117
+ run : |
118
+ cd OpenSearch-Dashboards/plugins/security-analytics-dashboards-plugin
119
+ echo "::set-output name=cypress_version::$(cat ./package.json | jq '.dependencies.cypress' | tr -d '"')"
120
+
121
+ - name : Cache Cypress
122
+ id : cache-cypress
123
+ uses : actions/cache@v2
124
+ with :
125
+ path : ${{ matrix.cypress_cache_folder }}
126
+ key : cypress-cache-v2-${{ runner.os }}-${{ hashFiles('**/package.json') }}
127
+
77
128
# for now just chrome, use matrix to do all browsers later
78
129
- name : Cypress tests
79
130
uses : cypress-io/github-action@v2
@@ -82,15 +133,19 @@ jobs:
82
133
command : yarn run cypress run
83
134
wait-on : ' http://localhost:5601'
84
135
browser : chrome
136
+ env :
137
+ CYPRESS_CACHE_FOLDER : ${{ matrix.cypress_cache_folder }}
138
+
85
139
# Screenshots are only captured on failure, will change this once we do visual regression tests
86
140
- uses : actions/upload-artifact@v1
87
141
if : failure()
88
142
with :
89
- name : cypress-screenshots
143
+ name : cypress-screenshots-${{ matrix.os }}
90
144
path : OpenSearch-Dashboards/plugins/security-analytics-dashboards-plugin/cypress/screenshots
145
+
91
146
# Test run video was always captured, so this action uses "always()" condition
92
147
- uses : actions/upload-artifact@v1
93
148
if : always()
94
149
with :
95
- name : cypress-videos
150
+ name : cypress-videos-${{ matrix.os }}
96
151
path : OpenSearch-Dashboards/plugins/security-analytics-dashboards-plugin/cypress/videos
0 commit comments