-
Notifications
You must be signed in to change notification settings - Fork 177
/
.gitlab-ci.yml
577 lines (545 loc) · 15.7 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
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
#
# Copyright 2021-2024 Software Radio Systems Limited
#
# This file is part of srsRAN
#
# srsRAN is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of
# the License, or (at your option) any later version.
#
# srsRAN is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU Affero General Public License for more details.
#
# A copy of the GNU Affero General Public License can be found in
# the LICENSE file in the top-level directory of this distribution
# and at http://www.gnu.org/licenses/.
#
# How to test nighlt/weekly schedules
# Generate a schedule for your branch whit a CI_DESCRIPTION variable
# that contains "Nightly"/"Weekly" and an extra word
# Ex: "Test Weekly", "Nighlty add feature"
include:
- project: softwareradiosystems/ci/tools
ref: "20"
file: .gitlab/ci-shared/setup/all.yml
- project: softwareradiosystems/ci/tools
ref: "20"
file: .gitlab/ci-shared/features/all.yml
- project: softwareradiosystems/ci/tools
ref: "20"
file: .gitlab/ci-shared/tools/python.yml
- project: softwareradiosystems/ci/tools
ref: "20"
file: .gitlab/ci-shared/tools/test_reporter.yml
- project: softwareradiosystems/ci/tools
ref: "20"
file: .gitlab/ci-shared/tools/tagger.yml
- local: .gitlab/ci/builders/version.yml
- local: .gitlab/ci/build.yml
- local: .gitlab/ci/trx.yml
- local: .gitlab/ci/e2e.yml
- local: .gitlab/ci/release.yml
stages:
- ci
- static
- build and unit tests
- zmq
- rf
- manual
- documentation
- private
- public
- release
variables:
SLACK_CHANNEL_OK: "#ci_gnb"
SLACK_CHANNEL_FAIL: "#ci_gnb"
SLACK_CHANNEL_INFO_MSG: "#ci_gnb_verbose"
AUTOREBASER_PRS_IN_QUEUE: 1
################################################################################
## CI
################################################################################
job cleaner:
extends: .job cleaner
timeout: 4h
rules:
- if: $CI_DESCRIPTION =~ /Nightly Build Unit Tests/
pr reminder:
extends: .pr reminder
rules:
- if: $NOTIFY_SLACK != "true"
when: never
- if: $CI_DESCRIPTION =~ /Nightly Build Unit Tests/
trigger builder:
stage: ci
rules:
- if: $ON_MR
changes:
paths:
- .gitlab/ci/builders.yml
- .gitlab/ci/builders/**/*
- docker/scripts/**/*
trigger:
include: .gitlab/ci/builders.yml
strategy: depend
trigger docker:
stage: ci
rules:
- if: $ON_MR
changes:
paths:
- .gitlab/ci/docker.yml
- docker/**/*.{yml,env,json,toml,py,sh,csv,py,toml}
- docker/**/Dockerfile
- .gdbinit
- if: $CI_DESCRIPTION =~ /Nightly Build Unit Tests/
variables:
CI_DESCRIPTION: $CI_DESCRIPTION
- if: $CI_DESCRIPTION =~ /Weekly/
variables:
CI_DESCRIPTION: $CI_DESCRIPTION
trigger:
include: .gitlab/ci/docker.yml
strategy: depend
variables:
PY_DIR: docker/metrics_server
matlab nightly:
stage: ci
rules:
- if: $CI_DESCRIPTION =~ /Nightly Build Unit Tests/
variables:
ON_SCHEDULE: "true"
CI_DESCRIPTION: Nightly
SRSRAN_COMMIT: $CI_COMMIT_SHA
NOTIFY_SLACK: "true"
when: delayed
start_in: 3 hours
inherit:
variables: false
trigger:
project: softwareradiosystems/srsgnb_matlab
branch: master
enterprise nightly:
stage: ci
rules:
- if: $CI_DESCRIPTION =~ /Nightly Build Unit Tests/
variables:
ON_SCHEDULE: "true"
CI_DESCRIPTION: Nightly
SRSRAN_COMMIT: $CI_COMMIT_SHA
NOTIFY_SLACK: "true"
when: delayed
start_in: 3 hours
inherit:
variables: false
trigger:
project: softwareradiosystems/srsran_5g_enterprise
branch: main
matlab weekly:
stage: ci
rules:
- if: $CI_DESCRIPTION =~ /Weekly/
variables:
ON_SCHEDULE: "true"
CI_DESCRIPTION: Weekly
SRSRAN_COMMIT: $CI_COMMIT_SHA
NOTIFY_SLACK: "true"
when: delayed
start_in: 20 hours
inherit:
variables: false
trigger:
project: softwareradiosystems/srsgnb_matlab
branch: master
helm weekly:
stage: ci
rules:
- if: $CI_DESCRIPTION =~ /Weekly/
variables:
ON_SCHEDULE: "true"
CI_DESCRIPTION: Synchronization with srsGNB
NOTIFY_SLACK: "true"
when: delayed
start_in: 20 hours
inherit:
variables: false
trigger:
project: softwareradiosystems/ci/srsgnb_k8s
branch: main
needs:
- job: trigger docker
artifacts: false
################################################################################
## Static
################################################################################
headers:
image: ubuntu
stage: static
rules:
- if: $ON_MR
exists:
- "**/CMakeLists.txt"
- "**/Dockerfile"
- "**/*.cmake"
- "**/*.yml"
- "**/*.sh"
script:
- .gitlab/ci/release/update_headers.sh
needs: []
include-guards:
extends: .include-guards
parallel:
matrix:
- INPUT_PATH: "include/srsran"
INPUT_IGNORE: "/bundled/"
- INPUT_PATH: "."
INPUT_IGNORE: "^\\(include\\|docs\\|external\\)/.*"
full-code-format:
extends: .full-code-format
rules:
- if: $ON_MR
changes:
- .clang-format
- if: $CI_DESCRIPTION =~ /Nightly Build Unit Tests/
.codechecker:
image: ${CR_REGISTRY_URI}/srsgnb/codechecker:${DOCKER_BUILDER_VERSION}
stage: static
tags:
- amd64
needs:
- job: builder version
optional: false
artifacts: true
- job: trigger builder
optional: true
artifacts: false
variables:
ANALYZER: ""
ANALYZER_ARGS: ""
ARTIFACT_EXTRA_PATH: ""
KUBERNETES_CPU_REQUEST: 6
KUBERNETES_CPU_LIMIT: 6
KUBERNETES_MEMORY_REQUEST: 12Gi
KUBERNETES_MEMORY_LIMIT: 12Gi
CHECK_PER_FILE_TIMEOUT: 600
before_script:
- |
echo "
-/usr/lib
-*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_TESTS=False ..
make srsran_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:
- nohup bash -c monitor_child_process &
- static-analyzer.sh -i /tmp/codechecker_skip --jobs ${KUBERNETES_CPU_REQUEST} --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
stage: manual
rules:
- if: $ON_MR == "true" && $CI_MERGE_REQUEST_APPROVED == "true"
- if: $ON_MR
when: manual
allow_failure: false
variables:
ANALYZER: clang-tidy
ANALYZER_ARGS: --analyzer-config clang-tidy:take-config-from-directory=true --tidy-config .clang-tidy
ARTIFACT_EXTRA_PATH: "/index.html"
cppcheck:
extends: .codechecker
rules:
- if: $CI_DESCRIPTION =~ /Nightly Build Unit Tests/
interruptible: false
retry: 2
variables:
ANALYZER: cppcheck
ANALYZER_ARGS: --cppcheck-max-template-recursion 5
artifacts:
<<: *codechecker_artifacts
expire_in: 1 day
clangsa:
extends: .codechecker
rules:
- if: $CI_DESCRIPTION =~ /Nightly Build Unit Tests/
when: manual
allow_failure: true
- if: $CI_DESCRIPTION =~ /Weekly/
when: manual
allow_failure: true
interruptible: false
variables:
ANALYZER: clangsa
ANALYZER_ARGS: --ctu
timeout: 8 hours
# .coverity_base:
# image: $CR_REGISTRY_URI/coverity_image/2022.6.0:1.0.0
# stage: static
# needs: []
# variables:
# KUBERNETES_CPU_REQUEST: 6
# KUBERNETES_CPU_LIMIT: 6
# KUBERNETES_MEMORY_REQUEST: 12Gi
# KUBERNETES_MEMORY_LIMIT: 12Gi
# tags:
# - amd64
# interruptible: false
# timeout: 2 hours
# script:
# - |
# mkdir -p build
# cd build
# cmake ..
# cov-build --dir cov-int make -j${KUBERNETES_CPU_REQUEST}
# tar czvf srsgnb.tgz cov-int
# ver=$(git rev-parse HEAD)
# - |
# curl --form token=$COV_TOKEN \
# --form email=${COVERITY_EMAIL} \
# --form [email protected] \
# --form version=$ver \
# --form description="${DESCRIPTION}" \
# https://scan.coverity.com/builds?project=${PROJECT_NAME}
# coverity-dev:
# extends: .coverity_base
# rules:
# - if: $CI_DESCRIPTION =~ /Weekly/
# before_script:
# - export PROJECT_NAME="srsRAN_5G"
# - export DESCRIPTION="srsRAN Project dev build"
# - export COV_TOKEN="${COVERITY_TOKEN_DEV}"
e2e tests tox:
stage: static
rules:
- if: $ON_MR
changes:
- tests/e2e/**/*
variables:
PY_DIR: tests/e2e
before_script:
- apk add build-base
extends: .tox
################################################################################
## Build + Unit Tests + Integration tests
################################################################################
# In build.yml
################################################################################
# Doc generation
################################################################################
unit coverage:
stage: documentation
image:
name: ${GITLAB_REGISTRY_URI}/${CI_TOOLS_REPO}/report-generator:5.1.26
entrypoint: ["/bin/sh", "-c"]
rules:
- if: $ON_MR
variables:
coverage_report: summary
when: always # Even if previous stages/required jobs fail
before_script:
- 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 "PRIVATE-TOKEN: $CODEBOT_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
fi
- |
export metric_prefix=""
if [[ $ON_MR == "true" ]]; then metric_prefix="_pr"; fi
echo "coverage${metric_prefix},pipeline=${CI_PIPELINE_ID},os=${OS} value=${coverage_value}" >> build/build_time_metrics.txt
- |
influx write --host $INFLUXDB_URL --token $INFLUXDB_TOKEN --org $INFLUXDB_ORG \
--bucket ci --file build/build_time_metrics.txt
coverage: /^\s*Line coverage:\s*\d+.\d+\%/
artifacts: &unit_coverage_artifacts
paths:
- coverage_html
expire_in: 10 minutes
retry: 2
needs:
- job: intermediate commits cached
optional: true
artifacts: true
- job: intermediate commits clean
optional: true
artifacts: true
- job: smoke release update cache
optional: true
artifacts: true
unit coverage dev:
extends: unit coverage
rules:
- if: $CI_DESCRIPTION =~ /Nightly Build Unit Tests/
variables:
coverage_report: full
when: always # Even if previous stages/required jobs fail
artifacts:
<<: *unit_coverage_artifacts
expire_in: 1 day
pages:
stage: documentation
rules:
- if: $CI_DESCRIPTION =~ /Nightly Build Unit Tests/
when: always # Even if previous stages/required jobs fail
allow_failure: true
image: ${GITLAB_REGISTRY_URI}/${CI_TOOLS_REPO}/doxygen:1.9.8-1.2023.7
script:
- mkdir public
- mv coverage_html public/
- mv codechecker*html public/
- mv docs/index.html public/index.html
- docker/scripts/install_dependencies.sh
- apt-get update && apt-get install -y --no-install-recommends rsync
- |
rm -Rf build
mkdir build
cd build || exit
cmake ..
make -j $(nproc) doxygen
cd ..
- mkdir public/doxygen
- rsync -a build/docs/html/ public/doxygen/
after_script:
- |
if [ $CI_JOB_STATUS = "failed" ]; then
mkdir -p public
mv docs/fail.html public/index.html
fi
- mv docs/*.png public/
- sed -i 's/commit_hash/'$CI_COMMIT_SHA'/' public/index.html
needs:
- job: unit coverage dev
artifacts: true
- job: cppcheck
artifacts: true
artifacts:
paths:
- public
expire_in: 10 minutes
################################################################################
# Release dryrun
################################################################################
update agpl main dryrun:
extends: update private branch
stage: .post
rules:
- if: $CI_DESCRIPTION =~ /Nightly Build Unit Tests/
when: always
variables:
PRIVATE_BRANCH: agpl_main
HEADERS: "true"
MODE: "dryrun"
needs: []
create-tags:
extends: .create-tag
stage: .post
rules:
- if: $CI_DESCRIPTION =~ /Nightly Build Unit Tests/
when: delayed
start_in: 3 hours
script:
- |
for name in $TAG_NAME_ARRAY; do
create_tag "${name}_$(date -u +"%Y.%m.%d")"
done
needs: []
retry: 2
################################################################################
# Enable / Disable pipelines
################################################################################
scheduler:
# Override default scheduler job
# Enabling branches on default_branch will also apply any change done
stage: ci
extends: .enable-schedule-by-branch
rules:
- if: $ON_DEFAULT_BRANCH
variables:
ENABLE: "true"
BRANCH: $CI_COMMIT_BRANCH
dependencies: []
disable current schedule:
stage: .post
extends: .enable-schedule-by-description
rules:
- if: $CI_DESCRIPTION =~ /Nightly Build Unit Tests/
when: always
- if: $CI_DESCRIPTION =~ /Nightly E2E Tests/
when: always
- if: $CI_DESCRIPTION =~ /Alternative OSs/
when: always
- if: $CI_DESCRIPTION =~ /Weekly/
when: always
interruptible: false
variables:
ENABLE: "false"
BRANCH: $CI_COMMIT_REF_NAME
DESCRIPTION: $CI_DESCRIPTION
dependencies: []