-
Notifications
You must be signed in to change notification settings - Fork 14
/
.gitlab-ci.yml
447 lines (398 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
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
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
---
workflow:
rules:
- if: $CI_COMMIT_REF_NAME =~ /dbg\//
when: never
- if: $CI_COMMIT_REF_NAME =~ /dev\// && $CI_COMMIT_TITLE =~ /WIP/
when: never
- if: $CI_MERGE_REQUEST_ID
when: never
- when: always
stages:
- precheck
- invivog5k-deb11
- invivog5k-deb12
- test
- functional
- package
- publish
variables:
DEBIAN_FRONTEND: noninteractive
TZ: Europe/Paris
GIT_SUBMODULE_STRATEGY: normal
TOX_PACKAGE: "tox<4"
FUNCTIONAL_TESTS: test_static_run_command.py test_static_gather_facts.py test_static_play_on.py test_static_run_ansible.py test_static_tasks.py test_sync_info.py test_dstat.py
###############################################################################
#
# PRECHECK STAGE
#
###############################################################################
precheck:
image: python:3.11
stage: precheck
tags: [ci.inria.fr]
script:
- pip install pre-commit
- pre-commit run --all-files
###############################################################################
#
# G5K STAGE
#
###############################################################################
test_invivo_g5k_1$debian11$: &test_invivo_g5k_1
# stick to the distribution we'll find on g5k frontends
image: debian:11
stage: invivog5k-deb11
tags: [ci.inria.fr]
# Always run on tagged commits, and also allow manual runs at any time.
# In all cases, don't fail the pipeline, this is mostly informative.
rules:
- if: $CI_COMMIT_TAG
when: on_success
allow_failure: true
- when: manual
allow_failure: true
script:
- env
- apt update
- apt install -y python3 python3-pip python3-venv iproute2 cmake zlib1g-dev libssl-dev libffi-dev ssh
- ip a
- python3 -m venv /venv
- /venv/bin/python3 -m pip install -e .
- mkdir -p ~/.ssh
- rm -f ~/.ssh/*
- cat $PRIVATE_KEY > ~/.ssh/id_rsa
- cat $PUBLIC_KEY > ~/.ssh/id_rsa.pub
- chmod 600 ~/.ssh/id_rsa
- cat $PYTHON_G5K > ~/.python-grid5000.yaml
- cd docs/tutorials/
- /venv/bin/python3 grid5000/tuto_grid5000_commands.py || /venv/bin/python3 cleanup_g5k_job.py tuto_grid5000_commands.py
- /venv/bin/python3 grid5000/tuto_grid5000_deploy.py || /venv/bin/python3 cleanup_g5k_job.py tuto_grid5000_deploy.py
- /venv/bin/python3 grid5000/tuto_grid5000_deploy_centos.py || /venv/bin/python3 cleanup_g5k_job.py tuto_grid5000_deploy_centos.py
- /venv/bin/python3 grid5000/tuto_grid5000_reload.py || /venv/bin/python3 cleanup_g5k_job.py tuto_grid5000_reload.py
- /venv/bin/python3 grid5000/tuto_grid5000_docker_nvidia.py || /venv/bin/python3 cleanup_g5k_job.py tuto_grid5000_docker_nvidia.py
- /venv/bin/python3 grid5000/tuto_grid5000_monitoring_service.py || /venv/bin/python3 cleanup_g5k_job.py tuto_grid5000_monitoring_service.py
# Second batch of tests to parallelize a bit
test_invivo_g5k_2$debian11$: &test_invivo_g5k_2
# stick to the distribution we'll find on g5k frontends
image: debian:11
stage: invivog5k-deb11
tags: [ci.inria.fr]
# Always run on tagged commits, and also allow manual runs at any time.
# In all cases, don't fail the pipeline, this is mostly informative.
rules:
- if: $CI_COMMIT_TAG
when: on_success
allow_failure: true
- when: manual
allow_failure: true
script:
- env
- apt update
- apt install -y python3 python3-pip python3-venv iproute2 cmake zlib1g-dev libssl-dev libffi-dev ssh
- ip a
- python3 -m venv /venv
- /venv/bin/python3 -m pip install -e .
- mkdir -p ~/.ssh
- rm -f ~/.ssh/*
- cat $PRIVATE_KEY > ~/.ssh/id_rsa
- cat $PUBLIC_KEY > ~/.ssh/id_rsa.pub
- chmod 600 ~/.ssh/id_rsa
- cat $PYTHON_G5K > ~/.python-grid5000.yaml
- cd docs/tutorials/
- /venv/bin/python3 vmong5k/tuto_vmong5k_home.py || /venv/bin/python3 cleanup_g5k_job.py tuto_vmong5k_home.py
- /venv/bin/python3 grid5000/tuto_grid5000_multisites.py || /venv/bin/python3 cleanup_g5k_job.py tuto_grid5000_multisites.py
- /venv/bin/python3 grid5000/tuto_grid5000_docker.py || /venv/bin/python3 cleanup_g5k_job.py tuto_grid5000_docker.py
- /venv/bin/python3 grid5000/tuto_grid5000_destroy.py || /venv/bin/python3 cleanup_g5k_job.py tuto_grid5000_destroy.py
# Run same tests on Debian 12 (newer Python version, allows newer Ansible versions)
# We need to run them in a different stage, otherwise the common OAR job names cause interferences.
test_invivo_g5k_1$debian12$:
<<: *test_invivo_g5k_1
stage: invivog5k-deb12
image: debian:12
test_invivo_g5k_2$debian12$:
<<: *test_invivo_g5k_2
stage: invivog5k-deb12
image: debian:12
###############################################################################
#
# TEST STAGE
#
###############################################################################
python3.7:
image: python:3.7
stage: test
tags: [ci.inria.fr]
script:
- pip install $TOX_PACKAGE
- tox -e py37
python3.8:
image: python:3.8
stage: test
tags: [ci.inria.fr]
script:
- pip install $TOX_PACKAGE
- tox -e py38
python3.9:
image: python:3.9
stage: test
tags: [ci.inria.fr]
script:
- pip install $TOX_PACKAGE
- tox -e py39
python3.10:
image: python:3.10
stage: test
tags: [ci.inria.fr]
script:
- pip install $TOX_PACKAGE
- tox -e py310
python3.11:
image: python:3.11
stage: test
tags: [ci.inria.fr]
script:
- pip install $TOX_PACKAGE
- tox -e py311
coverage: /^TOTAL\s+\d+\s+\d+\s+(\d+\%)$/
artifacts:
when: always
paths:
- htmlcov
reports:
junit: utest.xml
coverage_report:
coverage_format: cobertura
path: cov.xml
pep8:
image: python:3.11
stage: test
tags: [ci.inria.fr]
script:
- pip install $TOX_PACKAGE
- tox -e pep8
pylint:
image: python:3.11
stage: test
tags: [ci.inria.fr]
script:
- pip install $TOX_PACKAGE
- tox -e pylint
typecheck-3.7:
image: python:3.7
stage: test
tags: [ci.inria.fr]
script:
- pip install $TOX_PACKAGE
- tox -e typecheck
typecheck-3.11:
image: python:3.11
stage: test
tags: [ci.inria.fr]
script:
- pip install $TOX_PACKAGE
- tox -e typecheck
sonar:
image: python:3.10-buster
stage: test
allow_failure: true
only:
- tags
tags:
- large
- ci.inria.fr
script:
- pip install -e .
- apt update
- apt install -y wget unzip openjdk-11-jre-headless --no-install-recommends
- pip install pylint
- wget https://binaries.sonarsource.com/Distribution/sonar-scanner-cli/sonar-scanner-cli-4.4.0.2170-linux.zip
- unzip sonar-scanner-cli-4.4.0.2170-linux.zip
- mv sonar-scanner-4.4.0.2170-linux sonar
- wget --no-check-certificate https://sonarqube.inria.fr/static/digicertca.crt
- keytool -import -alias inria -storepass "changeit" -keystore $(pwd)/sonar/jre/lib/security/cacerts -file digicertca.crt
- pip install $TOX_PACKAGE && tox -e py310
- sonar/bin/sonar-scanner -X -Dsonar.login=$SONAR_LOGIN
doc:
image: python:3.10
stage: test
tags: [ci.inria.fr]
script:
- apt update
- apt install -y pandoc
- pip install $TOX_PACKAGE
- tox -e docs
artifacts:
paths:
- docs/_build/html
###############################################################################
#
# FUNCTIONAL STAGE
#
###############################################################################
## TEST VARIOUS ANSIBLE VERSIONS
test_enoslib-ansible_7: &enoslib-ansible
image: debian:11
stage: functional
tags: [ci.inria.fr]
variables:
ENOSLIB_ANSIBLE_VERSION: ">=7,<8"
script:
- |
apt update
# procps is required for "kill" for the dstat test
apt install --no-install-recommends -y python3 python3-pip python3-venv iproute2 procps
ip a
# Create virtualenv
python3 -m venv /tmp/venv
. /tmp/venv/bin/activate
python3 -m pip install -U pip wheel
# Test several versions of ansible
# note that
# python3 -m pip uninstall enoslib-ansible
# python3 -m pip install ansible${ENOSLIB_ANSIBLE_VERSION} should work too!
# but this will install all the ansible_collections shipped with the ansible package
python3 -m pip install enoslib-ansible${ENOSLIB_ANSIBLE_VERSION}
# test_dstat needs pandas
python3 -m pip install -e .[analysis]
cd enoslib/tests/functional
# Make sure we perform all tests and then display a summary
failures=""
retcode=0
for test in ${FUNCTIONAL_TESTS}
do
python3 ${test} || { retcode=$?; failures="$failures $test"; }
done
[ -n "$failures" ] && echo "FAILED TESTS: $failures"
exit $retcode
test_enoslib-ansible_6:
<<: *enoslib-ansible
variables:
ENOSLIB_ANSIBLE_VERSION: ">=6,<7"
test_enoslib-ansible_5:
<<: *enoslib-ansible
variables:
ENOSLIB_ANSIBLE_VERSION: ">=5,<6"
test_enoslib-ansible_4:
<<: *enoslib-ansible
variables:
ENOSLIB_ANSIBLE_VERSION: ">=4,<5"
test_enoslib-ansible_8:
<<: *enoslib-ansible
variables:
ENOSLIB_ANSIBLE_VERSION: ">=8,<9"
test_enoslib-ansible_9:
<<: *enoslib-ansible
# ansible 9+ only work for python>=10
image: debian:12
variables:
ENOSLIB_ANSIBLE_VERSION: ">=9,<10"
test_enoslib-ansible_10:
<<: *enoslib-ansible
# ansible 9+ only work for python>=10
image: debian:12
variables:
ENOSLIB_ANSIBLE_VERSION: ">=10,<11"
## TEST AGAINST DIFFERENT DISTROS
#-----------------------------------------------
test_functional$debian12$: &debian-base
image: debian:12
stage: functional
tags: [ci.inria.fr]
script:
- |
apt update
# procps is required for "kill" for the dstat test
apt install --no-install-recommends -y python3 python3-pip python3-venv iproute2 procps
ip a
# Create virtualenv
python3 -m venv /tmp/venv
. /tmp/venv/bin/activate
python3 -m pip install -U pip wheel
# test_dstat needs pandas
python3 -m pip install -e .[analysis]
cd enoslib/tests/functional
# Make sure we perform all tests and then display a summary
failures=""
retcode=0
for test in ${FUNCTIONAL_TESTS}
do
python3 ${test} || { retcode=$?; failures="$failures $(basename $test)"; }
done
[ -n "$failures" ] && echo "FAILED TESTS: $failures"
exit $retcode
## debian 10
#-----------------------------------------------
test_functional$debian10$: &debian10
<<: *debian-base
image: debian:10
## debian 11
#-----------------------------------------------
test_functional$debian11$: &debian11
<<: *debian-base
image: debian:11
## debian testing
#-----------------------------------------------
test_functional$debiantesting$: &debiantesting
<<: *debian-base
image: debian:testing
# remove me on 10.x
allow_failure: true
## ubuntu 20.04
#-----------------------------------------------
test_functional$ubuntu2004$: &ubuntu2004
<<: *debian-base
image: ubuntu:20.04
## ubuntu 22.04
#-----------------------------------------------
test_functional$ubuntu2204$: &ubuntu2204
<<: *debian-base
image: ubuntu:22.04
###############################################################################
#
# PACKAGE STAGE
#
###############################################################################
#### Entering the release zone
package:
image: python:3.7
stage: package
tags: [ci.inria.fr]
only:
- tags
script:
- python setup.py bdist_wheel
artifacts:
paths:
- dist/
###############################################################################
#
# PUBLISH STAGE
#
###############################################################################
pages:
# when: manual
stage: publish
tags: [ci.inria.fr]
only:
- tags
dependencies:
- doc
script:
- mkdir -p public/
- cp -r docs/_build/html/* public/
artifacts:
paths:
- public
pypi:
image: python:3.7
stage: publish
tags: [ci.inria.fr]
only:
- tags
dependencies:
- package
script:
- pip install twine
# credentials are set in the env by gitlab
- twine upload dist/* --verbose