forked from nasa/HDTN
-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
426 lines (401 loc) · 13.8 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
# Configure the pipeline stages
stages:
- build-stage
- test-stage
- scan-stage
# Set global environment variables
variables:
HDTN_SOURCE_ROOT: "$PWD"
# Build HDTN with the default configuration
# Use this for unit and integrated tests
build-default:
stage: build-stage
tags:
- docker
- linux-x86
image: $CI_REGISTRY/hdtn-v4/hdtn/debian-base
script:
- mkdir -p build
- cmake -S . -B build -DCMAKE_CXX_FLAGS="-Werror" -DCMAKE_C_FLAGS="-Werror" -DENABLE_STREAMING_SUPPORT:BOOL=ON
- make -C build/ -j8
- make -C build/ install
cache:
key: build-default-$CI_MERGE_REQUEST_TARGET_BRANCH_NAME-$CI_MERGE_REQUEST_ID
paths:
- build
artifacts:
paths:
- build
expire_in: 2 days
rules:
- if: $CI_PIPELINE_SOURCE == 'merge_request_event'
# Build HDTN with Visual Studio 2022
build-and-run-win:
stage: build-stage
tags:
- win-x86
script:
- powershell -executionpolicy bypass .\building_on_windows\hdtn_windows_cicd_unit_test.ps1
rules:
- if: $CI_PIPELINE_SOURCE == 'merge_request_event'
# Build HDTN with Oracle Linux on x86_64 using shared libs
build-and-run-shared-linux-x64:
stage: build-stage
tags:
- oracle-x86
script:
- mkdir -p build
- cmake -S . -B build -DCMAKE_CXX_FLAGS="-Werror" -DCMAKE_C_FLAGS="-Werror" -DBUILD_SHARED_LIBS:BOOL=ON
- make -C build/ -j8
- export HDTN_SOURCE_ROOT=$PWD
- ./build/tests/unit_tests/unit-tests
rules:
- if: $CI_PIPELINE_SOURCE == 'merge_request_event'
# Build HDTN with FreeBSD on x86_64
build-and-run-freebsd-x64:
stage: build-stage
tags:
- freebsd-x86
script:
- mkdir -p build
- cmake -S . -B build -DCMAKE_CXX_FLAGS="-Werror" -DCMAKE_C_FLAGS="-Werror" -DUSE_X86_HARDWARE_ACCELERATION:BOOL=ON -DLTP_RNG_USE_RDSEED:BOOL=ON -Dlibzmq_LIB:FILEPATH=/usr/local/lib/libzmq.so
- make -C build/ -j8
- export HDTN_SOURCE_ROOT=$PWD
- ./build/tests/unit_tests/unit-tests
rules:
- if: $CI_PIPELINE_SOURCE == 'merge_request_event'
# Build HDTN with OpenBSD on x86_64
build-and-run-openbsd-x64:
stage: build-stage
tags:
- openbsd-x86
script:
- mkdir -p build
- cmake -S . -B build -DCMAKE_CXX_FLAGS="-Werror" -DCMAKE_C_FLAGS="-Werror" -DUSE_X86_HARDWARE_ACCELERATION:BOOL=ON -DLTP_RNG_USE_RDSEED:BOOL=ON -Dlibzmq_LIB:FILEPATH=/usr/local/lib/libzmq.so
- make -C build/ -j8
- export HDTN_SOURCE_ROOT=$PWD
- ./build/tests/unit_tests/unit-tests
rules:
- if: $CI_PIPELINE_SOURCE == 'merge_request_event'
# Build HDTN with Intel Mac
build-and-run-mac-intel:
stage: build-stage
tags:
- macos-x86
script:
- mkdir -p build
- cmake -S . -B build -DCMAKE_CXX_FLAGS="-Werror" -DCMAKE_C_FLAGS="-Werror" -DUSE_X86_HARDWARE_ACCELERATION:BOOL=ON -DLTP_RNG_USE_RDSEED:BOOL=ON -Dlibzmq_LIB:FILEPATH=/usr/local/Cellar/zeromq/4.3.5_1/lib/libzmq.dylib -Dlibzmq_INCLUDE:PATH=/usr/local/Cellar/zeromq/4.3.5_1/include
- make -C build/ -j8
- export HDTN_SOURCE_ROOT=$PWD
- ./build/tests/unit_tests/unit-tests
rules:
- if: $CI_PIPELINE_SOURCE == 'merge_request_event'
# Build HDTN with M2 Mac
build-and-run-mac-m2:
stage: build-stage
tags:
- macos-arm64
script:
- mkdir -p build
- cmake -S . -B build -DCMAKE_CXX_FLAGS="-Werror" -DCMAKE_C_FLAGS="-Werror" -DUSE_X86_HARDWARE_ACCELERATION:BOOL=ON -DLTP_RNG_USE_RDSEED:BOOL=OFF -Dlibzmq_LIB:FILEPATH=/opt/homebrew/lib/libzmq.dylib -Dlibzmq_INCLUDE:PATH=/opt/homebrew/include
- make -C build/ -j8
- export HDTN_SOURCE_ROOT=$PWD
- ./build/tests/unit_tests/unit-tests
rules:
- if: $CI_PIPELINE_SOURCE == 'merge_request_event'
# Build HDTN with Linux Arm64 (aarch64)
build-and-run-linux-arm64:
stage: build-stage
tags:
- linux-arm64
- ubuntu-arm64
script:
- mkdir -p build
- cmake -S . -B build -DCMAKE_CXX_FLAGS="-Werror" -DCMAKE_C_FLAGS="-Werror" -DUSE_X86_HARDWARE_ACCELERATION:BOOL=ON -DLTP_RNG_USE_RDSEED:BOOL=OFF
- make -C build/ -j8
- export HDTN_SOURCE_ROOT=$PWD
- ./build/tests/unit_tests/unit-tests
rules:
- if: $CI_PIPELINE_SOURCE == 'merge_request_event'
# Build HDTN with C++11 only
build-cpp11:
stage: build-stage
tags:
- docker
- linux-x86
image: $CI_REGISTRY/hdtn-v4/hdtn/debian-base
script:
- mkdir -p build
- cmake -S . -B build -DHDTN_TRY_USE_CPP17:BOOL=OFF -DCMAKE_CXX_FLAGS="-Werror" -DCMAKE_C_FLAGS="-Werror"
- make -C build/ -j8
cache:
key: build-cpp11-$CI_MERGE_REQUEST_TARGET_BRANCH_NAME-$CI_MERGE_REQUEST_ID
paths:
- build
rules:
- if: $CI_PIPELINE_SOURCE == 'merge_request_event'
# Build HDTN with extra compile options
build-extra-options:
stage: build-stage
tags:
- docker
- linux-x86
image: $CI_REGISTRY/hdtn-v4/hdtn/debian-base
script:
- mkdir -p build
- cmake -S . -B build -DUSE_WEB_INTERFACE:BOOL=OFF -DDO_STATS_LOGGING=ON -DENABLE_OPENSSL_SUPPORT=OFF -DENABLE_BPSEC=OFF -DCMAKE_CXX_FLAGS="-Werror" -DCMAKE_C_FLAGS="-Werror"
- make -C build/ -j8
cache:
key: build-without-gui-$CI_MERGE_REQUEST_TARGET_BRANCH_NAME-$CI_MERGE_REQUEST_ID
paths:
- build
rules:
- if: $CI_PIPELINE_SOURCE == 'merge_request_event'
# Build HDTN with CivetWeb instead of Boost Beast
build-civetweb:
stage: build-stage
tags:
- docker
- linux-x86
image: $CI_REGISTRY/hdtn-v4/hdtn/debian-base
script:
- mkdir -p build
- cmake -S . -B build -DWEB_INTERFACE_USE_CIVETWEB:BOOL=ON -DCMAKE_CXX_FLAGS="-Werror" -DCMAKE_C_FLAGS="-Werror"
- make -C build/ -j8
cache:
key: build-civet-$CI_MERGE_REQUEST_TARGET_BRANCH_NAME-$CI_MERGE_REQUEST_ID
paths:
- build
rules:
- if: $CI_PIPELINE_SOURCE == 'merge_request_event'
build-static-analysis:
stage: build-stage
tags:
- cov-analysis
script:
- export PATH=/home/hdtn/cov-analysis-linux64-2022.6.1/bin:$PATH
- export HDTN_SOURCE_ROOT=$PWD
- mkdir -p build
- cd build
- cmake -DENABLE_STREAMING_SUPPORT:BOOL=ON -DCMAKE_BUILD_TYPE=Release ..
- cov-build --dir idir make -j8
cache:
key: build-static-analysis-$CI_MERGE_REQUEST_TARGET_BRANCH_NAME-$CI_MERGE_REQUEST_ID
paths:
- build
artifacts:
paths:
- build
expire_in: 2 days
rules:
- if: $DO_MONTHLY_SLOC_COUNT == "true"
when: never
- if: $CI_PIPELINE_SOURCE == "schedule"
- if: $CI_PIPELINE_SOURCE == 'merge_request_event'
# Run unit tests and generate a test report
unit-test:
stage: test-stage
tags:
- docker
- linux-x86
image: $CI_REGISTRY/hdtn-v4/hdtn/debian-base
needs:
- build-default
dependencies:
- build-default
script:
- ./build/tests/unit_tests/unit-tests --log_format=JUNIT --log_sink=report.xml
artifacts:
when: always
paths:
- report.xml
reports:
junit: report.xml
expire_in: 1 week
rules:
- if: $CI_PIPELINE_SOURCE == 'merge_request_event'
# Run integrated tests and generate a test report
integrated-test:
stage: test-stage
tags:
- docker
- linux-x86
image: $CI_REGISTRY/hdtn-v4/hdtn/debian-base
needs:
- build-default
dependencies:
- build-default
script:
- ./build/tests/integrated_tests/integrated-tests --log_format=JUNIT --log_sink=report.xml
artifacts:
when: always
paths:
- report.xml
reports:
junit: report.xml
expire_in: 1 week
rules:
- if: $CI_PIPELINE_SOURCE == 'merge_request_event'
# Static Analysis Legacy defects
static-analysis-legacy:
stage: scan-stage
tags:
- cov-analysis
dependencies:
- build-static-analysis
needs:
- build-static-analysis
script:
- git fetch --prune
- export PATH=/home/hdtn/cov-analysis-linux64-2022.6.1/bin:$PATH
- export files_to_scan=$(git diff --diff-filter=d --name-only origin/$CI_MERGE_REQUEST_TARGET_BRANCH_NAME origin/$CI_MERGE_REQUEST_SOURCE_BRANCH_NAME | grep '\.cpp')
- if [ "$files_to_scan" != "" ]; then cov-run-desktop --dir build/idir --url $COV_BUILD_SERVER --auth-key-file /home/hdtn/ci-auth.key --stream HDTN-development --exit1-if-defects true --ignore-uncapturable-inputs true --present-in-reference true --all --enable-constraint-fpp --enable-fnptr --enable-virtual $files_to_scan; else echo "No files to scan"; fi
rules:
- if: $CI_PIPELINE_SOURCE == 'merge_request_event'
allow_failure: true
# Static Analysis New defects
static-analysis-new:
stage: scan-stage
tags:
- cov-analysis
dependencies:
- build-static-analysis
needs:
- build-static-analysis
script:
- git fetch --prune
- export PATH=/home/hdtn/cov-analysis-linux64-2022.6.1/bin:$PATH
- export files_to_scan=$(git diff --diff-filter=d --name-only origin/$CI_MERGE_REQUEST_TARGET_BRANCH_NAME origin/$CI_MERGE_REQUEST_SOURCE_BRANCH_NAME | grep '\.cpp')
- if [ "$files_to_scan" != "" ]; then cov-run-desktop --dir build/idir --url $COV_BUILD_SERVER --auth-key-file /home/hdtn/ci-auth.key --stream HDTN-development --exit1-if-defects true --ignore-uncapturable-inputs true --present-in-reference false --all --enable-constraint-fpp --enable-fnptr --enable-virtual $files_to_scan; else echo "No files to scan"; fi
rules:
- if: $CI_PIPELINE_SOURCE == 'merge_request_event'
# Static Analysis Development Defects
static-analysis-development:
stage: scan-stage
tags:
- cov-analysis
dependencies:
- build-static-analysis
needs:
- build-static-analysis
script:
- export HDTN_SOURCE_ROOT=$PWD
- export PATH=/home/hdtn/cov-analysis-linux64-2022.6.1/bin:$PATH
- cov-analyze --dir build/idir --all --enable-constraint-fpp --enable-fnptr --enable-virtual --strip-path $HDTN_SOURCE_ROOT
- cov-commit-defects --dir build/idir --url $COV_BUILD_SERVER --stream HDTN-development --auth-key-file /home/hdtn/auth-gitlab.key
rules:
- if: $DO_MONTHLY_SLOC_COUNT == "true"
when: never
- if: $CI_PIPELINE_SOURCE == "schedule"
# Code test coverage
code-test-coverage:
stage: scan-stage
tags:
- docker
- linux-x86
image: $CI_REGISTRY/hdtn-v4/hdtn/debian-base
script:
- export HDTN_SOURCE_ROOT=$PWD
- mkdir -p build
- cmake -S . -B build -DCMAKE_BUILD_TYPE=Coverage -DDO_STATS_LOGGING:BOOL=ON
- make -C build/ -j8
- cd build
# Clean up lcov
- lcov --gcov-tool /usr/bin/gcov -directory $HDTN_SOURCE_ROOT -b . --zerocounters
# Create baseline
- lcov --gcov-tool /usr/bin/gcov -c -i -d $HDTN_SOURCE_ROOT -b . -o coverage.base --no-external --branch-coverage --ignore-errors mismatch,negative
# Run tests
- ./tests/unit_tests/unit-tests
- ./tests/integrated_tests/integrated-tests
# Capture lcov counters and generate report
- lcov --gcov-tool /usr/bin/gcov --directory $HDTN_SOURCE_ROOT -b . --capture --output-file coverage.capture --no-external --branch-coverage --ignore-errors mismatch,negative
# Add baseline counters
- lcov --gcov-tool /usr/bin/gcov -a coverage.base -a coverage.capture --output-file coverage.total --no-external --branch-coverage --ignore-errors mismatch,negative
# Filter collected data
- lcov --gcov-tool /usr/bin/gcov --remove coverage.total "**/unit_tests/**" "**/integrated_tests/**" "**/test/**" "**/CMakeCXXCompilerId.cpp" --output-file coverage.info --no-external --branch-coverage --ignore-errors mismatch,negative,unused
# Generate reports
- genhtml -o coverage coverage.info --ignore-errors source --branch-coverage --filter branch
- gcovr --xml coverage.xml -r $HDTN_SOURCE_ROOT -e .*/unit_tests/.* -e .*/integrated_tests/.* -e .*/test/.* -e .*/CMakeCXXCompilerId.cpp --object-directory=. --gcov-ignore-parse-errors
dependencies: []
needs: []
cache:
key: code-coverage-$CI_MERGE_REQUEST_TARGET_BRANCH_NAME-$CI_MERGE_REQUEST_ID
paths:
- build
artifacts:
reports:
coverage_report:
coverage_format: cobertura
path: build/coverage.xml
paths:
- build/coverage
expire_in: 1 week
coverage: '/^ lines.*: (\d+\.\d+\%).*$/'
rules:
- if: $CI_PIPELINE_SOURCE == 'merge_request_event'
- if: $CI_PIPELINE_SOURCE == "schedule"
# SLOC
sloc-count:
stage: scan-stage
tags:
- docker
- linux-x86
image: $CI_REGISTRY/hdtn-v4/hdtn/debian-base
script:
- git fetch --prune
- git reset --hard origin/$CI_MERGE_REQUEST_SOURCE_BRANCH_NAME
- ./ci/cloc.sh "origin/$CI_MERGE_REQUEST_TARGET_BRANCH_NAME" "origin/$CI_MERGE_REQUEST_SOURCE_BRANCH_NAME"
dependencies: []
needs: []
artifacts:
expose_as: 'SLOC Counts'
name: sloc-counts
paths:
- reports
expire_in: 1 month
rules:
- if: $CI_PIPELINE_SOURCE == 'merge_request_event'
# Monthly SLOC
monthly-sloc-count:
stage: scan-stage
tags:
- docker
- linux-x86
image: $CI_REGISTRY/hdtn-v4/hdtn/debian-base
script:
# Get SLOC counts from the beginning of the previous month to now
- git fetch --prune
- git checkout $CI_COMMIT_BRANCH
- git reset --hard origin/$CI_COMMIT_BRANCH
- current_date=$(date +"%Y-%m-%d")
- first_day_of_previous_month=$(date -d "$current_date -1 month" +"%Y-%m-01 00:00:00")
- echo "Getting SLOC counts from $first_day_of_previous_month to now"
- git_commit=$(git log --before="$first_day_of_previous_month" -n 1 --pretty=format:"%H")
- ./ci/cloc.sh $git_commit "origin/$CI_COMMIT_BRANCH"
dependencies: []
needs: []
artifacts:
name: sloc-counts
paths:
- reports
expire_in: 1 month
rules:
- if: $CI_PIPELINE_SOURCE == "schedule"
- if: $DO_MONTHLY_SLOC_COUNT == "true"
# Issue Count
issue-count:
stage: scan-stage
tags:
- docker
- linux-x86
image: $CI_REGISTRY/hdtn-v4/hdtn/debian-base
script:
- current_date=$(date +"%Y-%m-01T00:00:00.000Z")
- first_day_of_previous_month=$(date -d "$current_date -1 month" +"%Y-%m-01T00:00:00.000Z")
- echo "Getting issue counts from $first_day_of_previous_month to now"
- python3 ci/count_issues.py $first_day_of_previous_month $current_date
dependencies: []
needs: []
rules:
- if: $CI_PIPELINE_SOURCE == "schedule"
- if: $DO_MONTHLY_SLOC_COUNT == "true"