-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.gitlab-ci.yml
499 lines (460 loc) · 17.3 KB
/
.gitlab-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
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
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
# Continuous Integration configuration with gitlab.com
# See https://gitlab.com/help/ci/yaml/README.md
#########################################################
# Default CI pipeline configuration:
# - preset variables: 'WITH_NANO_EXTENDED = 1' set in gitlab project
# - jobs run in stages:
# - gen: generation job
# - build: build-linux64-ASan
# - tests:
# - test-check
# - test-unit
# - test-uactt
#
# CI pipeline manual run with 'ALL_TESTS = 1':
# - preset variables: 'WITH_NANO_EXTENDED = 1' set in gitlab project
# - jobs run in stages:
# - build: build-linux64-pys2opc # 'WITH_ASAN = 0' and 'WITH_PYS2OPC = 1'
# - tests: # TEST_SERVER_XML_ADDRESS_SPACE and TEST_SERVER_XML_CONFIG set to use dynamic config
# - test-unit-all-tests
# - test-uactt-all-tests
#
# CI pipeline manual run with 'ALL_BUILDS = 1':
# - preset variables: WITH_NANO_EXTENDED = 1 set in gitlab project
# - jobs run in stages:
# - gen: generation job
# - build: # 'WITH_STATIC_SECURITY_DATA: 1', 'WITH_CONST_ADDSPACE: 1' and 'PUBSUB_STATIC_CONFIG: 1'
# - build-linux64-static-conf
# - tests:
# - test-unit
# - build-others:
# - build-win32
# - build-win64
# - windows-appveyor
#
# CI pipeline manual run with 'WINDOWS_TEST = 1':
# - jobs run in stages:
# - build-others:
# - windows-appveyor
#
# CI pipeline manual run with 'CROSS_COMPILE = 1':
# - jobs run in stages:
# - build-others:
# - build-win32
# - build-win64
#########################################################
# Variables for ALL_BUILDS and ALL_TESTS manual pipelines
.variables: &all-tests_build_variables
WITH_PYS2OPC: 1
.variables: &all-tests_test_variables
TEST_SERVER_XML_ADDRESS_SPACE: S2OPC_Test_NodeSet.xml
TEST_SERVER_XML_CONFIG: S2OPC_Server_UACTT_Config.xml
TEST_USERS_XML_CONFIG: S2OPC_UACTT_Users.xml
.variables: &all-builds_build_variables
WITH_STATIC_SECURITY_DATA: 1
WITH_CONST_ADDSPACE: 1
PUBSUB_STATIC_CONFIG: 1
stages:
- gen
- build
- test
- build-others
- analyses
- doc
# Avoid to run 2 pipelines in case of MR
# (1 for branch and 1 for MR)
workflow:
rules:
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
- if: '$CI_PIPELINE_SOURCE == "schedule"'
- if: '$CI_PIPELINE_SOURCE == "web"'
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
- if: '$CI_COMMIT_BRANCH && $CI_OPEN_MERGE_REQUESTS'
when: never
- if: '$CI_COMMIT_BRANCH'
.docker-job: &docker_job
tags:
- docker
- linux
.zephyr-job: &zephyr_job
tags:
- zephyr
###
# Generation jobs
###
generation:
<<: *docker_job
stage: gen
image: com.systerel.fr:5000/c765/gen-ext@sha256:29c8f93dfce606b86133605ee367c14e3b4b978eebe4181e42e9b826db06b06c # digest of gen-ext:1.3
script:
- ./clean.sh all
- ./.validates_xml_schemas.sh
- ./.pre-build-ext.sh
- ./.check_generated_code.sh
artifacts:
name: 'bgenc-${CI_COMMIT_REF_SLUG}_${CI_COMMIT_SHA}'
paths:
- 'pre-build.log'
when: always
expire_in: '1 month'
when: always
rules:
- if: "$NO_GEN == null && \
$WINDOWS_TEST == null && \
$CROSS_COMPILE == null && \
$S2OPC_PUBSUB_ONLY == null &&\
$ALL_BUILDS == null && \
$ALL_TESTS == null && \
$WITH_DOC == null"
when: on_success
###
# Compilation jobs
###
.build-linux: &build_linux
<<: *docker_job
stage: build
image: registry.gitlab.com/systerel/s2opc/build@sha256:0f38c91390138ec7da5e1878b72ad6ca1fb306300bb9a5f838a16a45ef52d65a # digest of build:1.28
script:
- &build_command_line './build.sh && cd $BUILD_DIR && cmake --build . --target install || exit 1'
variables: &build_linux_variables
CMAKE_INSTALL_PREFIX: '../install_linux64'
DOCKER_IMAGE: 'sha256:12eae257acf165e632233b1903ac84e8236c050be032b7e84b14f1f8344d0119'
BUILD_DIR: build
artifacts:
name: 'bin-${CI_COMMIT_REF_SLUG}_${CI_COMMIT_SHA}'
paths:
- '*.log'
- 'install_linux64/'
- 'build/' # Required by tests / coverage
expire_in: '1 month'
when: always
# Common rules overwritten by each job using this template
# rules: # note: should be repeated in each child job of *build_linux
# - if: "$WINDOWS_TEST == null && $CROSS_COMPILE == null && $WITH_COVERITY == null && $WITH_DOC == null"
# when: on_success
# Used by "normal" pipeline
build-linux64-ASan:
<<: *build_linux
variables:
<<: *build_linux_variables
WITH_ASAN: 1
WITH_UBSAN: 1
rules: # 1st line repeat .build-linux + added rules to avoid ASAN build
- if: "$WINDOWS_TEST == null && $CROSS_COMPILE == null && \
$WITH_COVERITY == null && $WITH_COVERAGE == null && $WITH_DOC == null && \
$NO_ASAN == null && $ALL_TESTS == null && $ALL_BUILDS == null" # avoid ASAN build in most of nightly builds
when: on_success
# Used by all-tests pipeline (add tests which needs NO_ASAN)
build-linux64-pys2opc:
<<: *build_linux
variables:
<<: *build_linux_variables
<<: *all-tests_build_variables # add pys2opc
rules: # do not repeat .build-linux: due to disjunction + need only those 2 conditions
- if: "$ALL_TESTS != null || $NO_ASAN != null && $WITH_NANO_EXTENDED == '1'" # if ASAN is deactivated build PyS2OPC by default (exclude nano scope: see TODO below)
when: on_success
# Used when ALL_BUILDS set (tests use static configuration)
build-linux64-static-conf:
<<: *build_linux
variables:
<<: *build_linux_variables
<<: *all-builds_build_variables # add static conf
rules: # single case rule of ALL_BUILDS
- if: "$ALL_BUILDS != null"
when: on_success
build-linux64-NoASan-NoPyS2OPC:
<<: *build_linux
variables:
<<: *build_linux_variables
rules: # In case of coverage analysis or when nano scope is used (TODO: PyS2OPC shall be built but tests will fail: use another server with subscription in tests)
- if: "$WITH_COVERAGE != null || $NO_ASAN != null && $WITH_NANO_EXTENDED != '1'"
when: on_success
build-win64: &build_win64
<<: *docker_job
stage: build-others
image: registry.gitlab.com/systerel/s2opc/mingw_build@sha256:6d6f54912b5a6b6e3b4d0815c64d8975a72673224a77fd70bef5ed35571c153d # digest of mingw_build:1.13
script:
# Manually disable PyS2OPC for windows cross builds. When set in "variables:", the value is overwritten.
- 'export WITH_PYS2OPC=OFF'
- *build_command_line
variables: &build_win64_variables
CMAKE_INSTALL_PREFIX: '../install_win64'
CMAKE_C_FLAGS: '-D__USE_MINGW_ANSI_STDIO=0 -DWARNINGS_AS_ERRORS=0' # deactivate warnings as errors because of string format issues
CMAKE_TOOLCHAIN_FILE: 'toolchain-mingw32-w64_x86_64.cmake'
DOCKER_IMAGE: 'sha256:4edcdfff072522487730fb268bf834438d47a8fc5e662e5ac7868c4ecb367dcb'
BUILD_DIR: build_toolchain
S2OPC_CLIENTSERVER_ONLY: 1 # PubSub is not compatible with windows platform
artifacts:
name: 'bin-w64-${CI_COMMIT_REF_SLUG}_${CI_COMMIT_SHA}'
paths:
- '$BUILD_DIR/bin'
- 'install_win64/'
expire_in: '1 month'
rules:
- if: "$CROSS_COMPILE != null || $ALL_BUILDS != null || $CI_PIPELINE_SOURCE == 'merge_request_event'"
when: always # run even if previous job in pipeline failed
build-win32:
<<: *build_win64
variables:
<<: *build_win64_variables
CMAKE_INSTALL_PREFIX: '../install_win32'
CMAKE_TOOLCHAIN_FILE: 'toolchain-mingw32-w64.cmake'
artifacts:
name: 'bin-w32-${CI_COMMIT_REF_SLUG}_${CI_COMMIT_SHA}'
paths:
- '$BUILD_DIR/bin/'
- 'install_win32/'
expire_in: '1 month'
rules:
- if: "$CROSS_COMPILE != null || $ALL_BUILDS != null || $CI_PIPELINE_SOURCE == 'merge_request_event'"
when: always # run even if previous job in pipeline failed
build-rpi:
<<: *docker_job
stage: build-others
image: registry.gitlab.com/systerel/s2opc/rpi-build@sha256:977b5d7083659af98a6279ee12d7d3ca1c94195b8b954c72c605a22386446a7c # digest of rpi-build:1.4
script:
- *build_command_line
variables:
CMAKE_INSTALL_PREFIX: '../install_rpi'
CMAKE_TOOLCHAIN_FILE: '/toolchain-rpi.cmake'
DOCKER_IMAGE: 'sha256:1d0eb4c4f99214faf186b4af677f138ef6e01945053e1b7533c99edfdf469f0f'
BUILD_SHARED_LIBS: 'true'
BUILD_DIR: build_toolchain
artifacts:
name: 'bin-rpi-${CI_COMMIT_REF_SLUG}_${CI_COMMIT_SHA}'
paths:
- '$BUILD_DIR/bin'
- 'install_rpi/'
expire_in: '1 month'
rules:
- if: "$CROSS_COMPILE != null || $ALL_BUILDS != null || $CI_PIPELINE_SOURCE == 'merge_request_event'"
when: always # run even if previous job in pipeline failed
# Used by coverity, also starts the analysis
build-linux64-coverity:
<<: *docker_job
stage: build
image: registry.gitlab.com/systerel/s2opc/coverity@sha256:2772b9557756c77517217bef69386b4415b6c6a5cf443f42050f08e9ab5c1529 # digest of coverity:1.6
script: |-
mkdir build
cd build
cmake -DWITH_COVERITY=1 -DCMAKE_BUILD_TYPE=Debug -DWITH_NANO_EXTENDED=1 ..
/opt/cov-analysis-linux64-2021.12.1/bin/cov-build --dir cov-int make
tar czf cov-int.tar.gz cov-int
curl -k --form token=${COVERITY_TOKEN} --form email=${COVERITY_EMAIL} --form version=${CI_COMMIT_REF_SLUG}_${CI_COMMIT_SHA} --form description=${CI_COMMIT_REF_SLUG}_${CI_COMMIT_SHA} --form [email protected] https://scan.coverity.com/builds?project=S2OPC
rules:
- if: "$WITH_COVERITY != null"
build-zephyr:
<<: *zephyr_job
stage: build-others
image: registry.gitlab.com/systerel/s2opc/zephyr_build@sha256:9808bec78b1f86bf747734b9f6893643a4090dcb92a005680884ee836c94f4ff # digest of zephyr_build :v1
script:
- 'zephyr/build-zephyr-samples-docker.sh || exit $?'
variables:
artifacts:
name: 'bin-zephyr-${CI_COMMIT_REF_SLUG}_${CI_COMMIT_SHA}'
paths:
- 'build_zephyr/'
expire_in: '1 month'
rules:
- if: "$CROSS_COMPILE != null || $ALL_BUILDS != null || $CI_MERGE_REQUEST_TARGET_BRANCH_NAME == 'master'"
when: always
###
# Test jobs
###
test-build-from-export:
<<: *build_linux
stage: test
script:
- 'mkdir -p ${CI_PROJECT_DIR}/samples/ClientServer/build_samples'
- 'cd ${CI_PROJECT_DIR}/samples/ClientServer/build_samples'
- 's2opc_DIR=${CI_PROJECT_DIR}/build cmake ..'
- 'cmake --build .'
- 'mkdir -p ${CI_PROJECT_DIR}/samples/PubSub/build_samples'
- 'cd ${CI_PROJECT_DIR}/samples/ClientServer/build_samples'
- 's2opc_DIR=${CI_PROJECT_DIR}/build cmake ..'
- 'cmake --build .'
- 'mkdir -p ${CI_PROJECT_DIR}/samples/PubSub_ClientServer/build_samples'
- 'cd ${CI_PROJECT_DIR}/samples/ClientServer/build_samples'
- 's2opc_DIR=${CI_PROJECT_DIR}/build cmake ..'
- 'cmake --build .'
artifacts:
rules:
- if: "$NO_TESTS == null && $WINDOWS_TEST == null && $CROSS_COMPILE == null && \
$WITH_COVERITY == null && $WITH_COVERAGE == null && $WITH_DOC == null && \
$S2OPC_PUBSUB_ONLY == null && $S2OPC_CLIENTSERVER_ONLY == null && \
$ALL_BUILDS == null && $ALL_TESTS == null"
when: on_success
.test-linux: &test_linux
<<: *docker_job
stage: test
# Common rules overwritten by each job using this template
# rules: # note to be repeated by each child job of *test_linux
# - if: "$NO_TESTS == null && $WINDOWS_TEST == null && $CROSS_COMPILE == null && \
# $WITH_COVERITY == null && $WITH_COVERAGE == null"
# when: on_success
# Test check belongs to the test part, however it does not depend on linux build.
test-check:
<<: *test_linux
image: registry.gitlab.com/systerel/s2opc/check@sha256:6805805e14420a9b635c2305526a4535f9edd191ff22801fc84cca94410b1a03 # digest of check:1.14
script:
- ./.check-code.sh
# Check generated types are up to date
- './scripts/gen-sopc-types.py ./schemas/Opc.Ua.Types.bsd && ./.format.sh && git ls-files -m | test 0 -eq `wc -l`'
variables:
DOCKER_IMAGE: 'sha256:20d4e72a3c1681a55aeb7b083a28edf4b58d12d113fc9271806d8e70900000ff'
artifacts:
name: 'test-check-results-${CI_COMMIT_REF_SLUG}_${CI_COMMIT_SHA}'
paths:
- 'pre-build-check.log'
- 'clang_tidy.log'
- 'build-analyzer/analyzer-report'
when: on_failure
expire_in: '1 month'
rules: # repeat .test-linux variables exception since overwritten here
- if: "$NO_TESTS == null && $WINDOWS_TEST == null && $CROSS_COMPILE == null && \
$WITH_COVERITY == null && $WITH_COVERAGE == null && $WITH_DOC == null && \
$ALL_TESTS == null && $ALL_BUILDS == null"
when: on_success
.test-unit: &test_unit
<<: *test_linux
image: registry.gitlab.com/systerel/s2opc/test@sha256:c8dc587888ca258206baaca8eed113b65e47560ed9aa808a8002931cd0f58293 # digest of test:2.12
script:
- './.set-bin-root.sh'
- './test-all.sh'
artifacts:
name: 'test-unit-results-${CI_COMMIT_REF_SLUG}_${CI_COMMIT_SHA}'
paths:
- 'build/bin/**/*.tap'
- 'build/bin/**/*.log'
- 'build/tests/**/Testing'
- 'build/**/*.*.gcda' # coverage analysis
- 'build/**/*.*.gcno' # coverage analysis
when: always
expire_in: '1 month'
# Common rules defined by test-unit job below
# Test unit for ALL_TESTS variable (add dynamic configuration)
test-unit-all-tests:
<<: *test_unit
variables:
<<: *all-tests_test_variables
script:
- './.set-bin-root.sh'
- './test-all.sh'
rules:
- if: "$ALL_TESTS != null"
when: on_success
# Test unit for NOT ALL_TESTS variable
test-unit:
<<: *test_unit
rules: # repeat .test-linux variables exception since overwritten here
- if: "$NO_TESTS == null && $WINDOWS_TEST == null && $CROSS_COMPILE == null && \
$WITH_COVERITY == null && $WITH_DOC == null && \
$ALL_TESTS == null" # + excludes ALL_TESTS
when: on_success
.test-uactt: &test_uactt
<<: *test_linux
image: com.systerel.fr:5000/c838/uactt-win@sha256:5be484563b6d9ba9bc96ace1e0f4a7c2f44acbf44197db7ef020a24beb140e03 # digest of uactt-win:1.8
script:
- 'cd tests/ClientServer/acceptance_tools/ && ./launch_acceptance_tests.sh'
artifacts:
name: 'uactt-logs-${CI_COMMIT_REF_SLUG}_${CI_COMMIT_SHA}'
paths:
- 'build/bin/**/*.tap'
- 'build/bin/**/*.log'
- 'tests/ClientServer/acceptance_tools/*.log'
- '**/*.*.gcda' # coverage analysis
- '**/*.*.gcno' # coverage analysis
when: always
expire_in: '1 month'
# Test unit for ALL_TESTS variable (add dynamic configuration)
test-uactt-all-tests:
<<: *test_uactt
variables:
<<: *all-tests_test_variables
rules:
- if: "$ALL_TESTS != null && \
$S2OPC_PUBSUB_ONLY == null && \
$ALL_BUILDS == null" # + no UACTT tests on PubSub + excludes ALL_BUILDS
# Test unit for NOT ALL_TESTS variable
test-uactt:
<<: *test_uactt
rules: # repeat .test-uactt variables exception since overwritten here
- if: "$NO_TESTS == null && $WINDOWS_TEST == null && $CROSS_COMPILE == null && \
$WITH_COVERITY == null && $WITH_COVERAGE == null && $WITH_DOC == null && \
$S2OPC_PUBSUB_ONLY == null && $ALL_BUILDS == null && $ALL_TESTS == null"
# + no UACTT tests on PubSub + excludes ALL_BUILDS + excludes ALL_TESTS
when: on_success
##
# Windows native build and tests (done in "build-others" stage)
##
windows-appveyor:
stage: build-others
image: docker.io/library/debian@sha256:de3eac83cd481c04c5d6c7344cd7327625a1d8b2540e82a8231b5675cef0ae5f # debian:9
script:
- 'apt-get update && apt-get -y install curl && curl -H "Authorization: Bearer $APPVEYOR_TOKEN" -H "Content-Type: application/json" --request POST -d ''{"accountName" : "Systerel", "projectSlug": "s2opc", "branch": "''$CI_COMMIT_REF_NAME''"}'' https://ci.appveyor.com/api/builds'
tags:
- linux
rules:
- if: "$ALL_BUILDS != null || $WINDOWS_TEST != null || \
$CI_COMMIT_BRANCH == 'master' && \
$ALL_TESTS == null && $WITH_COVERITY == null && $WITH_COVERAGE == null && \
$NO_ASAN == null && $NO_GEN == null && \
$S2OPC_PUBSUB_ONLY == null && $S2OPC_CLIENTSERVER_ONLY == null" # Avoid to run job on master for all nightly build except ALL_BUILDS
when: always # run even if previous job in pipeline failed
###
# Analysis jobs
###
coverage-analysis:
<<: *docker_job
stage: analyses
image: registry.gitlab.com/systerel/s2opc/test@sha256:ff5e7d299ba26e58f798427a55abef3760457a749032dfd71d227651458026bd # digest of test:2.10
script:
- ./.gen_coverage.sh
artifacts:
name: 'coverage-report-${CI_COMMIT_REF_SLUG}_${CI_COMMIT_SHA}'
paths:
- 'report'
expire_in: '1 month'
rules:
- if: "$WITH_COVERAGE != null"
###
# Documentation generation and publication
###
# The job name must be "pages", and the html must be in "public/" and put in an artifact.
pages:
<<: *build_linux
stage: doc
dependencies: []
rules:
- if: "$WITH_DOC != null"
- if: "$CI_PIPELINE_SOURCE == 'push' && $CI_COMMIT_BRANCH == 'master'"
variables:
<<: *build_linux_variables
script:
- mkdir $BUILD_DIR
- cd $BUILD_DIR
# PyS2OPC relies on subscriptions
- cmake -DWITH_NANO_EXTENDED=yes -DWITH_PYS2OPC=yes ..
- cmake --build . --target doc
- mv apidoc/html ../public/
artifacts:
paths:
- public
expire_in: 30 days
check_doc:
<<: *build_linux
stage: doc
script:
- cd $BUILD_DIR
- cmake --build . --target doc &> doc.log
- test $(grep -c warning doc.log) -eq 0
variables:
<<: *build_linux_variables
artifacts:
paths:
- '$BUILD_DIR/doc.log'
expire_in: '1 month'
when: on_failure
rules:
- if: "$ALL_BUILDS != null || $CI_PIPELINE_SOURCE == 'merge_request_event'"
when: always # run even if previous job in pipeline failed