-
Notifications
You must be signed in to change notification settings - Fork 1
428 lines (364 loc) · 12.4 KB
/
test.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
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
name: Test
on:
push:
branches-ignore:
- "main"
tags-ignore:
- "**"
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.ref_name }}
cancel-in-progress: true
jobs:
run-adminUi-checks:
runs-on: ubuntu-latest
name: Run Admin UI Checks
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Run Checks
run: ./.ci/aui/runChecks.sh
run-adminUi-flutter-checks:
runs-on: ubuntu-latest
name: Run Admin UI Flutter Checks
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Flutter
uses: subosito/[email protected]
- name: Run checks
run: ./.ci/aui/runFlutterChecks.sh
check-formatting:
runs-on: ubuntu-latest
name: Check Formatting
steps:
- name: Checkout
uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: latest
cache: "npm"
cache-dependency-path: "**/package.json"
- name: Cache npm dependencies
uses: actions/cache@v4
with:
path: |
./runtime/node_modules
key: ${{ runner.os }}-npm-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-npm-
- name: Install script dependencies
run: npm install --prefix ./.ci
- name: Setup dotnet
uses: actions/setup-dotnet@v4
with:
dotnet-version: "8.0.x"
- name: Cache NuGet packages
uses: actions/cache@v4
with:
path: ~/.nuget/packages
key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj') }}
restore-keys: ${{ runner.os }}-nuget-
- name: Check formatting
run: ./.ci/checkFormatting.sh
unit-test:
runs-on: ubuntu-latest
name: Run Unit Tests
steps:
- name: Checkout
uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: latest
cache: "npm"
cache-dependency-path: "**/package.json"
- name: Cache npm dependencies
uses: actions/cache@v4
with:
path: |
./runtime/node_modules
key: ${{ runner.os }}-npm-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-npm-
- name: Install script dependencies
run: npm install --prefix ./.ci
- name: Setup dotnet
uses: actions/setup-dotnet@v4
with:
dotnet-version: "8.0.x"
- name: Cache NuGet packages
uses: actions/cache@v4
with:
path: ~/.nuget/packages
key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj') }}
restore-keys: ${{ runner.os }}-nuget-
- name: Run tests
run: ./.ci/test.sh
env:
DOTNET_CONSOLE_ANSI_COLOR: true
image-test-builds:
name: Build ${{matrix.image}} Image
runs-on: ubuntu-latest
strategy:
matrix:
include:
- dockerfile: ConsumerApi/Dockerfile
image: consumer-api
- dockerfile: AdminApi/src/AdminApi/Dockerfile
image: admin-ui
- dockerfile: Modules/Devices/src/Devices.AdminCli/Dockerfile
image: admin-cli
- dockerfile: DatabaseMigrator/Dockerfile
image: database-migrator
- dockerfile: EventHandlerService/src/EventHandlerService/Dockerfile
image: event-handler-service
- dockerfile: Modules/Files/src/Files.Jobs.SanityCheck/Dockerfile
image: files-sanity-check
- dockerfile: Jobs/src/Job.IdentityDeletion/Dockerfile
image: identity-deletion-jobs
- dockerfile: SseServer/src/SseServer/Dockerfile
image: sse-server
steps:
- name: Checkout
uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: latest
cache: "npm"
cache-dependency-path: "**/package-lock.json"
- name: Setup Docker
uses: docker/setup-buildx-action@v3
with:
driver: docker-container
- name: Setup NuGet
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.x
- name: Cache Image
uses: actions/cache@v4
with:
path: /tmp/.buildx-${{ matrix.image }}-cache
key: buildx-${{ matrix.image }}-cache-${{ hashFiles(matrix.dockerfile) }}
restore-keys: |
buildx-${{ matrix.image }}-cache-
- name: Install script dependencies
run: npm install --prefix ./.ci
- name: Build Image
uses: docker/build-push-action@v6
env:
DOCKER_BUILD_NO_SUMMARY: true
with:
context: .
file: ${{ matrix.dockerfile }}
cache-from: type=local,src=/tmp/.buildx-${{ matrix.image }}-cache
cache-to: type=local,mode=max,dest=/tmp/.buildx-${{ matrix.image }}-cache-new
outputs: type=docker,dest=/tmp/${{ matrix.image }}.tar
tags: ${{ matrix.image }}:0.0.1
- name: Upload artifact
uses: actions/upload-artifact@v4
with:
name: docker-${{ matrix.image }}
path: /tmp/${{ matrix.image }}.tar
retention-days: 1
# Temp fix
# https://github.com/docker/build-push-action/issues/252
# https://github.com/moby/buildkit/issues/1896
- name: Move cache
run: |
rm -rf /tmp/.buildx-${{ matrix.image }}-cache
mv /tmp/.buildx-${{ matrix.image }}-cache-new /tmp/.buildx-${{ matrix.image }}-cache
integration-test-sqlserver:
name: Run Integration Tests (on SQL Server)
runs-on: ubuntu-latest
needs: image-test-builds
steps:
- name: Checkout
uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: latest
cache: "npm"
cache-dependency-path: "**/package-lock.json"
- name: Setup NuGet
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.x
- name: Install script dependencies
run: npm install --prefix ./.ci
- name: Download cached Docker images
uses: actions/download-artifact@v4
with:
path: /tmp
pattern: docker-*
merge-multiple: true
- name: Load Docker images
run: ./.ci/loadDockerImages.sh
- name: Run integration tests
run: ./.ci/integrationTest.sqlserver.sh
- name: Save Docker Logs
if: failure()
run: docker compose -f ./.ci/docker-compose.test.yml -f ./.ci/docker-compose.test.sqlserver.yml logs > docker-log.txt
- name: Archive logs
if: failure()
uses: actions/upload-artifact@v4
with:
name: integration-test-sqlserver-docker-logs
path: docker-log.txt
env:
DOTNET_CONSOLE_ANSI_COLOR: true
integration-test-postgres:
name: Run Integration Tests (on Postgres)
runs-on: ubuntu-latest
needs: image-test-builds
steps:
- name: Checkout
uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: latest
cache: "npm"
cache-dependency-path: "**/package-lock.json"
- name: Setup NuGet
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.x
- name: Install script dependencies
run: npm install --prefix ./.ci
- name: Download cached Docker images
uses: actions/download-artifact@v4
with:
path: /tmp
pattern: docker-*
merge-multiple: true
- name: Load Docker images
run: ./.ci/loadDockerImages.sh
- name: Run integration tests
run: ./.ci/integrationTest.postgres.sh
- name: Save Docker Logs
if: failure()
run: docker compose -f ./.ci/docker-compose.test.yml -f ./.ci/docker-compose.test.postgres.yml logs > docker-log.txt
- name: Archive logs
if: failure()
uses: actions/upload-artifact@v4
with:
name: integration-test-postgres-docker-logs
path: docker-log.txt
env:
DOTNET_CONSOLE_ANSI_COLOR: true
transport-test-sqlserver:
name: Run transport Tests (on SQL Server)
runs-on: ubuntu-latest
needs: image-test-builds
steps:
- name: Checkout backbone repository
uses: actions/checkout@v4
with:
path: backbone
- name: Checkout runtime repository
uses: actions/checkout@v4
with:
repository: nmshd/runtime
path: runtime
ref: release/v5
- uses: actions/setup-node@v4
with:
node-version: latest
cache: "npm"
cache-dependency-path: "**/package-lock.json"
- name: Download cached Docker images
uses: actions/download-artifact@v4
with:
path: /tmp
pattern: docker-*
merge-multiple: true
- name: Load Docker images
run: ./backbone/.ci/loadDockerImages.sh
- name: Run Consumer API & Admin API
run: docker compose -f ./backbone/.ci/docker-compose.test.yml -f ./backbone/.ci/docker-compose.test.sqlserver.yml up -d --no-build
- name: Install runtime dependencies
working-directory: ./runtime
run: npm install
- name: Run transport Tests
working-directory: ./runtime/packages/transport
env:
NMSHD_TEST_BASEURL: http://localhost:5000
NMSHD_TEST_CLIENTID: test
NMSHD_TEST_CLIENTSECRET: test
NMSHD_TEST_BASEURL_ADMIN_API: http://localhost:5173
NMSHD_TEST_ADMIN_API_KEY: test
run: npm run test:local:lokijs
- name: Save Docker Logs
if: failure()
run: docker compose -f ./backbone/.ci/docker-compose.test.yml -f ./backbone/.ci/docker-compose.test.sqlserver.yml logs > docker-log.txt
- name: Archive logs
if: failure()
uses: actions/upload-artifact@v4
with:
name: transport-test-sqlserver-docker-logs
path: docker-log.txt
- name: Stop Consumer API
run: docker compose -f ./backbone/.ci/docker-compose.test.yml -f ./backbone/.ci/docker-compose.test.sqlserver.yml down
transport-test-postgres:
name: Run transport Tests (on Postgres)
runs-on: ubuntu-latest
needs: image-test-builds
steps:
- name: Checkout backbone repository
uses: actions/checkout@v4
with:
path: backbone
- name: Checkout runtime repository
uses: actions/checkout@v4
with:
repository: nmshd/runtime
path: runtime
ref: release/v5
- uses: actions/setup-node@v4
with:
node-version: latest
cache: "npm"
cache-dependency-path: "**/package-lock.json"
- name: Download cached Docker images
uses: actions/download-artifact@v4
with:
path: /tmp
pattern: docker-*
merge-multiple: true
- name: Load Docker images
run: ./backbone/.ci/loadDockerImages.sh
- name: Run Consumer API & Admin API
run: docker compose -f ./backbone/.ci/docker-compose.test.yml -f ./backbone/.ci/docker-compose.test.postgres.yml up -d --no-build
- name: Install runtime dependencies
working-directory: ./runtime
run: npm install
- name: Run transport Tests
working-directory: ./runtime/packages/transport
env:
NMSHD_TEST_BASEURL: http://localhost:5000
NMSHD_TEST_CLIENTID: test
NMSHD_TEST_CLIENTSECRET: test
NMSHD_TEST_BASEURL_ADMIN_API: http://localhost:5173
NMSHD_TEST_ADMIN_API_KEY: test
run: npm run test:local:lokijs
- name: Save Docker Logs
if: failure()
run: docker compose -f ./backbone/.ci/docker-compose.test.yml -f ./backbone/.ci/docker-compose.test.postgres.yml logs > docker-log.txt
- name: Archive logs
if: failure()
uses: actions/upload-artifact@v4
with:
name: transport-test-postgres-docker-logs
path: docker-log.txt
- name: Stop Consumer API
run: docker compose -f ./backbone/.ci/docker-compose.test.yml -f ./backbone/.ci/docker-compose.test.postgres.yml down
build-helm-chart:
name: Build Helm Chart
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Install script dependencies
run: npm install --prefix ./.ci
- name: Build Helm Chart
run: ./.ci/helm/buildChart.js
env:
VERSION: 0.0.0