-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
358 lines (348 loc) · 12 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
# Prevent duplicated pipeline by removing MR pipelines # We leave it so that the pipeline badge is good
#workflow:
# rules:
# - if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
# when: never
# - when: always
# Check out also this one https://stackoverflow.com/questions/69812129/gitlab-ci-if-mr-exist-just-trigger-merge-request-detach-pipeline-if-not-trigge/69819558#69819558
# Triggers on merge resuests, branch pipelines UNLESS there is an open merge requests
workflow:
rules:
- if: $CI_COMMIT_TAG
when: never
- if: '$CI_PIPELINE_SOURCE == "merge_request_event"'
- if: '$CI_COMMIT_BRANCH && $CI_OPEN_MERGE_REQUESTS'
when: never
- if: '$CI_COMMIT_BRANCH'
variables:
GIT_STRATEGY: none # Do nothing by default. It will be done once in init, then other we reuse it
GIT_SUBMODULE_STRATEGY: none
# SCHEDULER_PARAMETERS: "--clusters c1 --qos=c1_test_giga --ntasks=1 --time=00:15:00" # Attention c1 is DAAA partition, hence this works only with DAAA users
#Common to all stages
default:
tags: # Use shell instead of submitting pipeline to slurm
- shell
# - slurm
before_script:
- module purge
# Load python version, compilers
- source /stck/rmilani/GitLab_CI_envs/CoMMA_env.sh
# Adding installed pybind11 to CMAKE_PREFIX_PATH (it has been installed with pip)
- export CMAKE_PREFIX_PATH=/stck/rmilani/.local/lib/python3.10/site-packages/pybind11:$CMAKE_PREFIX_PATH
# Adding installed Catch2 to CMAKE_PREFIX_PATH
- export CMAKE_PREFIX_PATH=/stck/rmilani/opt/Catch2/install:$CMAKE_PREFIX_PATH
# GitLab Server v17.0+
id_tokens:
CI_JOB_JWT:
aud: https://gitlab.onera.net
stages:
- init
- configure
- build
- test
- lint_format
- lint_format_python
- documentation
.rules_changes_anything:
rules:
- changes:
- include/CoMMA/*.{h,md}
- src/*.cpp
- tests/*.{cpp,h}
- CMakeLists.txt
- .gitlab-ci.yml
- Documentation/Doxyfile
- .clang-format
- .clang-tidy
- examples/cpp*.{cpp,h}
- examples/scripts/*.py
- examples/scripts/pyproject.toml
- config_files/*
.rules_changes_sources:
rules:
- changes:
- include/CoMMA/*.h
- src/*.cpp
- tests/*.{cpp,h}
- CMakeLists.txt
- .gitlab-ci.yml
- config_files/*
.rules_changes_sources_linting:
rules:
- changes:
- include/CoMMA/*.h
- src/*.cpp
- tests/*.{cpp,h}
- CMakeLists.txt
- .gitlab-ci.yml
- .clang-format
- .clang-tidy
- config_files/*
- examples/cpp*.{cpp,h}
.rules_changes_python:
rules:
- changes:
- examples/scripts/*.py
- examples/scripts/pyproject.toml
- config_files/*
job:init:
stage: init
variables:
GIT_STRATEGY: clone
# GIT_SUBMODULE_STRATEGY: none # Do it manually to avoid some unused submodules # Superseded
rules:
- !reference [.rules_changes_anything, rules]
script:
# Ensure that everything from previous CI is cleaned
- rm -rf build* install
# Set a commun directory and make it available, Create it at the root dir, so that it is found
# See https://docs.gitlab.com/ee/ci/variables/#pass-an-environment-variable-to-another-job
- echo "CUSTOM_CI_DIR=$PWD" >> build.env
- echo "INSTALL_DIR=\$CUSTOM_CI_DIR/install" >> build.env
- echo "EXAMPLES_DIR=\$CUSTOM_CI_DIR/examples" >> build.env
- echo "PYTHON_DIR=\$EXAMPLES_DIR/scripts" >> build.env
- echo "TESTS_DIR=\$CUSTOM_CI_DIR/tests" >> build.env
# See if python tools are installed (here, we have already sourced the env,
# see default:before_script, so it's OK
- python3 -c "import gcovr" || python3 -m pip install --user gcovr
- python3 -m black --version || python3 -m pip install --user black
- python3 -m isort --version || python3 -m pip install --user isort
- python3 -m ruff --version || python3 -m pip install --user ruff
- python3 -m pytest --version || python3 -m pip install --user pytest
artifacts:
reports:
dotenv: ./build.env
job:configure_dbg:
stage: configure
needs: ['job:init']
rules:
- !reference [.rules_changes_sources_linting, rules]
script:
- cd $CUSTOM_CI_DIR
- mkdir -p build
- cd build
- cmake -DCODAFLAGS=On -DCOVERAGE=On -DCMAKE_INSTALL_PREFIX=${INSTALL_DIR} ..
job:build_dbg:
stage: build
# We need job:init artifacts so leave it
needs: ['job:init', 'job:configure_dbg']
rules:
- !reference [.rules_changes_sources_linting, rules]
script:
- cd $CUSTOM_CI_DIR/build
- make -j
- make install
#artifacts:
# expire_in: 1 month
# paths:
# # The path is taken from the initial directory, hence we specify the full path
# - $CUSTOM_CI_DIR/build
job:test_dbg:
stage: test
needs: ['job:init', 'job:build_dbg']
rules:
- !reference [.rules_changes_sources, rules]
script:
- cd $CUSTOM_CI_DIR/build
- ./CoMMA_test -r junit > test_a.xml
- python3 -m gcovr --xml-pretty --exclude '\.\./pybind11/' --exclude '\.\./Catch2/' --exclude '\.\./perfetto/' --exclude '\.\./build_rel.*/' --exclude '\.\./src/CoMMA.cpp' --exclude '\.\./config_files/' --exclude '\.\./misc_scripts/' --print-summary -o coverage.xml --root ..
coverage: /^\s*lines:\s*\d+.\d+\%/
artifacts:
expire_in: 1 month
reports:
# The path is taken from the initial directory, hence we specify the full path
junit: $CUSTOM_CI_DIR/build/test_a.xml
coverage_report:
coverage_format: cobertura
path: $CUSTOM_CI_DIR/build/coverage.xml
job:test_examples_dbg:
stage: test
needs: ['job:init', 'job:build_dbg']
rules:
- !reference [.rules_changes_sources, rules]
script:
- cd $CUSTOM_CI_DIR/build
# This is typically what pkgconfig should return + TEST_DIR
- g_opt="-I${INSTALL_DIR}/include -L${INSTALL_DIR}/lib64"
- g++ ${EXAMPLES_DIR}/cpp/ex_aniso_lines.cpp -o example ${g_opt}
- ./example
- g++ ${EXAMPLES_DIR}/cpp/ex_coarse_graph.cpp -o example ${g_opt}
- ./example
job:test_python_dbg:
stage: test
needs: ['job:init', 'job:build_dbg']
rules:
- !reference [.rules_changes_sources, rules]
script:
- pyv=$(python3 --version | awk -F '[ .]' '{print $2"."$3}')
# equivalent to
# - pyv=$(python3 -c "import sys;print('{}.{}'.format(sys.version_info[0],sys.version_info[1]))")
# Add path to CoMMA module to PATH
- export PYTHONPATH=${INSTALL_DIR}/lib64/python${pyv}/site-packages:$PYTHONPATH
- export PYTHONPATH=${INSTALL_DIR}/lib/python${pyv}/site-packages:$PYTHONPATH
- cd ${PYTHON_DIR}
- python3 -m pytest
job:test_install_pkgconfig:
stage: test
needs: ['job:init', 'job:build_dbg']
rules:
- changes:
- include/CoMMA/*.h
- CMakeLists.txt
- .gitlab-ci.yml
- config_files/*.in
script:
- cd $CUSTOM_CI_DIR/build
- export PKG_CONFIG_PATH=${INSTALL_DIR}/lib64/pkgconfig:${PKG_CONFIG_PATH}
- pkg-config --exists --print-errors comma
- g++ ../misc_scripts/test_pkgconfig_compile.cpp -o test_pkgconfig_compile `pkg-config --cflags --libs comma`
job:configure_rel:
stage: configure
needs: ['job:init']
rules:
- !reference [.rules_changes_sources, rules]
script:
- cd $CUSTOM_CI_DIR
- mkdir -p build_rel
- cd build_rel
- cmake -DCODAFLAGS=On -DCMAKE_BUILD_TYPE=RelWithDebInfo -DBUILD_PYTHON_BINDINGS=Off ..
job:build_rel:
stage: build
needs: ['job:init', 'job:configure_rel']
rules:
- !reference [.rules_changes_sources, rules]
script:
- cd $CUSTOM_CI_DIR/build_rel
- make -j
job:test_rel:
stage: test
needs: ['job:init', 'job:build_rel']
rules:
- !reference [.rules_changes_sources, rules]
script:
- cd $CUSTOM_CI_DIR/build_rel
- ./CoMMA_test
job:configure_rel32:
stage: configure
needs: ['job:init']
rules:
- !reference [.rules_changes_sources, rules]
script:
- cd $CUSTOM_CI_DIR
- mkdir -p build_rel32
- cd build_rel32
- cmake -DCODAFLAGS=On -DCMAKE_BUILD_TYPE=RelWithDebInfo -DINT_T="int32_t" -DINDEX_T="uint32_t" -DBUILD_PYTHON_BINDINGS=Off ..
job:build_rel32:
stage: build
needs: ['job:init', 'job:configure_rel32']
rules:
- !reference [.rules_changes_sources, rules]
script:
- cd $CUSTOM_CI_DIR/build_rel32
- make -j
job:test_rel32:
stage: test
needs: ['job:init', 'job:build_rel32']
rules:
- !reference [.rules_changes_sources, rules]
script:
- cd $CUSTOM_CI_DIR/build_rel32
- ./CoMMA_test
job:configure_rel64:
stage: configure
needs: ['job:init']
rules:
- !reference [.rules_changes_sources, rules]
script:
- cd $CUSTOM_CI_DIR
- mkdir -p build_rel64
- cd build_rel64
- cmake -DCODAFLAGS=On -DCMAKE_BUILD_TYPE=RelWithDebInfo -DINT_T="int64_t" -DINDEX_T="uint64_t" -DBUILD_PYTHON_BINDINGS=Off ..
job:build_rel64:
stage: build
needs: ['job:init', 'job:configure_rel64']
rules:
- !reference [.rules_changes_sources, rules]
script:
- cd $CUSTOM_CI_DIR/build_rel64
- make -j
job:test_rel64:
stage: test
needs: ['job:init', 'job:build_rel64']
rules:
- !reference [.rules_changes_sources, rules]
script:
- cd $CUSTOM_CI_DIR/build_rel64
- ./CoMMA_test
job:clang_tidy:
stage: lint_format
# Need compile_commands
needs: ['job:init', 'job:configure_dbg']
rules:
- !reference [.rules_changes_sources_linting, rules]
# Select only changed files otherwise too long
script:
- cd $CUSTOM_CI_DIR
- CHANGED_FILES=$(git diff --name-only $CI_COMMIT_BEFORE_SHA $CI_COMMIT_SHA | grep ".*\.\(h\|cpp\)" || true)
- if [[ ! -z $CHANGED_FILES ]]; then clang-tidy -p build/compile_commands.json --warnings-as-errors="*" $CHANGED_FILES; else echo "Nothing to do"; fi
allow_failure: true
job:clang_format:
stage: lint_format
needs: ['job:init']
rules:
- !reference [.rules_changes_sources_linting, rules]
script:
- cd $CUSTOM_CI_DIR
- git ls-tree --name-only -r HEAD include/CoMMA src tests examples/cpp config_files | grep ".*\.\(h\|cpp\)\(\.in\)\?" | xargs /stck/rmilani/.local/bin/clang-format --style=file --dry-run --Werror
allow_failure: true
job:black:
stage: lint_format_python
needs: ['job:init']
rules:
- !reference [.rules_changes_python, rules]
script:
- cd ${PYTHON_DIR}
- python3 -m black --check *.py
allow_failure: true
job:isort:
stage: lint_format_python
needs: ['job:init']
rules:
- !reference [.rules_changes_python, rules]
script:
- cd ${PYTHON_DIR}
- python3 -m isort --check *.py
allow_failure: true
job:ruff:
stage: lint_format_python
needs: ['job:init']
rules:
- !reference [.rules_changes_python, rules]
script:
- cd ${PYTHON_DIR}
- python3 -m ruff check *.py
allow_failure: true
pages:
stage: documentation
needs:
- job: 'job:init'
- job: 'job:test_dbg'
artifacts: false
script:
- cd $CUSTOM_CI_DIR
- rm -rf documentation
- doxygen Documentation/Doxyfile
- cd -
- rm -rf public
- cp -r ${CUSTOM_CI_DIR}/documentation/html public
artifacts:
expire_in: 1 month
paths:
- public
rules:
- if: $CI_COMMIT_REF_NAME == $CI_DEFAULT_BRANCH
changes:
- include/CoMMA/*.{h,md}
- src/*.cpp
- .gitlab-ci.yml
- Documentation/Doxyfile