forked from ocudu/ocudu
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.gitlab-ci.yml
More file actions
495 lines (471 loc) · 14.7 KB
/
Copy path.gitlab-ci.yml
File metadata and controls
495 lines (471 loc) · 14.7 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
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
# SPDX-FileCopyrightText: Copyright (C) 2021-2026 Software Radio Systems Limited
# SPDX-License-Identifier: BSD-3-Clause-Open-MPI
include:
- local: .gitlab/ci-shared/gitlab_settings/.gitlab-ci.yml
- local: .gitlab/ci-shared/workflow.yml
- local: .gitlab/ci-shared/static.yml
- local: .gitlab/ci/doxygen/version.yml
- local: .gitlab/ci/build.yml
- local: .gitlab/ci/deploy.yml
stages:
- ci
- static
- build and unit tests
- documentation
- deploy
# variables:
# SKIP_OCUDU_BUILDING_CONTAINERS_CI: true # set to any value to skip building ocudu containers in CI
################################################################################
## CI MR
################################################################################
trigger builder:
stage: ci
rules:
- if: $SKIP_OCUDU_BUILDING_CONTAINERS_CI
when: never
- if: $ON_MR_FORK
when: never
- if: $ON_MR_TRAIN
when: never
- if: $CI_MERGE_REQUEST_LABELS =~ /ci-no-builder/
when: never
- if: $ON_MR
changes:
paths:
- .gitlab/ci/builders/**/*
- docker/scripts/**/*
trigger:
include: .gitlab/ci/builders/.gitlab-ci.yml
strategy: mirror
needs:
- job: trigger buildkit
optional: true
artifacts: false
trigger buildkit:
stage: ci
rules:
- if: $SKIP_OCUDU_BUILDING_CONTAINERS_CI
when: never
- if: $ON_MR_FORK
when: never
- if: $ON_MR_TRAIN
when: never
- if: $ON_MR
changes:
paths:
- .gitlab/ci/buildkit-cli/**/*
trigger:
include: .gitlab/ci/buildkit-cli/.gitlab-ci.yml
strategy: mirror
trigger docker:
stage: ci
rules:
- if: $CI_MERGE_REQUEST_LABELS =~ /ci-no-docker/
when: never
- if: $ON_MR_FORK
when: never
- if: $ON_MR
changes:
paths:
- .gitlab/ci/docker/**/*
- docker/**/*.{yml,env,json,toml,py,sh,csv,py,toml}
- docker/**/Dockerfile
- .gdbinit
- if: $CI_PIPELINE_SCHEDULE_DESCRIPTION =~ /Nightly/
variables:
CI_PIPELINE_SCHEDULE_DESCRIPTION: Nightly
- if: $CI_PIPELINE_SCHEDULE_DESCRIPTION =~ /Weekly/
variables:
CI_PIPELINE_SCHEDULE_DESCRIPTION: Weekly
trigger:
include: .gitlab/ci/docker/.gitlab-ci.yml
strategy: mirror
needs:
- job: trigger buildkit
optional: true
artifacts: false
trigger doxygen:
stage: ci
rules:
- if: $SKIP_OCUDU_BUILDING_CONTAINERS_CI
when: never
- if: $ON_MR_FORK
when: never
- if: $ON_MR_TRAIN
when: never
- if: $ON_MR
changes:
paths:
- .gitlab/ci/doxygen/**/*
trigger:
include: .gitlab/ci/doxygen/.gitlab-ci.yml
strategy: mirror
needs:
- job: trigger buildkit
optional: true
artifacts: false
trigger static:
stage: ci
rules:
- if: $SKIP_OCUDU_BUILDING_CONTAINERS_CI
when: never
- if: $ON_MR_FORK
when: never
- if: $ON_MR_TRAIN
when: never
- if: $CI_MERGE_REQUEST_LABELS =~ /ci-no-static/
when: never
- if: $ON_MR
changes:
paths:
- .gitlab/ci/static/**/*
trigger:
include: .gitlab/ci/static/.gitlab-ci.yml
strategy: mirror
needs:
- job: trigger buildkit
optional: true
artifacts: false
warning about unapplied changes:
stage: ci
image: alpine:3.16.0
rules:
- if: $SKIP_OCUDU_BUILDING_CONTAINERS_CI && $ON_MR
changes: &warning_container_changes
paths:
- .gitlab/ci/builders/**/*
- .gitlab/ci/buildkit-cli/**/*
- .gitlab/ci/doxygen/**/*
- .gitlab/ci/static/**/*
- docker/grafana/**/*
- docker/scripts/**/*
- docker/telegraf/**/*
- if: $ON_MR_FORK
changes:
<<: *warning_container_changes
allow_failure: true
script:
- echo "This MR contains changes in OCUDU containers but pushing new images is disabled. You'll keep using old containers and changes won't be applied."
- exit 1
################################################################################
## Static
################################################################################
headers:
extends: .headers
needs:
- job: trigger static
optional: true
artifacts: false
code-format:
extends: .code-format
rules:
- if: $ON_MR
changes:
- .clang-format
when: never
- if: $ON_MR
needs:
- job: trigger static
optional: true
artifacts: false
full-code-format:
extends: .full-code-format
rules:
- if: $ON_MR
changes:
- .clang-format
needs:
- job: trigger static
optional: true
artifacts: false
include-guards:
extends: .include-guards
rules:
- if: $ON_MR
parallel:
matrix:
- INPUT_PATH: "include/ocudu"
INPUT_IGNORE: "/bundled/"
- INPUT_PATH: "."
INPUT_IGNORE: "^\\(include\\|docs\\|external\\)/.*"
needs:
- job: trigger static
optional: true
artifacts: false
.codechecker:
image: ${OCUDU_REGISTRY_URI}/codechecker:${DOCKER_BUILDER_VERSION}
stage: static
tags:
- ${OCUDU_RUNNER_TAG}-amd64
needs:
- job: trigger builder
optional: true
artifacts: false
variables:
ANALYZER: ""
ANALYZER_ARGS: ""
ARTIFACT_EXTRA_PATH: ""
CHECK_PER_FILE_TIMEOUT: 600
timeout: 3 hours
before_script:
- |
CPU_JOBS="$(/usr/local/bin/get_available_cores.sh 2>/dev/null || ${CI_PROJECT_DIR}/.gitlab/ci/builders/get_available_cores.sh)"
if [ -z "${CPU_JOBS}" ] || [ "${CPU_JOBS}" -lt 1 ]; then
CPU_JOBS=1
fi
export CPU_JOBS
- |
echo "
-/usr/lib
-*CMakeTmp
-*CompilerIdCXX
-*tests/unittests
-*tests/integrationtests
-*tests/benchmarks
-*benchmarks
-*apps/examples
-*external
-*lib/asn1
-*lib/phy/generic_functions/fftx/lib_fftx_dftbat_srcs
-*lib/phy/generic_functions/fftx/lib_fftx_idftbat_srcs" >/tmp/codechecker_skip
- |
export CC=/usr/bin/clang
export CXX=/usr/bin/clang++
mkdir -p build
cd build || exit
cmake -DASSERT_LEVEL=PARANOID -DMARCH=x86-64-v3 -DCMAKE_EXPORT_COMPILE_COMMANDS=ON -DBUILD_TESTING=False ..
make ocudu_versioning # needed to generate hashes.h
- |
monitor_child_process() {
while true; do
ps -eo comm,pid,etimes | grep ${ANALYZER} | while read comm pid etimes; do
if [ $etimes -gt $CHECK_PER_FILE_TIMEOUT ]; then
echo "Killing child analysis process"
kill $pid
fi
done
sleep 30
done
}
export -f monitor_child_process
script: &codechecker_script
- nohup bash -c monitor_child_process &
- static-analyzer.sh -i /tmp/codechecker_skip --jobs ${CPU_JOBS} --analyzers ${ANALYZER} ${ANALYZER_ARGS} $CI_PROJECT_DIR
after_script:
- mv codechecker_html codechecker-${ANALYZER}-html
artifacts: &codechecker_artifacts
reports:
codequality: code-quality-report.json
paths:
- codechecker-${ANALYZER}-html${ARTIFACT_EXTRA_PATH}
when: always
expire_in: 10 minutes
clang-tidy:
extends: .codechecker
rules:
- if: $CI_PIPELINE_SCHEDULE_DESCRIPTION =~ /Nightly/
retry: 2
variables:
ANALYZER: clang-tidy
ANALYZER_ARGS: --analyzer-config clang-tidy:take-config-from-directory=true --tidy-config .clang-tidy
ARTIFACT_EXTRA_PATH: "/index.html"
clang-tidy incremental:
extends: clang-tidy
rules:
- if: $ON_MR
variables:
CCACHE_MAXSIZE: 3G
CACHE_COMPRESSION_LEVEL: slowest
CACHE_REQUEST_TIMEOUT: 5 # minutes - 10 by default
script:
- |
cd $CI_PROJECT_DIR
git config advice.detachedHead false
UNSHALLOW=$([ "$(git rev-parse --is-shallow-repository)" = "true" ] && echo --unshallow || true)
if [ "$CI_MERGE_REQUEST_SOURCE_PROJECT_PATH" != "$CI_PROJECT_PATH" ]; then
git remote add fork $CI_MERGE_REQUEST_SOURCE_PROJECT_URL
git fetch $UNSHALLOW origin $CI_MERGE_REQUEST_TARGET_BRANCH_NAME
git fetch fork $CI_MERGE_REQUEST_SOURCE_BRANCH_NAME
git branch -f $CI_MERGE_REQUEST_SOURCE_BRANCH_NAME fork/$CI_MERGE_REQUEST_SOURCE_BRANCH_NAME
git branch -f $CI_MERGE_REQUEST_TARGET_BRANCH_NAME origin/$CI_MERGE_REQUEST_TARGET_BRANCH_NAME
else
git fetch $UNSHALLOW origin $CI_MERGE_REQUEST_TARGET_BRANCH_NAME $CI_MERGE_REQUEST_SOURCE_BRANCH_NAME
git branch -f $CI_MERGE_REQUEST_SOURCE_BRANCH_NAME origin/$CI_MERGE_REQUEST_SOURCE_BRANCH_NAME
git branch -f $CI_MERGE_REQUEST_TARGET_BRANCH_NAME origin/$CI_MERGE_REQUEST_TARGET_BRANCH_NAME
fi
FORK_POINT=$(git merge-base $CI_MERGE_REQUEST_SOURCE_BRANCH_NAME $CI_MERGE_REQUEST_TARGET_BRANCH_NAME)
SOURCE_SHA=${CI_MERGE_REQUEST_SOURCE_BRANCH_SHA:-$CI_COMMIT_SHA}
- |
for rev in $FORK_POINT $SOURCE_SHA; do
echo "##################################################"
echo "#### $rev ####"
echo "##################################################"
git checkout $rev
CodeChecker log -o ${CI_PROJECT_DIR}/build/compile_commands.json --build "builder.sh -m -j${CPU_JOBS} -c clang -DMARCH=x86-64-v3 -DENABLE_ARMPL=False -DENABLE_MKL=False -DENABLE_FFTW=True -DASSERT_LEVEL=PARANOID -DCMAKE_BUILD_TYPE=RelWithDebInfo -DBUILD_TESTING=False $CI_PROJECT_DIR"
done
- *codechecker_script
cache:
- key: codechecker-clang-tidy
paths: [ccache]
policy: pull-push
when: always
cppcheck:
extends: .codechecker
rules:
- if: $CI_PIPELINE_SCHEDULE_DESCRIPTION =~ /Nightly/
retry: 2
variables:
ANALYZER: cppcheck
ANALYZER_ARGS: --cppcheck-max-template-recursion 5
artifacts:
<<: *codechecker_artifacts
expire_in: 7 days
clangsa:
extends: .codechecker
rules:
- if: $CI_PIPELINE_SCHEDULE_DESCRIPTION =~ /Nightly/
when: manual
allow_failure: true
- if: $CI_PIPELINE_SCHEDULE_DESCRIPTION =~ /Weekly/
when: manual
allow_failure: true
variables:
ANALYZER: clangsa
ANALYZER_ARGS: --ctu
timeout: 8 hours
################################################################################
## Build + Unit Tests + Integration tests
################################################################################
# In .gitlab/ci/build.yml
################################################################################
# Doc generation
################################################################################
unit coverage:
stage: documentation
image:
name: mcr.microsoft.com/dotnet/sdk:8.0-alpine
entrypoint: ["/bin/sh", "-c"]
rules:
- if: $ON_MR
variables:
coverage_report: summary
- if: $CI_PIPELINE_SCHEDULE_DESCRIPTION =~ /Nightly/
variables:
coverage_report: summary
- if: $CI_PIPELINE_SCHEDULE_DESCRIPTION =~ /Smoke/
variables:
coverage_report: summary
- if: $ON_PROTECTED_BRANCH
variables:
coverage_report: full
before_script:
- export PATH="$PATH:/root/.dotnet/tools"
- dotnet tool install -g dotnet-reportgenerator-globaltool --version 5.5.0
- PACKAGE_URL=${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/coverage/${CI_COMMIT_BRANCH}${CI_MERGE_REQUEST_SOURCE_BRANCH_NAME}/coverage_history.tar.gz
# Download coverage history from the registry
- |
download_from_registry() {
apk add curl
cd ${CI_PROJECT_DIR}
http_code=$(curl -w "%{http_code}" --header "JOB-TOKEN: $CI_JOB_TOKEN" "${PACKAGE_URL}" -o output.tar.gz)
if [[ $http_code == "200" ]]; then
tar -xf output.tar.gz
fi
}
# Publish coverage history folder to the registry
- |
publish_to_registry() {
cd ${CI_PROJECT_DIR}
tar -czf coverage_history.tar.gz coverage_history
curl --fail --header "JOB-TOKEN: $CI_JOB_TOKEN" --upload-file coverage_history.tar.gz "${PACKAGE_URL}"
}
script:
- |
if [[ $coverage_report = "full" ]]; then
download_from_registry
HTML_TYPE=Html
HISTORY=-historydir:coverage_history
else
HTML_TYPE=HtmlSummary
HISTORY=
fi
- |
reportgenerator -reports:*coverage*.xml -targetdir:coverage_html ${HISTORY} \
-title:${CI_PROJECT_NAME} -tag:${CI_COMMIT_SHA} \
-reporttypes:"${HTML_TYPE};TextSummary"
- cat coverage_html/Summary.txt
- coverage_value=$(cat coverage_html/Summary.txt | sed -n 's/^\s*Line coverage:\s*\(.*\)\%/\1/p')
- |
if [[ $coverage_report = "full" ]]; then
publish_to_registry
cd ${CI_PROJECT_DIR}
tar -czf coverage_html.tar.gz coverage_html
curl --fail --header "JOB-TOKEN: $CI_JOB_TOKEN" --upload-file coverage_html.tar.gz ${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/coverage_html/latest/coverage_html.tar.gz
fi
coverage: /^\s*Line coverage:\s*\d+.\d+\%/
artifacts:
paths:
- coverage_html
expire_in: 7 days
retry: 2
needs:
- job: intermediate commits cached
optional: true
artifacts: true
- job: intermediate commits clean
optional: true
artifacts: true
- job: smoke coverage
optional: true
artifacts: true
doxygen:
stage: documentation
image: ${OCUDU_REGISTRY_URI}/doxygen:${DOXYGEN_VERSION}-${PLANTUML_VERSION}
rules:
- if: $ON_MR
changes:
paths:
- docs/**/*
- if: $CI_PIPELINE_SCHEDULE_DESCRIPTION =~ /Nightly/
- if: $CI_PIPELINE_SCHEDULE_DESCRIPTION =~ /Smoke/
- if: $ON_PROTECTED_BRANCH
script:
- |
rm -Rf build_doxygen
mkdir build_doxygen
cd build_doxygen || exit
cmake -DENABLE_UHD=False -DDOXYGEN_HAVE_DOT=False -DBUILD_TESTING=False ..
make -j $(nproc) doxygen
- |
if [[ $CI_COMMIT_BRANCH == "main" ]]; then
cd ${CI_PROJECT_DIR}
tar -czf doxygen.tar.gz build_doxygen/docs/doxygen/html
curl --fail --header "JOB-TOKEN: $CI_JOB_TOKEN" --upload-file doxygen.tar.gz ${CI_API_V4_URL}/projects/${CI_PROJECT_ID}/packages/generic/doxygen/latest/doxygen.tar.gz
fi
artifacts:
paths:
- build_doxygen/docs/doxygen/html
expire_in: 7 days
needs:
- job: trigger doxygen
optional: true
artifacts: false
################################################################################
# post
################################################################################
promotion:
stage: .post
rules:
- if: $CI_PIPELINE_SCHEDULE_DESCRIPTION =~ /Nightly/ && $GITLAB_TOKEN
image: alpine:3
variables:
GIT_STRATEGY: none
script:
- apk add --no-cache git
- git clone https://gitlab_token:${GITLAB_TOKEN}@${CI_SERVER_SHELL_SSH_HOST}/${CI_PROJECT_NAMESPACE}/${CI_PROJECT_NAME}.git /${CI_PROJECT_NAME}
- cd /${CI_PROJECT_NAME}
- git fetch origin main
- git checkout -t origin/main
- git rebase ${CI_COMMIT_SHA}
- git push
dependencies: []