-
Notifications
You must be signed in to change notification settings - Fork 1
357 lines (311 loc) · 11.3 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
name: Test
on:
push:
branches-ignore:
- "main"
tags-ignore:
- "**"
concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.ref_name }}
cancel-in-progress: true
jobs:
adminui-checks:
runs-on: ubuntu-latest
name: Run Admin UI Checks
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Flutter
uses: subosito/[email protected]
- name: Run checks
run: ./.ci/aui/runChecks.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: 22.4.1
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: Setup dotnet
uses: actions/setup-dotnet@v4
with:
dotnet-version: "8.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: 22.4.1
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: Setup dotnet
uses: actions/setup-dotnet@v4
with:
dotnet-version: "8.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:
fail-fast: false
matrix:
include:
- dockerfile: Applications/ConsumerApi/src/Dockerfile
image: consumer-api
- dockerfile: Applications/AdminApi/src/AdminApi/Dockerfile
image: admin-ui
- dockerfile: Applications/AdminCli/src/AdminCli/Dockerfile
image: admin-cli
- dockerfile: Applications/DatabaseMigrator/src/DatabaseMigrator/Dockerfile
image: database-migrator
- dockerfile: Applications/EventHandlerService/src/EventHandlerService/Dockerfile
image: event-handler-service
- dockerfile: Applications/FilesSanityCheck/src/FilesSanityCheck/Dockerfile
image: files-sanity-check
- dockerfile: Applications/IdentityDeletionJobs/src/Job.IdentityDeletion/Dockerfile
image: identity-deletion-jobs
- dockerfile: Applications/SseServer/src/SseServer/Dockerfile
image: sse-server
steps:
- name: Checkout
uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 22.4.1
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: Build Image
uses: docker/build-push-action@v6
env:
DOCKER_BUILD_SUMMARY: false
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:
name: Run ${{matrix.test-project.display-name}} Integration Tests (on ${{matrix.database}})
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
database: [sqlserver, postgres]
test-project:
- display-name: admin-api
path: Applications/AdminApi/test/AdminApi.Tests.Integration
- display-name: consumer-api
path: Applications/ConsumerApi/test/ConsumerApi.Tests.Integration
- display-name: identity-deletion-job
path: Applications/IdentityDeletionJobs/test/Job.IdentityDeletion.Tests.Integration
needs: image-test-builds
steps:
- name: Checkout
uses: actions/checkout@v4
- uses: actions/setup-node@v4
with:
node-version: 22.4.1
cache: "npm"
cache-dependency-path: "**/package-lock.json"
- name: Setup NuGet
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.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: Download cached Docker images
uses: actions/download-artifact@v4
with:
path: /tmp
pattern: docker-*
merge-multiple: true
- name: Load Docker images and build test code
run: |
{
./.ci/loadDockerImages.sh
} &
{
# The following two lines are for the identity deletion job only
mv appsettings.override.json appsettings.override.json.bak
cp .ci/appsettings.override.${{matrix.database}}.local.json appsettings.override.json
dotnet restore ${{matrix.test-project.path}}
dotnet build --no-restore ${{matrix.test-project.path}}
}
wait
- name: Start compose stack
run: |
docker compose -f ./.ci/compose.test.yml -f ./.ci/compose.test.${{matrix.database}}.yml down -v
docker compose -f ./.ci/compose.test.yml -f ./.ci/compose.test.${{matrix.database}}.yml up --no-build --wait -d
- name: Run integration tests
run: dotnet test --no-restore --no-build --logger "GitHubActions;summary.includeNotFoundTests=false;summary.includeSkippedTests=false;summary.includePassedTests=false" ${{matrix.test-project.path}}
env:
ADMIN_API_BASE_ADDRESS: "http://localhost:5173"
CONSUMER_API_BASE_ADDRESS: "http://localhost:5000"
- name: Save Docker Logs
if: failure()
run: docker compose -f ./.ci/compose.test.yml -f ./.ci/compose.test.${{matrix.database}}.yml logs > logs.txt
- name: Archive logs
if: failure()
uses: actions/upload-artifact@v4
with:
name: ${{matrix.test-project.display-name}}-${{matrix.database}}
path: logs.txt
transport-test:
name: Run transport Tests (on ${{matrix.database}})
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
database: [sqlserver, postgres]
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
- uses: actions/setup-node@v4
with:
node-version: 22.4.1
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: Start compose stack
run: docker compose -f ./backbone/.ci/compose.test.yml -f ./backbone/.ci/compose.test.${{matrix.database}}.yml up --no-build --wait -d
- name: Install runtime dependencies
working-directory: ./runtime
run: npm ci
- name: Build
run: npm run build:node
working-directory: ./runtime
- 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/compose.test.yml -f ./backbone/.ci/compose.test.${{matrix.database}}.yml logs > logs.txt
- name: Archive logs
if: failure()
uses: actions/upload-artifact@v4
with:
name: transport-test-${{matrix.database}}-docker-logs
path: logs.txt
- name: Stop compose stack
run: docker compose -f ./backbone/.ci/compose.test.${{matrix.database}}.yml -f ./backbone/.ci/compose.test.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
validate-licenses:
name: Validate Open Source Licenses
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Dotnet
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.x
- name: Install nuget-licenses tool
run: dotnet tool install --global nuget-license
- name: Show Allowed Licenses
run: cat ./.ci/allowedLicenses.json
- name: Show Ignored Packages
run: cat ./.ci/ignoredPackages.json
- name: Restore Solution
run: dotnet restore /p:ContinuousIntegrationBuild=true ./Backbone.sln
- name: Validate Licenses
run: nuget-license --input ./Backbone.sln --allowed-license-types ./.ci/allowedLicenses.json --ignored-packages ./.ci/ignoredPackages.json --output table --error-only