-
Notifications
You must be signed in to change notification settings - Fork 0
257 lines (240 loc) · 10 KB
/
tests.yaml
File metadata and controls
257 lines (240 loc) · 10 KB
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
name: Test Workflow
on:
push:
paths-ignore:
- README.md
- CHANGELOG.md
branches:
- develop
pull_request:
types: [labeled, opened, synchronize, repoened]
paths-ignore:
- README.md
- CHANGELOG.md
branches:
- develop
- release
- main
jobs:
setup:
name: Setup Test Parallelization
runs-on: ubuntu-latest
if: github.event.pull_request.draft == false
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Calculate Test Sets
id: set-matrix
run: |
tot_lines=$(find tests/e2e -name "*.spec.ts" | wc -l)
echo "Found $tot_lines test suites"
lines=$(($tot_lines/4))
find tests/e2e -name "*.spec.ts" | split -l $lines -
if (($tot_lines % 4)) ;
then
matrix="{\"tests\": [\"$(cat xaa | tr '\n' ',')\", \"$(cat xab | tr '\n' ',')\", \"$(cat xac | tr '\n' ',')\", \"$(cat xad | tr '\n' ',')\", \"$(cat xae | tr '\n' ',')\"]}"
else
matrix="{\"tests\": [\"$(cat xaa | tr '\n' ',')\", \"$(cat xab | tr '\n' ',')\", \"$(cat xac | tr '\n' ',')\", \"$(cat xad | tr '\n' ',')\"]}"
fi
echo "Built matrix: $matrix"
echo "::set-output name=matrix::$( echo "$matrix" )"
api-dev:
name: API Tests Development Cluster
if: ${{ !contains(github.event.pull_request.labels.*.name, 'experimental') && github.event.pull_request.draft == false }}
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Create localhost certificate
run: mkdir certs/ && openssl req -x509 -nodes -days 1024 -newkey rsa:2048 -keyout certs/localhost.key -out certs/localhost.crt -extensions 'v3_req' -subj '/C=DE/ST=NRW/L=Paderborn/CN=localhost'
- name: Use Node.js
uses: actions/setup-node@v1
with:
node-version: '12.x'
- name: Cache node modules
uses: actions/cache@v2
env:
cache-name: cache-node-modules
with:
# npm cache files are stored in `~/.npm` on Linux/macOS
path: ~/.npm
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- name: Install dependencies
run: npm install
- name: Run unit tests
run: npm run test:unit
api-exp:
name: API Tests Experimental Cluster
if: ${{ contains(github.event.pull_request.labels.*.name, 'experimental') && github.event.pull_request.draft == false }}
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Create localhost certificate
run: mkdir certs/ && openssl req -x509 -nodes -days 1024 -newkey rsa:2048 -keyout certs/localhost.key -out certs/localhost.crt -extensions 'v3_req' -subj '/C=DE/ST=NRW/L=Paderborn/CN=localhost'
- name: Use Node.js
uses: actions/setup-node@v1
with:
node-version: '12.x'
- name: Cache node modules
uses: actions/cache@v2
env:
cache-name: cache-node-modules
with:
# npm cache files are stored in `~/.npm` on Linux/macOS
path: ~/.npm
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- name: Install dependencies
run: npm install
- name: Run unit tests
run: export TEST_ENV=experimental && npm run test:unit
e2e-dev:
name: E2E Tests Development Cluster
needs: setup
if: ${{ !contains(github.event.pull_request.labels.*.name, 'experimental') && github.event.pull_request.draft == false }}
runs-on: ubuntu-latest
timeout-minutes: 30
strategy:
fail-fast: false
matrix: ${{ fromJson(needs.setup.outputs.matrix) }}
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Export node conf
run: export NODE_TLS_REJECT_UNAUTHORIZED=0
- name: mkdir
run: mkdir -p certs/
- name: Create CA certificate
run: openssl req -x509 -newkey rsa:4096 -days 365 -nodes -keyout certs/ca-key.pem -out certs/ca-cert.pem -subj '/C=DE/ST=NRW/L=Paderborn/CN=ca-localhost'
- name: Create certificate request
run: openssl req -newkey rsa:4096 -nodes -keyout certs/server-key.pem -out certs/server-req.pem -subj '/C=DE/ST=NRW/L=Paderborn/CN=localhost'
- name: Sign certificate request
run: openssl x509 -req -in certs/server-req.pem -days 60 -CA certs/ca-cert.pem -CAkey certs/ca-key.pem -CAcreateserial -out certs/server-cert.pem
- name: Trust CA certificate
run: sudo cp certs/ca-cert.pem /usr/local/share/ca-certificates/ && sudo update-ca-certificates
- name: Use Node.js
uses: actions/setup-node@v1
with:
node-version: '12.x'
- name: Cache node modules
uses: actions/cache@v2
env:
cache-name: cache-node-modules
with:
# npm cache files are stored in `~/.npm` on Linux/macOS
path: ~/.npm
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- name: Install dependencies
run: npm ci
- name: Build server
run: export NODE_ENV=development && npm run build
- name: Copy nginx conf
run: mkdir -p temp && cp .github/nginx.conf temp/nginx.conf
- name: Run nginx to reverse proxy for e2e tests
run: docker run --name reverse-proxy -p 443:443 --mount type=bind,source=$(pwd)/temp/nginx.conf,target=/etc/nginx/nginx.conf --mount type=bind,source=$(pwd)/certs/,target=/etc/nginx/certs/ --mount type=bind,source=$(pwd)/dist/,target=/app/deploy -d nginx
- name: run e2e tests
run: npm run test:e2e:headless -- --spec ${{ matrix.tests }} --env NODE_ENV=development
- name: Upload Screenshots
uses: actions/upload-artifact@v1
if: failure()
with:
name: cypress-screenshots
path: cypress/screenshots
# Test run video was always captured, so this action uses "always()" condition
- name: Upload Videos
uses: actions/upload-artifact@v1
if: always()
with:
name: cypress-videos
path: cypress/videos
- name: Upload coverage report
uses: actions/upload-artifact@v1
if: always()
with:
name: code-coverage
path: coverage/lcov-report/
e2e-exp:
name: E2E Tests Experimental Cluster
needs: setup
if: ${{ contains(github.event.pull_request.labels.*.name, 'experimental') && github.event.pull_request.draft == false }}
runs-on: ubuntu-latest
timeout-minutes: 30
strategy:
fail-fast: false
matrix: ${{ fromJson(needs.setup.outputs.matrix) }}
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Export node conf
run: export NODE_TLS_REJECT_UNAUTHORIZED=0
- name: mkdir
run: mkdir -p certs/
- name: Create CA certificate
run: openssl req -x509 -newkey rsa:4096 -days 365 -nodes -keyout certs/ca-key.pem -out certs/ca-cert.pem -subj '/C=DE/ST=NRW/L=Paderborn/CN=ca-localhost'
- name: Create certificate request
run: openssl req -newkey rsa:4096 -nodes -keyout certs/server-key.pem -out certs/server-req.pem -subj '/C=DE/ST=NRW/L=Paderborn/CN=localhost'
- name: Sign certificate request
run: openssl x509 -req -in certs/server-req.pem -days 60 -CA certs/ca-cert.pem -CAkey certs/ca-key.pem -CAcreateserial -out certs/server-cert.pem
- name: Trust CA certificate
run: sudo cp certs/ca-cert.pem /usr/local/share/ca-certificates/ && sudo update-ca-certificates
- name: Use Node.js
uses: actions/setup-node@v1
with:
node-version: '12.x'
- name: Cache node modules
uses: actions/cache@v2
env:
cache-name: cache-node-modules
with:
# npm cache files are stored in `~/.npm` on Linux/macOS
path: ~/.npm
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
- name: Install dependencies
run: npm ci
- name: Build server
run: export NODE_ENV=experimental && npm run build
- name: Copy nginx conf
run: mkdir -p temp && cp .github/nginx.conf temp/nginx.conf
- name: Run nginx to reverse proxy for e2e tests
run: docker run --name reverse-proxy -p 443:443 --mount type=bind,source=$(pwd)/temp/nginx.conf,target=/etc/nginx/nginx.conf --mount type=bind,source=$(pwd)/certs/,target=/etc/nginx/certs/ --mount type=bind,source=$(pwd)/dist/,target=/app/deploy -d nginx
- name: run e2e tests
run: npm run test:e2e:headless -- --spec ${{ matrix.tests }} --env NODE_ENV=experimental
- name: Upload Screenshots
uses: actions/upload-artifact@v1
if: failure()
with:
name: cypress-screenshots
path: cypress/screenshots
# Test run video was always captured, so this action uses "always()" condition
- name: Upload Videos
uses: actions/upload-artifact@v1
if: always()
with:
name: cypress-videos
path: cypress/videos
- name: Upload coverage report
uses: actions/upload-artifact@v1
if: always()
with:
name: code-coverage
path: coverage/lcov-report/