-
Notifications
You must be signed in to change notification settings - Fork 6
/
.gitlab-ci.yml
287 lines (254 loc) · 7.25 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
workflow:
rules:
- if: $CI_MERGE_REQUEST_ID
when: always
- if: '$CI_COMMIT_BRANCH == "master"'
when: always
- if: $CI_COMMIT_TAG
when: always
- when: never
default:
tags:
- docker
stages:
- build
- test
- publish
variables:
ALMALINUX8_IMAGE: "registry.esss.lu.se/ecdc/ess-dmsc/build-nodes/almalinux8:1.0"
CENTOS7_IMAGE: "registry.esss.lu.se/ecdc/ess-dmsc/build-nodes/centos7:1.0"
UBUNTU2204_IMAGE: "registry.esss.lu.se/ecdc/ess-dmsc/build-nodes/ubuntu2204:1.0"
DEBIAN11_IMAGE: "registry.esss.lu.se/ecdc/ess-dmsc/build-nodes/debian11:1.0"
# Job template to reduce duplication
.build_template: &build_template
before_script:
- |
if [ -f /etc/os-release ]; then
. /etc/os-release
if [[ "$ID" == "almalinux" ]]; then
echo 'source scl_source enable gcc-toolset-12' >> ~/.bashrc
source ~/.bashrc
elif [[ "$ID" == "centos" ]]; then
echo 'source /opt/rh/devtoolset-11/enable' >> ~/.bashrc
source ~/.bashrc
fi
fi
- |
conan remote add \
--insert 0 \
--force \
ecdc-conan-external https://artifactory.esss.lu.se/artifactory/api/conan/ecdc-conan-external
- cmake --version
- gcc --version
- g++ --version
- cppcheck --version
- git config --global --add safe.directory '*'
build_job:
<<: *build_template
parallel:
matrix:
- NAME : "almalinux8"
CONTAINER_IMAGE: $ALMALINUX8_IMAGE
- NAME: "centos7"
CONTAINER_IMAGE: $CENTOS7_IMAGE
- NAME: "ubuntu2204"
CONTAINER_IMAGE: $UBUNTU2204_IMAGE
stage: build
image: $CONTAINER_IMAGE
dependencies: []
cache:
key: "$CI_COMMIT_SHA-$CONTAINER_IMAGE"
paths:
- build/
artifacts:
paths:
- build/bin
- build/generators
- build/lib
- build/licenses
- build/CONAN_INFO
expire_in: 1 day
script:
- echo "Running on $NAME"
- mkdir -p build
- cd build
# Check if build artifacts already exist
- if [ "$(ls -A build/bin 2>/dev/null)" ]; then
echo "Build artifacts found, skipping build.";
else
echo "No build artifacts found, proceeding to build.";
echo "Installing dependencies";
conan install --build=outdated ..;
conan info ../conanfile.txt > CONAN_INFO;
echo "Configuring with CMake";
cmake -DCONAN=MANUAL -DGOOGLE_BENCHMARK=ON -DCMAKE_BUILD_TYPE=Release -DCMAKE_SKIP_BUILD_RPATH=ON ..;
echo "Building project";
make -j$(nproc) all;
make;
fi
rules:
- if: $CI_MERGE_REQUEST_ID
when: on_success
- if: '$CI_COMMIT_BRANCH == "master"'
when: on_success
- if: $CI_COMMIT_TAG
when: on_success
- when: never
clangformat_test_job:
stage: test
image: $DEBIAN11_IMAGE
dependencies: []
before_script:
- export HTTP_PROXY="http://172.20.72.11:8888"
- export HTTPS_PROXY="http://172.20.72.11:8888"
- export NO_PROXY="localhost,127.0.0.1"
variables:
TEST_OUTPUT: cppcheck.xml
script:
- |
cppcheck -j$(nproc) \
-v `./cppcheck_exclude_tests.sh src` \
--platform=unix64 \
--force \
--enable=all \
-I ./src \
'--template={file},{line},{severity},{id},{message}' \
--xml --xml-version=2 \
./src --output-file=$TEST_OUTPUT
artifacts:
reports:
codequality: $TEST_OUTPUT
paths:
- $TEST_OUTPUT
rules:
- if: $CI_MERGE_REQUEST_ID
when: on_success
- when: never
unit_test_job:
stage: test
image: $CENTOS7_IMAGE
dependencies: []
<<: *build_template
script:
- mkdir -p build
- cd build
- echo "Installing dependencies"
- conan install --build=outdated ..
- echo "Configuring with CMake"
- |
cmake \
-DCONAN=MANUAL \
-DGOOGLE_BENCHMARK=ON \
-DCOV=ON \
..
- make -j$(nproc) runtest
- make -j$(nproc) runefu
- make -j$(nproc) coverage
artifacts:
reports:
junit: build/test_results/*.xml
coverage_report:
coverage_format: cobertura
path: build/coverage/coverage.xml
rules:
- if: '$CI_COMMIT_BRANCH == "master"'
when: on_success
- if: $CI_MERGE_REQUEST_ID
when: on_success
- when: never
publish_tar_job:
stage: publish
image: alpine:latest
dependencies: [build_job]
artifacts:
paths:
- event-formation-unit-centos7.tar.gz
needs:
- job: build_job
parallel:
matrix:
- NAME: "centos7"
CONTAINER_IMAGE: $CENTOS7_IMAGE
script:
- apk update
- apk add --no-cache bash tar
- mkdir -p archive/event-formation-unit
- cp -r build/bin archive/event-formation-unit
- cp -r build/generators archive/event-formation-unit
- cp -r build/lib archive/event-formation-unit
- cp -r build/licenses archive/event-formation-unit
- mkdir archive/event-formation-unit/util
- cp -r utils/efushell archive/event-formation-unit/util
- mkdir archive/event-formation-unit/configs
- mkdir archive/event-formation-unit/data
- cp build/CONAN_INFO archive/event-formation-unit
# - # Create file with build information
- touch archive/event-formation-unit/BUILD_INFO
- echo 'Repository replace_real_repo_name' >> archive/event-formation-unit/BUILD_INFO
- echo 'Commit replace_git_commit' >> archive/event-formation-unit/BUILD_INFO
- echo 'Jenkins build replace_build_id' >> archive/event-formation-unit/BUILD_INFO
- tar czvf event-formation-unit-centos7.tar.gz archive/event-formation-unit
rules:
- if: >
$CI_COMMIT_BRANCH == "master" &&
($CI_PIPELINE_SOURCE == "push" ||
$CI_PIPELINE_SOURCE == "merge_request_event" ||
$CI_PIPELINE_SOURCE == "web")
- if: $CI_COMMIT_TAG
when: on_success
- when: never
publish_docker_job:
parallel:
matrix:
- INSTRUMENT: "bifrost"
- INSTRUMENT: "cbm"
- INSTRUMENT: "cspec"
- INSTRUMENT: "dream"
- INSTRUMENT: "estia"
- INSTRUMENT: "freia"
- INSTRUMENT: "heimdal"
- INSTRUMENT: "loki"
- INSTRUMENT: "magic"
- INSTRUMENT: "miracles"
- INSTRUMENT: "nmx"
- INSTRUMENT: "tbl3he"
- INSTRUMENT: "timepix3"
- INSTRUMENT: "trex"
stage: publish
image: docker:latest
services:
- docker:dind
variables:
IMAGE_NAME: "$CI_REGISTRY_IMAGE/efu-$INSTRUMENT"
dependencies: [build_job]
needs:
- job: build_job
parallel:
matrix:
- NAME: "almalinux8"
CONTAINER_IMAGE: $ALMALINUX8_IMAGE
script:
- echo "Publishing docker image"
- |
docker login \
-u "$CI_REGISTRY_USER" \
-p "$CI_REGISTRY_PASSWORD" \
"$CI_REGISTRY"
- |
docker build \
--build-arg https_proxy="http://172.20.72.11:8888" \
--build-arg http_proxy="http://172.20.72.11:8888" \
--build-arg INSTRUMENT_NAME=$INSTRUMENT \
-t "$IMAGE_NAME" \
-f .ci/docker/Dockerfile.deploy .
- docker push "$IMAGE_NAME"
rules:
- if: >
$CI_COMMIT_BRANCH == "master" &&
($CI_PIPELINE_SOURCE == "push" ||
$CI_PIPELINE_SOURCE == "merge_request_event" ||
$CI_PIPELINE_SOURCE == "web")
when: on_success
- if: $CI_COMMIT_TAG
when: on_success
- when: never