-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy path.ci.yml
389 lines (350 loc) · 10.4 KB
/
.ci.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
image: $CI_REGISTRY_IMAGE:rdfm-ci-base-bookworm
.common_only: &common_only
only:
- main
- merge_requests
variables:
SSL_CERT_DIR: "certs"
PIP_CACHE_DIR: $CI_PROJECT_DIR/.cache/pip
GOROOT: ""
SCALENODE_CPU: 2
SCALENODE_RAM: 2048
SCALENODE_DISK: 20
.build-base:
variables:
JWT_SECRET: testsecret123123123
POSTGRES_MAJOR_VERSION: 15
before_script:
- python -V
- (apt update &&
apt-get -y install make netcat-openbsd openssl telnet uuid-runtime xxd postgresql-$POSTGRES_MAJOR_VERSION postgresql-contrib &&
service postgresql start &&
ln -s /usr/lib/postgresql/$POSTGRES_MAJOR_VERSION/bin/initdb /bin/initdb &&
ln -s /usr/lib/postgresql/$POSTGRES_MAJOR_VERSION/bin/postgres /bin/postgres)
- (cd server && poetry build && poetry install)
- (cd manager && poetry build && poetry install)
- (cd devices/linux-client && sudo make install)
- |
if [[ $(losetup --list | wc -l) == 0 ]]; then
dd if=/dev/zero of=blockfile bs=1M count=100
losetup /dev/loop0 blockfile
losetup /dev/loop1 blockfile
fi
- cp server/tests/etc_rdfm.conf /etc/rdfm/rdfm.conf
- cat /etc/rdfm/rdfm.conf
- (mkdir /var/lib/rdfm && cp server/tests/etc_rdfm.conf /var/lib/rdfm/rdfm.conf)
- |
echo "device_type=dummy" > /var/lib/rdfm/device_type
- chmod -R 777 /etc/rdfm
- chmod -R 777 /var/lib/rdfm
- server/tests/certgen.sh certs IP.1:127.0.0.1 DEVICE no
.build:
<<: *common_only
extends: .build-base
stages:
- docs-build
- docs-deploy
- build
- static-checks
- local-tests
build:
extends: .build-base
stage: build
script:
- echo "Build finished"
python-pycodestyle-check:
extends: .build
stage: static-checks
script:
- (cd server && poetry run test-pycodestyle)
- (cd manager && poetry run test-pycodestyle)
python-mypy-check:
extends: .build
stage: static-checks
script:
- (cd server && poetry run test-mypy)
- (cd manager && poetry run test-mypy)
allow_failure: true
test-package-api:
extends: .build
stage: local-tests
script:
- cd server
- poetry run pytest tests/test-packages.py
test-group-api:
extends: .build
stage: local-tests
script:
- cd server
- poetry run pytest tests/test-groups.py
test-server-update-policies:
extends: .build
stage: local-tests
script:
- cd server
- poetry run pytest tests/test-update-policies.py --sqlite
- poetry run pytest tests/test-update-policies.py --postgres
test-server-update-resolver:
extends: .build
stage: local-tests
script:
- cd server
- poetry run pytest tests/test-update-resolver.py
test-server-update-api:
extends: .build
stage: local-tests
script:
- cd server
- poetry run pytest tests/test-update-checker.py --sqlite
- poetry run pytest tests/test-update-checker.py --postgres
test-server-device-auth-api:
extends: .build
stage: local-tests
variables:
SCALENODE_RAM: 4096
script:
- cd server
- poetry run pytest tests/test-server-auth.py --sqlite
- poetry run pytest tests/test-server-auth.py --postgres
test-server-s3-storage:
extends: .build
stage: local-tests
script:
- cd server
- poetry run pytest tests/test-server-s3-storage.py
test-server-management-auth:
extends: .build
stage: local-tests
variables:
SCALENODE_RAM: 4096
script:
- cd server
- poetry run pytest tests/test-server-management-auth.py --sqlite
- poetry run pytest tests/test-server-management-auth.py --postgres
test-package-upload-auth:
extends: .build
stage: local-tests
variables:
SCALENODE_RAM: 4096
script:
- cd server
- poetry run pytest tests/test-package-upload-auth.py --sqlite
- poetry run pytest tests/test-package-upload-auth.py --postgres
test-server-route-correctness:
extends: .build
stage: local-tests
script:
- cd server
- poetry run pytest tests/test-server-route-correctness.py
test-server-websocket:
extends: .build
stage: local-tests
script:
- cd server
- poetry run pytest tests/test-server-ws.py --sqlite
- poetry run pytest tests/test-server-ws.py --postgres
test-manager:
extends: .build
stage: local-tests
variables:
SCALENODE_RAM: 4096
script:
- cd server
- poetry run pytest tests/test-manager.py --sqlite
- poetry run pytest tests/test-manager.py --postgres
test-server-stress:
extends: .build
stage: local-tests
variables:
SCALENODE_CPU: 8
SCALENODE_RAM: 32768
script:
- cd server
- poetry run pytest tests/test-stress.py -vs
artifacts:
paths:
- server/tests/logs/*
when: always
test-server-logs:
extends: .build
stage: local-tests
script:
- cd server
- poetry run pytest tests/test-server-logs.py --sqlite
- poetry run pytest tests/test-server-logs.py --postgres
# ===== rdfm-client ===== #
build-rdfm-client:
stage: build
script:
- cd devices/linux-client
- make
test-rdfm-client:
stage: local-tests
<<: *common_only
script:
# Build and install rdfm-artifact, which is required for the tests
- cd tools/rdfm-artifact
- make
- make install
- cd ../../devices/linux-client
- make test
test-rdfm-client-docker:
stage: local-tests
<<: *common_only
script:
- export PATH=$HOME/go/bin/:$PATH
# Build and install rdfm-artifact, which is required for the tests
- cd tools/rdfm-artifact
- make
- make install
- cd ../../devices/linux-client
# The tests are running in a Docker container, install and set up
# the Docker daemon
- apt update
- apt -qq -y --no-install-recommends install docker.io cgroupfs-mount crun fuse-overlayfs pigz ca-certificates
- cgroupfs-mount
- ../../common/docker/start-docker.sh
# HACK: For CI runs, we have to replace the -it flag in docker run
# as this is not a real terminal.
# HACK: We also comment out git invocations, as only a subfolder is mounted
# in the container, which would cause that call to fail. This is fine,
# as the invocation is only required when container UID != source UID
# (i.e, not in CI runs, where we run everything as root).
- sed -i "s/\-it//g" ./scripts/test-docker/test-artifact-info.sh
- sed -i "s/git/#git/g" ./scripts/test-docker/data/check-artifact-info.sh
- sed -i "s/\-it//g" ./scripts/test-docker/test-deltas.sh
- sed -i "s/git/#git/g" ./scripts/test-docker/data/check-delta-patching.sh
- sed -i "s/\-it//g" ./scripts/test-docker/test-delta-over-http.sh
# Run rdfm-client Docker tests
- ./scripts/test-docker/test-artifact-info.sh
- cd scripts/test-docker/
- ./make-delta-samples.sh
- cd ../../
- ./scripts/test-docker/test-deltas.sh
- ./scripts/test-docker/test-delta-over-http.sh
# ===== rdfm-mcumgr-client ===== #
build-mcumgr-client:
stage: build
before_script:
# Currently CI ships Go 1.19, while the client needs 1.22+
- wget --quiet -O - "https://go.dev/dl/go1.22.3.linux-amd64.tar.gz" | tar xz
script:
- export PATH=`pwd`/go/bin:$PATH
- make -C devices/mcumgr-client
artifacts:
expire_in: 1 day
paths:
- devices/mcumgr-client/rdfm-mcumgr-client
build-mcumgr-test-samples:
variables:
SCALENODE_CPU: 4
SCALENODE_RAM: 8192
ZEPHYR_WORKSPACE: $CI_PROJECT_DIR/zephyr
ZEPHYR_BASE: $CI_PROJECT_DIR/zephyr/zephyr
ZEPHYR_SDK_INSTALL_DIR: $CI_PROJECT_DIR/zephyr/sdk
<<: *common_only
stage: build
before_script:
- apt update
- apt -qqy --no-install-recommends install cmake device-tree-compiler ninja-build
script:
- ./devices/mcumgr-client/tests/build/build_samples.sh
- ls -la ./devices/mcumgr-client/tests/out/
artifacts:
expire_in: 1 day
paths:
- devices/mcumgr-client/tests/out
test-mcumgr-client:
variables:
SCALENODE_CPU: 4
SCALENODE_RAM: 6144
SCALENODE_DISK: 10
<<: *common_only
dependencies:
- build-mcumgr-client
- build-mcumgr-test-samples
- build-rdfm-artifact
stage: local-tests
script:
- set -eo pipefail
- apt update && apt -qqy --no-install-recommends install iproute2 git-lfs >/dev/null
# NOTE: Currently Renode is tracked using LFS since we're using a custom
# build with support for both STM32F764 and NRF52840 flash controllers.
# If they get added into main, this can be replaced with official release
# `wget --quiet https://builds.renode.io/renode_1.X.Y_amd64.deb`
- git lfs pull && apt -qqy --no-install-recommends install ./devices/mcumgr-client/tests/prebuilt/renode*.deb >/dev/null
- mv tools/rdfm-artifact/rdfm-artifact /usr/bin/
- mv devices/mcumgr-client/rdfm-mcumgr-client /usr/bin/
- pushd server && pip3 install -e . && popd
- pushd manager && pip3 install -e . && popd
- cd devices/mcumgr-client
# Run the test
- ./tests/end2end/test.sh
# ===== rdfm-artifact ===== #
.rdfm-artifact:
before_script:
- export PATH=$HOME/go/bin/:$PATH
build-rdfm-artifact:
extends: .rdfm-artifact
stage: build
script:
- cd tools/rdfm-artifact
- make
artifacts:
paths:
- tools/rdfm-artifact/rdfm-artifact
test-rdfm-artifact:
extends: .rdfm-artifact
<<: *common_only
stage: local-tests
script:
- cd tools/rdfm-artifact
- make test
# ===== rdfm-frontend ===== #
build-rdfm-frontend:
image: node:20
stage: static-checks
<<: *common_only
script:
- cd frontend
- npm install
- npm run format-check
- npm run build
artifacts:
paths:
- frontend/dist
# ===== documentation ===== #
docs-build:
stage: docs-build
<<: *common_only
before_script:
# Disable venvs and just install everything globally
# The server module must be accessible by Sphinx to
# properly autogenerate API documentation
- poetry config virtualenvs.create false
# Install doc building requirements
- pip3 install -r documentation/requirements.txt
# Build and install the server
- (cd server/ && poetry build --verbose && poetry install --verbose && pip3 install --verbose -e .)
script:
- cd documentation/
- make html latexpdf
- cp build/latex/*.pdf build/html/
# Make sure the docs archive lands in the root of the repository
- tar cf ../$CI_DOCS_ARCHIVE -C build/html/ .
artifacts:
paths:
- documentation/build
- $CI_DOCS_ARCHIVE
docs-deploy:
variables:
GIT_STRATEGY: none
<<: *common_only
dependencies:
- docs-build
stage: docs-deploy
tags: ["docs"]
script: echo 'Deploying docs'
artifacts:
paths:
- $CI_DOCS_ARCHIVE