-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy path.gitlab-ci.yml
398 lines (357 loc) · 9.96 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
# to use the env-var "GIT_CLONE_PATH", set the following in
# ./gitlab-runner/config.toml under [[runners]]:
# [runners.custom_build_dir]
# enabled = true
# This will prevent git clone conflicts for jobs ran in parallel
variables:
GIT_DEPTH: 10
GIT_CLONE_PATH: $CI_BUILDS_DIR/$CI_RUNNER_SHORT_TOKEN/$CI_PROJECT_PATH/$CI_COMMIT_REF_NAME/$CI_JOB_NAME
stages:
- info
- build
- check-cases
- code-analysis
- doc
- deploy
show-env-vars:
stage: info
variables:
GIT_STRATEGY: none
SEP: "##################################################################"
S00: "commit date - "
S01: "project: ${CI_PROJECT_PATH}"
S02: "branch: ${CI_COMMIT_REF_NAME}"
S03: "commit: ${CI_COMMIT_SHA}"
S04: "commit msg: ${CI_COMMIT_MESSAGE}"
S05: "clone base path: "
S06: "runner token: ${CI_RUNNER_SHORT_TOKEN}"
script:
- echo -e "${SEP}\n${S00}$(date)\n${SEP}\n${S01}\n${S02}\n${S03}\n${S04}\n${SEP}\n${S05}${GIT_CLONE_PATH}\n${S06}\n${SEP}"
#################
### TEMPLATES ###
#################
# template for documentation
.doc_template: &doc_template
when: always
stage: doc
needs: []
script:
- source hpc-module-loads/eve.chs-conda04
# checkout latest tag if there is at least one (and only for stable docs)
- if [ $(git rev-list --tags --max-count=1) ] && [ $DOC_TYPE == "stable" ]; then git checkout $(git describe --tags $(git rev-list --tags --max-count=1)); fi
- export PROJECT_NUMBER="$(cat version.txt)"
- doxygen doc/doxygen.config > doxygen_log_${DOC_TYPE}.txt 2>&1 # doxygen_log_stable.txt
- cd latex/ && tectonic -r 10 -Z continue-on-errors refman.tex > ../doxygen_latex_${DOC_TYPE}.txt 2>&1 # ../doxygen_latex_stable.txt
- cp refman.pdf ../html/mhm_doc.pdf # same name always
- cp refman.pdf ../mhm_doc_${DOC_TYPE}.pdf # ../mhm_doc_stable.pdf
- cd .. && mv html html_${DOC_TYPE} # html_stable
- mv doxygen_warn.txt doxygen_warn_${DOC_TYPE}.txt # doxygen_warn_stable.txt
artifacts:
name: "$CI_COMMIT_REF_NAME"
paths:
- html_*
- mhm_doc_*.pdf
- doxygen_*.txt
.cmake_template: &cmake_template
when: always
stage: build
script:
- source hpc-module-loads/eve.$COMPILER
- source CI-scripts/compile
- source CI-scripts/compile_debug
- source CI-scripts/compile_OpenMP
- source CI-scripts/compile_OpenMP_debug
artifacts:
paths:
- mhm
- mhm_debug
- mhm_openmp
- mhm_openmp_debug
.cmake_mpi_template: &cmake_mpi_template
when: always
stage: build
script:
- source hpc-module-loads/eve.$COMPILER
- source CI-scripts/compile_MPI
- source CI-scripts/compile_MPI_debug
artifacts:
paths:
- mhm_mpi
- mhm_mpi_debug
.check_template: &check_template
when: always
stage: check-cases
script:
- source hpc-module-loads/eve.$COMPILER
- source CI-scripts/pre_check
- python -u run_mhm_checks.py -l logs -e ../mhm_debug ../mhm ../mhm_openmp_debug ../mhm_openmp -t 4
artifacts:
when: always
paths:
- check/logs/
.check_mpi_template: &check_mpi_template
when: always
stage: check-cases
script:
- source hpc-module-loads/eve.$COMPILER
- source CI-scripts/pre_check
- python -u run_mhm_checks.py -l logs -e ../mhm_mpi_debug ../mhm_mpi -m 4
artifacts:
when: always
paths:
- check/logs/
.unittest_template: &unittest_template
when: always
stage: code-analysis
script:
# we need pfUnit
- source hpc-module-loads/eve.$COMPILER
# run cmake with testing support, build mhm and run pfunit tests
- cmake -DCMAKE_BUILD_TYPE=Debug -DBUILD_TESTING=ON -B build
- cmake --build build --parallel
- cmake --build build --target test
.valgrind_template: &valgrind_template
when: always
stage: code-analysis
script:
- source hpc-module-loads/eve.$COMPILER
- module load Mamba
- source activate /global/apps/mhm_checks/mhm_env
- valgrind --version
- valgrind --tool=memcheck --leak-check=full --show-leak-kinds=all --track-origins=yes --verbose ./mhm_debug
# execute mem-use check
- valgrind --tool=massif --stacks=yes --time-unit=i --massif-out-file=massif.out.0 ./mhm_debug
- ms_print massif.out.0
artifacts:
paths:
- massif.out.0
###################
### PY-BINDINGS ###
###################
pybindings:
stage: build
variables:
GIT_DEPTH: 0 # to have all tags
script:
- module load Mamba
- mamba create -p ./mhm_env -y python=3.11 pip netcdf-fortran fortran-compiler c-compiler cxx-compiler fypp python-build black isort pytest-cov xarray netCDF4
- source activate ./mhm_env
# check source code
- black --check --diff pybind
- isort --check --diff pybind
# create sdist and install it
- python -m build --sdist --outdir dist .
- pip install -v .
# check installation
- python -c "import mhm; print(mhm.__version__)"
- python -c "import mhm; print(mhm.f_version)"
- which mhm
- mhm --version
# will always download from main repo (no testing to prevent errors in forks)
- which mhm-download
- mhm-download -V
- mhm-download -h
- python -m pytest --cov mhm --cov-report term-missing --cov-report html --cov-report xml -v pybind/tests/
# check editable installation last to not mess with pytest
- pip install -v -e .
- rm -rf mhm_env/
coverage: '/(?i)total.*? (100(?:\.0+)?\%|[1-9]?\d(?:\.\d+)?\%)$/'
artifacts:
name: "$CI_COMMIT_REF_NAME"
reports:
coverage_report:
coverage_format: cobertura
path: coverage.xml
paths:
- dist
- htmlcov
####################
### COMPILE JOBS ###
####################
cmake-gfortran102:
variables:
COMPILER: gfortran102
<<: *cmake_template
cmake-gfortran102MPI:
variables:
COMPILER: gfortran102MPI
<<: *cmake_mpi_template
cmake-gfortran122:
variables:
COMPILER: gfortran122
<<: *cmake_template
cmake-gfortran122MPI:
variables:
COMPILER: gfortran122MPI
<<: *cmake_mpi_template
cmake-intel2020b:
variables:
COMPILER: intel2020b
<<: *cmake_template
cmake-intel2020bMPI:
variables:
COMPILER: intel2020bMPI
<<: *cmake_mpi_template
cmake-intel2023b-classic:
variables:
COMPILER: intel2023b-classic
<<: *cmake_template
cmake-intel2023bMPI-classic:
variables:
COMPILER: intel2023bMPI-classic
<<: *cmake_mpi_template
#################
### TEST JOBS ###
#################
check-gfortran102:
variables:
COMPILER: gfortran102
needs:
- job: cmake-gfortran102
artifacts: true
<<: *check_template
check-gfortran102MPI:
variables:
COMPILER: gfortran102MPI
needs:
- job: cmake-gfortran102MPI
<<: *check_mpi_template
check-gfortran122:
variables:
COMPILER: gfortran122
needs:
- job: cmake-gfortran122
artifacts: true
<<: *check_template
check-gfortran122MPI:
variables:
COMPILER: gfortran122MPI
needs:
- job: cmake-gfortran122MPI
artifacts: true
<<: *check_mpi_template
check-intel2020b:
variables:
COMPILER: intel2020b
needs:
- job: cmake-intel2020b
artifacts: true
<<: *check_template
check-intel2020bMPI:
variables:
COMPILER: intel2020bMPI
needs:
- job: cmake-intel2020bMPI
artifacts: true
<<: *check_mpi_template
check-intel2023b-classic:
variables:
COMPILER: intel2023b-classic
needs:
- job: cmake-intel2023b-classic
artifacts: true
<<: *check_template
check-intel2023bMPI-classic:
variables:
COMPILER: intel2023bMPI-classic
needs:
- job: cmake-intel2023bMPI-classic
artifacts: true
<<: *check_mpi_template
######################
### UNIT TEST JOBS ###
######################
unittest-gfortran122:
variables:
COMPILER: gfortran122
needs:
- job: cmake-gfortran122
<<: *unittest_template
unittest-intel2023b-classic:
variables:
COMPILER: intel2023b-classic
needs:
- job: cmake-intel2023b-classic
<<: *unittest_template
valgrind-gfortran122:
variables:
COMPILER: gfortran122
needs:
- job: cmake-gfortran122
artifacts: true
<<: *valgrind_template
valgrind-intel2023b-classic:
variables:
COMPILER: intel2023b-classic
needs:
- job: cmake-intel2023b-classic
artifacts: true
<<: *valgrind_template
################
### DOC JOBS ###
################
coverage:
when: always
stage: code-analysis
needs: []
script:
# gcov is part of GCC
- source hpc-module-loads/eve.chs-conda02
# run cmake with coverage support and run tests
- cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_WITH_COVERAGE=ON -B build
- cmake --build build --parallel
- cmake --build build --target mhm_coverage_CI
# copy the output to a top-level folder
- mkdir coverage
- cp build/mhm_coverage_CI/* coverage -R
- lcov_cobertura build/mhm_coverage_CI.info
coverage: '/lines[\.]+\: (\d+\.\d+)\%/'
artifacts:
when: always
reports:
coverage_report:
coverage_format: cobertura
path: coverage.xml
paths:
- coverage
documentation:
variables:
DOC_TYPE: latest
<<: *doc_template
documentation_stable:
only:
- develop
variables:
GIT_DEPTH: 0 # to have all tags
DOC_TYPE: stable
<<: *doc_template
pages:
only:
- develop
stage: deploy
needs:
- job: documentation
artifacts: true
- job: documentation_stable
artifacts: true
- job: coverage
artifacts: true
script:
# create public dir (remove if already present)
- test -d public && rm -rf public
- mkdir -p public
# create the subdir
- mkdir public/stable/
- mkdir public/latest/
# copy the doxygen generated html page to the public site
- cp html_stable/* public/stable/ -R
- cp html_latest/* public/latest/ -R
# create an index.html that redirects to the master documentation (in master folder)
- cp doc/html_files/index.html public/
# create the coverage site
- mkdir -p public/coverage
- cp coverage/* public/coverage/ -R
artifacts:
name: "$CI_COMMIT_REF_NAME"
paths:
- public