-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path.gitlab-ci.yml
251 lines (239 loc) · 7.9 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
workflow:
rules:
- if: $CI_PIPELINE_SOURCE == "merge_request_event" && $CI_MERGE_REQUEST_TITLE =~ /^(WIP:|Draft:)/
when: never
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
- if: $CI_COMMIT_BRANCH
stages:
- build test images
- test
variables:
IMAGE_PATH: $CI_REGISTRY_IMAGE/$CI_COMMIT_REF_SLUG
################################
# Build images to run the tests
################################
docker build images:
stage: build test images
rules:
- if: $CI_COMMIT_BRANCH
changes:
- ci/dev_tools/Dockerfile
image: docker:27.1.2
services:
- docker:27.1.2-dind
variables:
# Use TLS https://docs.gitlab.com/ee/ci/docker/using_docker_build.html#tls-enabled
DOCKER_TLS_CERTDIR: "/certs"
before_script:
- echo $CI_REGISTRY_PASSWORD | docker login -u $CI_REGISTRY_USER --password-stdin $CI_REGISTRY
script:
- |-
for TARGET in latest old_gcc old_clang
do
BRANCH_IMAGE=$IMAGE_PATH/dev_tools:$TARGET
MAIN_IMAGE=$CI_REGISTRY_IMAGE/$CI_DEFAULT_BRANCH/dev_tools:$TARGET
docker build --target $TARGET --tag $BRANCH_IMAGE \
--cache-from $BRANCH_IMAGE \
--cache-from $MAIN_IMAGE \
--build-arg BUILDKIT_INLINE_CACHE=1 \
ci/dev_tools
docker push $BRANCH_IMAGE
done
#############################
# Test delegates
#############################
# Tests:
# - unit test with coverage, asan and ubsan
# - expected compile errors
# - correctness of examples
# Runs with each commit.
test:latest-clang-extended:
stage: test
rules:
- if: $CI_COMMIT_BRANCH
image: $IMAGE_PATH/dev_tools:latest
variables:
PRESET: clang-cpp14-instr
NAME: latest-$PRESET
script:
- cmake --version
- cmake --preset $PRESET -B build
- cd build
- ninja unittest
- cd test
# run unittest and report errors from asan and ubsan
- ./unittest --reporters=junit 2>sanitizer-errors.txt | xml edit --inplace --update "//testsuite/@name" --value "$NAME - unittest" >unittest-report.xml
- "{ [ ! -s sanitizer-errors.txt ] || (cat sanitizer-errors.txt >&2; exit 1) }"
# create coverage reports
- llvm-profdata merge -sparse default.profraw -o ut.profdata
- >-
llvm-cov report unittest -instr-profile=ut.profdata -ignore-filename-regex=test/include/test/.+hpp
| awk '/rome\/delegate.hpp/ {print "Code coverage: " $4 " of regions in `" $1 "` covered."}'
- >-
llvm-cov export unittest -instr-profile=ut.profdata -format=lcov -ignore-filename-regex=test/.*
| lcov2xml --demangle --demangler c++filt --base-dir ../.. -o coverage.xml -
- >-
llvm-cov show unittest -instr-profile=ut.profdata --output-dir=coverage -format=html -ignore-filename-regex=test/include/test/.+hpp
-show-branches=count -show-instantiations=true -show-line-counts=true -show-expansions=true -show-regions=true -Xdemangler c++filt -Xdemangler -n
- cd ..
# test compile errors
- ninja compile_error_tests
- |-
ERR=0; ctest --test-dir test/compile_errors --quiet --parallel --output-junit ../compile-error-test-report.xml || ERR=1
xml edit --inplace --update "//testsuite/@name" --value "$NAME - compile errors" test/compile-error-test-report.xml
[ $ERR -eq 0 ]
# test examples
- ninja examples
- |-
ERR=0; ctest --test-dir test/examples --quiet --parallel --output-junit ../examples-test-report.xml || ERR=1
xml edit --inplace --update "//testsuite/@name" --value "$NAME - examples" test/examples-test-report.xml
[ $ERR -eq 0 ]
coverage: '/^Code coverage:\s+\d+\.\d+%/'
artifacts:
reports:
coverage_report:
coverage_format: cobertura
path: build/test/coverage.xml
junit: build/test/*test-report.xml
name: $NAME
paths:
- build/
when: on_failure
expire_in: 1 week
# Tests:
# - unit test (no instrumentation)
# - expected compile errors
# Runs manually or for merge request and on main branch.
# Uses latest compilers and CMake.
test:latest-linux:
stage: test
rules:
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
when: manual
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
- if: $CI_COMMIT_BRANCH
when: manual
allow_failure: true
image: $IMAGE_PATH/dev_tools:latest
parallel:
matrix:
- PRESET: [clang-cpp23, gcc-cpp14, gcc-cpp23]
variables:
NAME: latest-$PRESET
script:
- cmake --version
- cmake --preset $PRESET -B build
- cd build
- ninja unittest
- ./test/unittest --reporters=junit | xml edit --inplace --update "//testsuite/@name" --value "$NAME - unittest" >test/unittest-report.xml
- ninja compile_error_tests
- |-
ERR=0; ctest --test-dir test/compile_errors --quiet --parallel --output-junit ../compile-error-test-report.xml || ERR=1
xml edit --inplace --update "//testsuite/@name" --value "$NAME - compile errors" test/compile-error-test-report.xml
[ $ERR -eq 0 ]
artifacts:
reports:
junit: build/test/*test-report.xml
name: $NAME
paths:
- build/
when: on_failure
expire_in: 1 week
# Tests:
# - unit test (no instrumentation)
# - expected compile errors
# Runs manually or for merge request and on main branch.
# Uses old compilers (clang++ 4.0, GCC 5.3) and older CMake (3.20).
test:old-linux:
stage: test
rules:
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
when: manual
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
- if: $CI_COMMIT_BRANCH
when: manual
allow_failure: true
parallel:
matrix:
- COMPILER: [clang, gcc]
image: $IMAGE_PATH/dev_tools:old_$COMPILER
variables:
PRESET: $COMPILER-cpp14
NAME: old-$PRESET
script:
- cmake --version
- cmake --preset $PRESET -B build -G "Unix Makefiles"
- cd build
- make unittest
- ./test/unittest --reporters=junit | xml edit --inplace --update "//testsuite/@name" --value "$NAME - unittest" >test/unittest-report.xml
- make compile_error_tests
- ctest --test-dir test/compile_errors --parallel
artifacts:
reports:
junit: build/test/*test-report.xml
name: $NAME
paths:
- build/
when: on_failure
expire_in: 1 week
# Tests:
# - unit test (no instrumentation)
# - expected compile errors
# Runs manually or for merge request and on main branch.
# Uses latest MSVC compiler.
test:msvc:
stage: test
rules:
- when: never # a C++ build tool and cl.exe were not found in the current windows runners
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
when: manual
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
- if: $CI_COMMIT_BRANCH
when: manual
allow_failure: true
tags:
- saas-windows-medium-amd64
parallel:
matrix:
- CPP_VERSION: [cpp14, cpp23]
variables:
PRESET: msvc-$CPP_VERSION
NAME: $PRESET
script:
- cmake --version
- try {nmake} catch {write $_}
- try {cl /?} catch {write $_}
- try {ninja --version} catch {write $_}
- try {make --version} catch {write $_}
- cmake --preset $PRESET -B build -G "Ninja"
- cd build
- ninja unittest
- |-
$xml = [xml](./test/unittest --reporters=junit)
$xml.testsuites.testsuite.name = "$NAME - unittest"
$xml.OuterXml | Set-Content test/unittest-report.xml
- ninja compile_error_tests
- ctest --test-dir test/compile_errors --parallel
artifacts:
reports:
junit: build/test/*test-report.xml
name: $NAME
paths:
- build/
when: on_failure
expire_in: 1 week
# Analyzes code quality with clang-tidy.
# Uses latest Clang.
clang-tidy:
stage: test
rules:
- if: $CI_PIPELINE_SOURCE == "merge_request_event"
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
- if: $CI_COMMIT_BRANCH
when: manual
allow_failure: true
image: $IMAGE_PATH/dev_tools:latest
script:
- clang-tidy --version
- cmake --preset clang-cpp14 -B build
- ninja clang_tidy -C build