-
Notifications
You must be signed in to change notification settings - Fork 2
/
.gitlab-ci.yml
635 lines (586 loc) · 18.5 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
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
###############################
# FIREWHEEL's Continuous Integration
#
# This GitLab CI file enables testing of FIREWHEEL
# on a variety of operating systems and versions of
# Python.
#
# It makes heavy use of YAML Anchors and extends to save space.
# see: https://docs.gitlab.com/ce/ci/yaml/README.html#anchors
#
###############################
###############################
# Change pip's cache directory to be inside the project
# directory since we can only cache local items.
###############################
variables:
PIP_CACHE_DIR: "$CI_PROJECT_DIR/.cache/pip"
RUNNER_AFTER_SCRIPT_TIMEOUT: 3h
###############################
# Pip's cache doesn't store the python packages
# https://pip.pypa.io/en/stable/reference/pip_install/#caching
#
# If you want to also cache the installed packages, you have to install
# them in a virtualenv and cache it as well.
###############################
cache:
paths:
- "$CI_PROJECT_DIR/.cache/pip"
- venv/
- .cache/pip
###############################
# Setting up before_script anchors to speed up the exectution of
# pipeline jobs which do not require each component.
# See: https://docs.gitlab.com/ee/ci/yaml/#yaml-anchors-for-before_script-and-after_script
#
# This includes:
# * create_venv: Creating a Python 3.9 virtual environment
# * install_firewheel: Install FIREWHEEL and any dependencies.
# * configure_firewheel: Configure FIREWHEEL for use by the job.
# * install_mcs: Clone the base and linux Model Component repositories
# so that the functional tests can run.
###############################
.create_venv_docker: &create_venv_docker
- python --version ; pip --version
- pip install $PIP_ARGS virtualenv
- virtualenv venv
- source venv/bin/activate
.create_venv: &create_venv
- pushd /opt/firewheel/
- python3.9 -m venv venv
- source /opt/firewheel/venv/bin/activate
- popd
.install_firewheel_docker: &install_firewheel_docker
- python -m pip install $PIP_ARGS -U build setuptools pip
- python -m build
- python -m pip install -e .[dev]
.install_firewheel: &install_firewheel
- sudo killall minimega # Make sure minimega is not running
- sudo systemctl restart minimega
- *install_firewheel_docker
.set_config: &set_config
- firewheel config set -s system.default_output_dir "$(pwd)/logs"
- firewheel config set -s cluster.compute $(hostname)
- firewheel config set -s cluster.control $(hostname)
- firewheel config set -s discovery.hostname 127.0.0.1
- firewheel config set -s grpc.hostname 127.0.0.1
- firewheel config set -s minimega.experiment_interface lo
- firewheel config set -s minimega.install_dir /opt/minimega
- firewheel config set -s python.venv $(pwd)/venv
- firewheel config set -s python.bin python3
.configure_firewheel_docker: &configure_firewheel_docker
- *set_config
- firewheel config set -s system.default_group root
- python ./src/firewheel/lib/grpc/firewheel_grpc_server.py &
.configure_firewheel: &configure_firewheel
- *set_config
- firewheel init
- firewheel sync
- firewheel restart hard
.install_mcs_docker: &install_mcs_docker
- mkdir model_components
- pip install $PIP_ARGS firewheel-repo-base firewheel-repo-tutorials
- pushd model_components
- git clone https://gitlab-ci-token:${CI_JOB_TOKEN}@${CI_SERVER_HOST}/firewheel/model_components/linux.git
- git clone https://gitlab-ci-token:${CI_JOB_TOKEN}@${CI_SERVER_HOST}/firewheel/model_components/utilities.git
- git clone https://gitlab-ci-token:${CI_JOB_TOKEN}@${CI_SERVER_HOST}/firewheel/model_components/layer2.git
- git clone https://gitlab-ci-token:${CI_JOB_TOKEN}@${CI_SERVER_HOST}/firewheel/model_components/ntp.git
- git clone https://gitlab-ci-token:${CI_JOB_TOKEN}@${CI_SERVER_HOST}/firewheel/model_components/dns.git
- git clone https://gitlab-ci-token:${CI_JOB_TOKEN}@${CI_SERVER_HOST}/firewheel/model_components/vyos.git
- firewheel repository install linux
- firewheel repository install utilities
- firewheel repository install layer2
- firewheel repository install ntp
- firewheel repository install dns
- firewheel repository install vyos
- popd
.install_mcs: &install_mcs
- pushd /opt/firewheel/
- *install_mcs_docker
- pushd model_components
- git clone https://gitlab-ci-token:${CI_JOB_TOKEN}@${CI_SERVER_HOST}/${NTP_BIN_REPO_PATH} /tmp/ntp
- git clone https://gitlab-ci-token:${CI_JOB_TOKEN}@${CI_SERVER_HOST}/${DNS_BIN_REPO_PATH} /tmp/dns
- git clone https://gitlab-ci-token:${CI_JOB_TOKEN}@${CI_SERVER_HOST}/${VYOS_BIN_REPO_PATH} /tmp/vyos
- git clone https://gitlab-ci-token:${CI_JOB_TOKEN}@${CI_SERVER_HOST}/${LINUX_BIN_REPO_PATH} /tmp/linux
- mv /tmp/ntp/ntp/ntp-trusty-server.tar /opt/firewheel/model_components/ntp/src/firewheel_repo_ntp/ntp/vm_resources/
- mv /tmp/dns/dns_objects/vm_resources/bind9_xenial_debs.tgz /opt/firewheel/model_components/dns/src/firewheel_repo_dns/dns_objects/vm_resources/bind9_xenial_debs.tgz
- mv /tmp/vyos/vyos-1.1.8/vyos-1.1.8.qc2.xz /opt/firewheel/model_components/vyos/src/firewheel_repo_vyos/vyos-1.1.8/
- mv /tmp/linux/linux/vm_resources/*.tgz /opt/firewheel/model_components/linux/src/firewheel_repo_linux/linux/vm_resources
- mv /tmp/linux/ubuntu/ubuntu/vm_resources/debs/*.tgz /opt/firewheel/model_components/linux/src/firewheel_repo_linux/ubuntu/ubuntu/vm_resources/debs/
- mv /tmp/linux/ubuntu/bionic/images/ubuntu* /opt/firewheel/model_components/linux/src/firewheel_repo_linux/ubuntu/bionic/images/
- mv /tmp/linux/ubuntu/jammy/images/ubuntu* /opt/firewheel/model_components/linux/src/firewheel_repo_linux/ubuntu/jammy/images/
- mv /tmp/linux/ubuntu/jammy/vm_resources/debs/*.tgz /opt/firewheel/model_components/linux/src/firewheel_repo_linux/ubuntu/jammy/vm_resources/debs/
- mv /tmp/linux/ubuntu/trusty/images/ubuntu* /opt/firewheel/model_components/linux/src/firewheel_repo_linux/ubuntu/trusty/images/
- mv /tmp/linux/ubuntu/trusty/vm_resources/debs/*.tgz /opt/firewheel/model_components/linux/src/firewheel_repo_linux/ubuntu/trusty/vm_resources/debs/
- mv /tmp/linux/ubuntu/xenial/images/ubuntu* /opt/firewheel/model_components/linux/src/firewheel_repo_linux/ubuntu/xenial/images/
- popd
- popd
###############################
# Creating a few defaults and setting up the Pipeline stages.
###############################
default:
tags:
- vm
before_script:
- *create_venv
- *install_firewheel
- *configure_firewheel
stages:
- lint
- test
- deploy
###############################
# Unit Testing
#
# These anchors create an environment for running FIREWHEEL's
# unit tests. There is one anchor `all-unit` which runs
# on Python versions 3.8, 3.9, 3.10, 3.11, 3.12, 3.13.
#
# Unit tests for Python 3.8 is run on Ubuntu 22.04.
# Unit tests for Python 3.9 is run on Ubuntu 22.04 and RHEL 8.
# Unit tests for Python 3.10 is run on Ubuntu 22.04.
# Unit tests for Python 3.11 is run on Ubuntu 22.04.
# Unit tests for Python 3.12 is run on Ubuntu 22.04.
# Unit tests for Python 3.13 is run on Ubuntu 22.04.
#
###############################
.all-unit:
stage: test
before_script:
- sudo apt update
- sudo apt-get install -y python3.8 python3.8-dev python3.8-venv
- sudo apt-get install -y python3.9 python3.9-dev python3.9-venv
- sudo apt-get install -y python3.11 python3.11-dev python3.11-venv
- sudo apt-get install -y python3.12 python3.12-dev python3.12-venv
- sudo apt-get install -y python3.13 python3.13-dev python3.13-venv
- *create_venv
- *install_firewheel
- *configure_firewheel
- *install_mcs
unit-py38-ubuntu2204:
extends: .all-unit
tags:
- ubuntu2204
script:
- tox -e py38
artifacts:
paths:
- logs
when: on_failure
exclude:
- logs/fw_cli/**
- logs/fw_grpc/**
- logs/fw_grpc_unittest/**
- logs/discovery.log
name: "${CI_PROJECT_NAME}_${CI_JOB_NAME}_${CI_COMMIT_REF_NAME}_logs"
unit-py39-ubuntu2204:
extends: .all-unit
before_script:
- *create_venv
- *install_firewheel
- *configure_firewheel
- *install_mcs
tags:
- ubuntu2204
coverage: '/(?i)total.*? (100(?:\.0+)?\%|[1-9]?\d(?:\.\d+)?\%)$/'
script:
- tox -e py39
artifacts:
paths:
- htmlcov/
unit-py310-ubuntu2204:
extends: .all-unit
tags:
- ubuntu2204
script:
- tox -e py310
artifacts:
paths:
- logs
when: on_failure
exclude:
- logs/fw_cli/**
- logs/fw_grpc/**
- logs/fw_grpc_unittest/**
- logs/discovery.log
name: "${CI_PROJECT_NAME}_${CI_JOB_NAME}_${CI_COMMIT_REF_NAME}_logs"
unit-py311-ubuntu2204:
extends: .all-unit
tags:
- ubuntu2204
script:
- tox -e py311
artifacts:
paths:
- logs
when: on_failure
exclude:
- logs/fw_cli/**
- logs/fw_grpc/**
- logs/fw_grpc_unittest/**
- logs/discovery.log
name: "${CI_PROJECT_NAME}_${CI_JOB_NAME}_${CI_COMMIT_REF_NAME}_logs"
unit-py312-ubuntu2204:
extends: .all-unit
tags:
- ubuntu2204
script:
- tox -e py312
artifacts:
paths:
- logs
when: on_failure
exclude:
- logs/fw_cli/**
- logs/fw_grpc/**
- logs/fw_grpc_unittest/**
- logs/discovery.log
name: "${CI_PROJECT_NAME}_${CI_JOB_NAME}_${CI_COMMIT_REF_NAME}_logs"
unit-py313-ubuntu2204:
extends: .all-unit
tags:
- ubuntu2204
script:
- tox -e py313
artifacts:
paths:
- logs
when: on_failure
exclude:
- logs/fw_cli/**
- logs/fw_grpc/**
- logs/fw_grpc_unittest/**
- logs/discovery.log
name: "${CI_PROJECT_NAME}_${CI_JOB_NAME}_${CI_COMMIT_REF_NAME}_logs"
unit-py39-rhel8:
stage: test
before_script:
- *create_venv
- *install_firewheel
- *configure_firewheel
- *install_mcs
tags:
- rhel8
needs: []
script:
- tox -e py39
artifacts:
paths:
- logs
when: on_failure
exclude:
- logs/fw_cli/**
- logs/fw_grpc/**
- logs/fw_grpc_unittest/**
- logs/discovery.log
name: "${CI_PROJECT_NAME}_${CI_JOB_NAME}_${CI_COMMIT_REF_NAME}_logs"
###############################
# Functional Testings
#
# These anchors create an environment for running FIREWHEEL's
# functional tests. Currently only the minimal test are run.
# There are anchors for Python versions 3.9, 3.10, 3.11, 3.12, 3.13
#
###############################
.py39-functional:
before_script:
- *create_venv
- *install_firewheel
- *configure_firewheel
- *install_mcs
stage: test
script:
- PYTHONWARNINGS=error PYTHONDEVMODE=1 firewheel test functional minimal
artifacts:
paths:
- logs
when: on_failure
exclude:
- logs/fw_cli/**
- logs/fw_grpc/**
- logs/fw_grpc_unittest/**
- logs/discovery.log
name: "${CI_PROJECT_NAME}_${CI_JOB_NAME}_${CI_COMMIT_REF_NAME}_logs"
.py310-functional:
before_script:
- pushd /opt/firewheel/
- python3.10 -m venv venv
- source /opt/firewheel/venv/bin/activate
- popd
- *install_firewheel
- *configure_firewheel
- *install_mcs
stage: test
script:
- PYTHONDEVMODE=1 firewheel test functional minimal
artifacts:
paths:
- logs
when: on_failure
exclude:
- logs/fw_cli/**
- logs/fw_grpc/**
- logs/fw_grpc_unittest/**
- logs/discovery.log
name: "${CI_PROJECT_NAME}_${CI_JOB_NAME}_${CI_COMMIT_REF_NAME}_logs"
.py311-functional:
before_script:
- pushd /opt/firewheel/
- python3.11 -m venv venv
- source /opt/firewheel/venv/bin/activate
- popd
- *install_firewheel
- *configure_firewheel
- *install_mcs
stage: test
script:
- PYTHONDEVMODE=1 firewheel test functional minimal
artifacts:
paths:
- logs
when: on_failure
exclude:
- logs/fw_cli/**
- logs/fw_grpc/**
- logs/fw_grpc_unittest/**
- logs/discovery.log
name: "${CI_PROJECT_NAME}_${CI_JOB_NAME}_${CI_COMMIT_REF_NAME}_logs"
.py312-functional:
before_script:
- sudo apt update
- sudo apt-get install -y python3.12 python3.12-dev python3.12-venv
- pushd /opt/firewheel/
- python3.12 -m venv fwpy
- source /opt/firewheel/fwpy/bin/activate
- popd
- *install_firewheel
- *configure_firewheel
- *install_mcs
stage: test
script:
- PYTHONDEVMODE=1 firewheel test functional minimal
artifacts:
paths:
- logs
when: on_failure
exclude:
- logs/fw_cli/**
- logs/fw_grpc/**
- logs/fw_grpc_unittest/**
- logs/discovery.log
name: "${CI_PROJECT_NAME}_${CI_JOB_NAME}_${CI_COMMIT_REF_NAME}_logs"
.py313-functional:
before_script:
- sudo apt update
- sudo apt-get install -y python3.13 python3.13-dev python3.13-venv
- pushd /opt/firewheel/
- python3.13 -m venv fwpy
- source /opt/firewheel/fwpy/bin/activate
- popd
- *install_firewheel
- *configure_firewheel
- *install_mcs
stage: test
script:
- PYTHONDEVMODE=1 firewheel test functional minimal
artifacts:
paths:
- logs
when: on_failure
exclude:
- logs/fw_cli/**
- logs/fw_grpc/**
- logs/fw_grpc_unittest/**
- logs/discovery.log
name: "${CI_PROJECT_NAME}_${CI_JOB_NAME}_${CI_COMMIT_REF_NAME}_logs"
###############################
# RHEL 8 Functional Tests
#
# This includes testing for Python 3.9
# These tests are run only on the default branch.
###############################
functional-py39-rhel8:
extends: .py39-functional
script:
- PYTHONDEVMODE=1 firewheel test functional minimal
artifacts:
paths:
- logs
when: on_failure
exclude:
- logs/fw_cli/**
- logs/fw_grpc/**
- logs/fw_grpc_unittest/**
- logs/discovery.log
name: "${CI_PROJECT_NAME}_${CI_JOB_NAME}_${CI_COMMIT_REF_NAME}_logs"
tags:
- rhel8
###############################
# Ubuntu 22.04 Functional Tests
#
# This includes testing for Python 3.9-3.13
# Python 3.9 and 3.13 is run on on all branches.
###############################
functional-py39-ubuntu2204:
extends: .py39-functional
tags:
- ubuntu2204
functional-py310-ubuntu2204:
extends: .py310-functional
tags:
- ubuntu2204
rules:
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
functional-py311-ubuntu2204:
extends: .py311-functional
tags:
- ubuntu2204
rules:
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
functional-py312-ubuntu2204:
extends: .py312-functional
tags:
- ubuntu2204
rules:
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
functional-py313-ubuntu2204:
extends: .py313-functional
tags:
- ubuntu2204
###############################
# Performance Testings
#
# These anchors create an environment for running a stress-test for FIREWHEEL's
# performance.
#
###############################
performance-ubuntu2204:
before_script:
- pushd /opt/firewheel/
- python3.10 -m venv venv
- source /opt/firewheel/venv/bin/activate
- popd
- *install_firewheel
- *configure_firewheel
- *install_mcs
stage: test
needs: []
tags:
- ubuntu2204
script:
- pushd /opt/firewheel
# Enable FW to cache images
- firewheel experiment --no-install tests.vm_gen:1 minimega.schedules_ready
# Create a network with a lot of vertices and edges
- firewheel experiment --no-install --profile tests.vm_gen:10000 tests.connect_all:10 minimega.schedules_ready
- python -m pip install $PIP_ARGS snakeviz
- python -m pip install $PIP_ARGS "pywebcopy==7.0.2" lxml_html_clean
# There are a few flaws with pywebcopy and we need to patch it first
- |
sed -i '575i\
if not url:\
self.logger.debug("Invalid URL, re-encoded the resource as [%s]" % (match.group(0)))\
return match.group(0)\
if ans.response is not None and not ans.response.ok:\
self.logger.debug("Invalid Response, re-encoded the resource as [%s]" % (match.group(0)))\
return match.group(0)' /opt/firewheel/venv/lib/python3.10/site-packages/pywebcopy/elements.py
- |
tr -d '\r' < /opt/firewheel/venv/lib/python3.10/site-packages/pywebcopy/elements.py > /tmp/elements.py && mv /tmp/elements.py /opt/firewheel/venv/lib/python3.10/site-packages/pywebcopy/elements.py
- snakeviz -p 8888 -s firewheel_profile.prof &
- sleep 5
- python -m pywebcopy -p --url=http://127.0.0.1:8888/snakeviz/%2Fopt%2Ffirewheel%2Ffirewheel_profile.prof --location=$HOME/$CI_PROJECT_DIR/profile
- pkill snakeviz
- popd
artifacts:
paths:
- profile
###############################
# Lint Stages
#
# This includes:
# * lint-code: Linting all executable code
# * lint-docs: Linting the documentation
###############################
lint-code:
image: $DOCKER_REGISTRY/python:3.11
stage: lint
before_script:
- *create_venv_docker
- *install_firewheel_docker
- *configure_firewheel_docker
- firewheel init
- firewheel sync
script:
- touch logs/fw_cli/__init__.py
- touch logs/fw_cli/vm/__init__.py
- touch logs/fw_cli/tshoot/__init__.py
- touch logs/fw_cli/tmux/__init__.py
- touch logs/fw_cli/test/__init__.py
- touch logs/fw_cli/example_helpers/__init__.py
- touch logs/fw_cli/mc/__init__.py
- touch logs/fw_cli/mm/__init__.py
- touch logs/fw_cli/pull/__init__.py
- touch logs/fw_cli/push/__init__.py
- touch logs/fw_cli/repository/__init__.py
- touch logs/fw_cli/restart/__init__.py
- touch logs/fw_cli/stop/__init__.py
- tox -e lint -- logs/fw_cli/*/ logs/fw_cli
tags:
- $CI_DOCKER_RUNNER
lint-docs:
image: $DOCKER_REGISTRY/python:3.11
stage: lint
before_script:
- *create_venv_docker
- *install_firewheel_docker
- *configure_firewheel_docker
- *install_mcs_docker
- firewheel init
- firewheel sync
script:
- tox -e lint-docs -- logs/fw_cli
tags:
- $CI_DOCKER_RUNNER
###############################
# Create Documentation
###############################
docs:
image: $DOCKER_REGISTRY/python:3.11
before_script:
- *create_venv_docker
- *install_firewheel_docker
- *configure_firewheel_docker
- *install_mcs_docker
stage: lint
needs: []
script:
- tox -e dependencies,docs
- mkdir documentation
- mv docs/build/html documentation/html
artifacts:
expire_in: 3 mos
paths:
- documentation
name: "${CI_PROJECT_NAME}_${CI_JOB_NAME}_${CI_COMMIT_REF_NAME}"
rules:
- if: $CI_COMMIT_BRANCH =~ /^documentation.*$/
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH
tags:
- $CI_DOCKER_RUNNER
pages:
image: $DOCKER_REGISTRY/python:3.11
before_script:
- echo "Starting pages."
stage: deploy
tags:
- $CI_DOCKER_RUNNER
needs:
- job: docs
artifacts: true
script:
- mv documentation/html public
artifacts:
paths:
- public
rules:
- if: $CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH