-
Notifications
You must be signed in to change notification settings - Fork 276
790 lines (763 loc) · 28.7 KB
/
pull-request-management.yml
File metadata and controls
790 lines (763 loc) · 28.7 KB
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
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
---
name: "Collection code testing"
"on":
pull_request:
merge_group:
types: [checks_requested]
push:
branches:
- devel
concurrency:
# For PRs the head_ref will be used. For Merge Queues (merge_group) we fallback to run_id.
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true
env:
# Set -vvv is ACTIONS_STEP_DEBUG is set
# Apparently it is set in secrets when running with debug
ANSIBLE_VERBOSITY: ${{ secrets.ACTIONS_STEP_DEBUG && 3 || 0 }}
AVD_NEVER_RUN_FROM_SOURCE: 1
PY_COLORS: 1 # allows molecule colors to be passed to GitHub Actions
ANSIBLE_FORCE_COLOR: 1 # allows ansible colors to be passed to GitHub Actions
jobs:
required-checks: # Added in github settings as a required check before merge. This ensures that CI finishes before merge queue is merged.
needs:
- python_type_checking
- python_requirements
- molecule_eos_cli_config_gen
- molecule_eos_designs
- molecule_eos_designs_minimum_requirements
- molecule_anta_runner
- ansible_test_sanity
- ansible_test_units
- ansible_test_integration
- galaxy_importer
- ansible_lint
- test_pyavd
- codespell
- j2lint
- markdownlint
- check_schema_tables_in_docs
if: always()
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- run: echo '${{ toJSON(needs) }}' | jq -e 'to_entries | all(.value.result == "success" or .value.result == "skipped")'
file-changes:
runs-on: ubuntu-latest
outputs:
eos_design: ${{ steps.filter.outputs.eos_design }}
config_gen: ${{ steps.filter.outputs.config_gen }}
pyavd: ${{ steps.filter.outputs.pyavd }}
requirements: ${{ steps.filter.outputs.requirements }}
anta_runner: ${{ steps.filter.outputs.anta_runner }}
steps:
- uses: actions/checkout@v6
- uses: dorny/paths-filter@v4
id: filter
with:
filters: |
eos_design:
- 'ansible_collections/arista/avd/roles/eos_designs/*'
- 'ansible_collections/arista/avd/roles/eos_designs/**/*'
- '.github/workflows/pull-request-management.yml'
- 'ansible_collections/arista/avd/extensions/molecule/*'
- 'ansible_collections/arista/avd/extensions/molecule/**/*'
- 'ansible_collections/arista/avd/examples/*'
- 'ansible_collections/arista/avd/examples/**/*'
- 'python-avd/pyavd/_eos_designs/*'
- 'python-avd/pyavd/_eos_designs/**/*'
config_gen:
- 'ansible_collections/arista/avd/roles/eos_cli_config_gen/*'
- 'ansible_collections/arista/avd/roles/eos_cli_config_gen/**/*'
- '.github/workflows/pull-request-management.yml'
- 'ansible_collections/arista/avd/extensions/molecule/eos_cli_config_gen*/*'
- 'ansible_collections/arista/avd/extensions/molecule/eos_cli_config_gen*/**/*'
- 'python-avd/pyavd/_eos_cli_config_gen/*'
- 'python-avd/pyavd/_eos_cli_config_gen/**/*'
plugins:
- 'ansible_collections/arista/avd/plugins/filter/**'
- 'ansible_collections/arista/avd/plugins/test/**'
requirements:
- 'ansible_collections/arista/avd/requirements.txt'
- 'ansible_collections/arista/avd/meta/runtime.yml'
- 'ansible_collections/arista/avd/requirements.yml'
- '.github/workflows/pull-request-management.yml'
- 'sonar-project.properties'
- '.pre-commit-config.yaml'
pyavd:
- 'python-avd/**/*'
anta_runner:
- 'ansible_collections/arista/avd/roles/anta_runner/*'
- 'ansible_collections/arista/avd/roles/anta_runner/**/*'
- 'python-avd/pyavd/_anta/*'
- 'python-avd/pyavd/_anta/**/*'
- 'python-avd/pyavd/api/_anta/*'
- 'python-avd/pyavd/api/_anta/**/*'
- 'python-avd/pyavd/get_device_anta_catalog.py'
# -------------------------------------- #
# Build PyAVD wheel and upload artifact
# -------------------------------------- #
build_pyavd:
name: Build pyavd
runs-on: ubuntu-latest
outputs:
wheel_file: ${{ steps.build_step.outputs.wheel_file }}
steps:
- uses: actions/checkout@v6
- uses: actions/setup-python@v6
with:
python-version: |
3.12
- name: Create pyavd wheel and output wheel path
id: build_step
working-directory: ./python-avd
run: |
pip install build
python -m build --wheel
WHEEL_FILE=$(find ./dist/*.whl -print0 -type f | xargs -0 -n 1 basename)
echo "wheel_file=/tmp/pyavd/$WHEEL_FILE" >> "$GITHUB_OUTPUT"
- name: Upload pyavd artifact
uses: actions/upload-artifact@v7
with:
name: pyavd
path: ./python-avd/dist/*.whl
# -------------------------------------------- #
# Python type checking not covered in pre-commit
# -------------------------------------------- #
python_type_checking:
name: Python Linting not covered in pre-commit
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: actions/setup-python@v6
with:
python-version: "3.12"
- name: Install pyavd and Ansible requirements
run: |
pip install --group dev --upgrade
- name: PyRight static type checker
# Specific SHA as allowed by github org admins
uses: jakebailey/pyright-action@6cabc0f01c4994be48fd45cd9dbacdd6e1ee6e5e
# ----------------------------------- #
# Test Requirements
# ----------------------------------- #
python_requirements:
name: Test Python requirements installation
runs-on: ubuntu-latest
needs: [build_pyavd, file-changes]
if: needs.file-changes.outputs.requirements == 'true'
strategy:
fail-fast: true
matrix:
python_version:
- "3.10"
- "3.11"
- "3.12"
- "3.13"
- "3.14"
steps:
- uses: actions/checkout@v6
- name: Set up Python 3
uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python_version }}
- name: Download pyavd Artifact
uses: actions/download-artifact@v8
with:
name: pyavd
path: /tmp/pyavd/
- name: "Install Python requirements"
run: |
pip install "${{ needs.build_pyavd.outputs.wheel_file }}" --group dev --upgrade
# ----------------------------------- #
# EOS CLI CONFIG GEN MOLECULE
# ----------------------------------- #
molecule_eos_cli_config_gen:
name: Validate eos_cli_config_gen
runs-on: ubuntu-latest
needs: [build_pyavd, file-changes]
if: |
needs.file-changes.outputs.config_gen == 'true' ||
needs.file-changes.outputs.requirements == 'true' ||
github.event_name == 'merge_group'
strategy:
fail-fast: true
matrix:
avd_scenario:
- "eos_cli_config_gen"
- "eos_cli_config_gen_deprecated_vars"
- "eos_cli_config_gen_negative_unit_tests"
ansible_version:
- "ansible-core<2.21.0"
python_version:
- "3.12"
# Also test minimum ansible version for one scenario.
include:
- avd_scenario: "eos_cli_config_gen"
ansible_version: "ansible-core==2.16.0"
python_version: "3.11"
steps:
- uses: actions/checkout@v6
- name: Download pyavd Artifact
uses: actions/download-artifact@v8
with:
name: pyavd
path: /tmp/pyavd/
- name: Set up Python ${{ matrix.python_version }}
uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python_version }}
- name: Install pyavd and Ansible requirements
run: |
python -m pip install "${{ matrix.ansible_version}}" "${{ needs.build_pyavd.outputs.wheel_file }}[ansible-collection]" --group molecule
- name: Run molecule test
working-directory: ansible_collections/arista/avd
run: |
molecule test --scenario-name ${{ matrix.avd_scenario }}
- name: Check GIT status
run: |
sh .github/check-git-status.sh
# ----------------------------------- #
# EOS Design MOLECULE
# ----------------------------------- #
molecule_eos_designs:
name: Validate eos_designs
runs-on: ubuntu-latest
needs: [build_pyavd, file-changes]
if: |
needs.file-changes.outputs.eos_design == 'true' ||
needs.file-changes.outputs.config_gen == 'true' ||
needs.file-changes.outputs.requirements == 'true' ||
github.event_name == 'merge_group'
strategy:
fail-fast: true
matrix:
avd_scenario:
- "ansible_only"
- "digital_twin"
- "eos_designs_deprecated_vars"
- "eos_designs-l2ls"
- "eos_designs-mpls-isis-sr-ldp"
- "eos_designs-twodc-5stage-clos"
- "eos_designs_unit_tests"
- "evpn_underlay_ebgp_overlay_ebgp"
- "evpn_underlay_isis_overlay_ibgp"
- "evpn_underlay_ospf_overlay_ebgp"
- "evpn_underlay_rfc5549_overlay_ebgp"
- "example-campus-fabric"
- "example-dual-dc-l3ls"
- "example-isis-ldp-ipvpn"
- "example-l2ls-fabric"
- "example-single-dc-l3ls"
- "example-single-dc-l3ls-ipv6"
- "example-single-dc-multipod-l3ls"
- "example-cv-pathfinder"
- "howto"
- "eos_designs_negative_unit_tests"
ansible_version:
- "ansible-core>=2.16.0,<2.21.0"
python_version:
- "3.12"
include:
- avd_scenario: "eos_designs_unit_tests"
ansible_version: "ansible-core<2.17.0"
python_version: "3.11"
- avd_scenario: "eos_designs_unit_tests"
ansible_version: "ansible-core<2.18.0"
python_version: "3.11"
- avd_scenario: "eos_designs_unit_tests"
ansible_version: "ansible-core<2.19.0"
python_version: "3.11"
- avd_scenario: "eos_designs_unit_tests"
ansible_version: "ansible-core<2.20.0"
python_version: "3.11"
# Test latest ansible-core with latest Python
- avd_scenario: "eos_designs_unit_tests"
ansible_version: "ansible-core<2.21.0"
python_version: "3.14"
- avd_scenario: "eos_designs_negative_unit_tests"
ansible_version: "ansible-core<2.21.0"
python_version: "3.14"
# Test ansible-core milestone release
# We need to ignore requirements checks to avoid raising an error with new ansible versions not officially supported
- avd_scenario: "eos_designs_unit_tests -- -e avd_ignore_requirements=True"
ansible_version: "ansible-core @ git+https://github.com/ansible/ansible.git@milestone"
python_version: "3.14"
- avd_scenario: "eos_designs_negative_unit_tests -- -e avd_ignore_requirements=True"
ansible_version: "ansible-core @ git+https://github.com/ansible/ansible.git@milestone"
python_version: "3.14"
steps:
- uses: actions/checkout@v6
- name: Download pyavd Artifact
uses: actions/download-artifact@v8
with:
name: pyavd
path: /tmp/pyavd/
- name: Set up Python ${{ matrix.python_version }}
uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python_version }}
- name: Install pyavd and Ansible requirements
run: |
python -m pip install "${{ matrix.ansible_version}}" "${{ needs.build_pyavd.outputs.wheel_file }}[ansible-collection]" --group molecule
- name: Run molecule test
working-directory: ansible_collections/arista/avd
env:
ANSIBLE_COLLECTIONS_ON_ANSIBLE_VERSION_MISMATCH: ignore
run: |
molecule test --scenario-name ${{ matrix.avd_scenario }}
- name: Check GIT status
run: |
sh .github/check-git-status.sh
molecule_eos_designs_minimum_requirements:
name: Validate eos_designs with minimum requirements
runs-on: ubuntu-latest
needs: [build_pyavd, file-changes]
if: needs.file-changes.outputs.eos_design == 'true' || needs.file-changes.outputs.config_gen == 'true' || needs.file-changes.outputs.requirements == 'true' ||
github.event_name == 'merge_group'
steps:
- uses: actions/checkout@v6
- name: Download pyavd Artifact
uses: actions/download-artifact@v8
with:
name: pyavd
path: /tmp/pyavd/
- name: Use Python 3.10 for minimum requirements
uses: actions/setup-python@v6
with:
python-version: |
3.10
- name: Install pyavd and Ansible minimum requirements
# Installing molecule and requirements in different pip command because of jsonschema>=3.2.0 in AVD is incompatible
# with jsonschema>=4.9.1 in molecule when using pip compile with lowest
# Need to delete min_requirements afterwards otherwise git status is sad
# pip upgrade to get dependency groups
run: |
pip install uv
uv pip compile python-avd/pyproject.toml --extra ansible-collection --resolution lowest-direct > /tmp/pyavd/min_requirements.txt
cat /tmp/pyavd/min_requirements.txt
pip install pip --upgrade
python -m pip install --group molecule
python -m pip install "ansible-core==2.16.0" "${{ needs.build_pyavd.outputs.wheel_file }}[ansible-collection]" -r /tmp/pyavd/min_requirements.txt
- name: Run molecule test
working-directory: ansible_collections/arista/avd
run: |
molecule test --scenario-name eos_designs_unit_tests
- name: Check GIT status
run: |
sh .github/check-git-status.sh
# ----------------------------------- #
# ANTA Runner MOLECULE
# ----------------------------------- #
molecule_anta_runner:
name: Validate anta_runner
runs-on: ubuntu-latest
needs: [build_pyavd, file-changes]
if: |
needs.file-changes.outputs.eos_design == 'true' ||
needs.file-changes.outputs.anta_runner == 'true' ||
needs.file-changes.outputs.requirements == 'true' ||
github.event_name == 'merge_group'
strategy:
fail-fast: true
matrix:
avd_scenario:
- "anta_runner"
ansible_version:
- "ansible-core<2.21.0"
python_version:
- "3.12"
include:
- avd_scenario: "anta_runner"
ansible_version: "ansible-core==2.16.0"
python_version: "3.11"
steps:
- uses: actions/checkout@v6
- name: Download pyavd Artifact
uses: actions/download-artifact@v8
with:
name: pyavd
path: /tmp/pyavd/
- name: Set up Python ${{ matrix.python_version }}
uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python_version }}
- name: Install pyavd and Ansible requirements
run: |
python -m pip install "${{ matrix.ansible_version}}" "${{ needs.build_pyavd.outputs.wheel_file }}[ansible-collection]" --group molecule
- name: Run molecule test
working-directory: ansible_collections/arista/avd
run: |
molecule test --scenario-name ${{ matrix.avd_scenario }}
- name: Check GIT status
run: |
sh .github/check-git-status.sh
# ----------------------------------- #
# Ansible tests
# ----------------------------------- #
ansible_test_sanity:
name: Run ansible-test sanity validation
runs-on: ubuntu-latest
needs: [build_pyavd, file-changes]
strategy:
fail-fast: true
matrix:
ansible_version: [stable, devel]
include:
- ansibe_version: stable
pip_installation: "ansible-core<2.21.0"
- ansibe_version: devel
pip_installation: "ansible-core @ git+https://github.com/ansible/ansible.git@milestone"
skip_test: "--skip-test ansible-doc"
steps:
- uses: actions/checkout@v6
- name: Set up Python 3
uses: actions/setup-python@v6
with:
python-version: |
3.10
3.11
3.12
3.13
3.14
- name: Download pyavd Artifact
uses: actions/download-artifact@v8
with:
name: pyavd
path: /tmp/pyavd/
- name: Install pyavd and Ansible requirements
run: |
pip install "${{ matrix.pip_installation }}" "${{ needs.build_pyavd.outputs.wheel_file }}[ansible-collection]"
- name: Run ansible-test sanity
working-directory: ansible_collections/arista/avd
# Skip ansible-doc due to testing with ansible-core @ devel and raising error on supported Ansible version
run: |
ansible-test sanity --color yes -v ${{ matrix.skip_test }}
ansible_test_units:
name: Run ansible-test units test cases
runs-on: ubuntu-latest
needs: [file-changes, build_pyavd]
steps:
- uses: actions/checkout@v6
- name: Set up Python 3
uses: actions/setup-python@v6
with:
python-version: |
3.12
- name: Download pyavd Artifact
uses: actions/download-artifact@v8
with:
name: pyavd
path: /tmp/pyavd/
- name: Install pyavd and ansible requirements
run: |
pip install "ansible-core<2.21.0" "${{ needs.build_pyavd.outputs.wheel_file }}[ansible-collection]"
- name: Run ansible-test units
working-directory: ansible_collections/arista/avd
run: |
ansible-test units --coverage --requirements -vv
ansible-test coverage xml
mv tests/output/reports/coverage.xml ./units-coverage.xml
- name: Upload coverage from ansible-test units
uses: actions/upload-artifact@v7
with:
name: ansible-test-units-coverage
path: ansible_collections/arista/avd/units-coverage.xml
ansible_test_integration:
name: Run ansible-test integration test cases
runs-on: ubuntu-latest
needs: [file-changes]
steps:
- uses: actions/checkout@v6
- name: Set up Python 3
uses: actions/setup-python@v6
with:
# Testing 3.10 to ensure ansible-core < 2.19 still works.
python-version: |
3.10
3.12
3.13
3.14
- name: Install Python requirements
run: |
pip install "ansible-core<2.21.0" "./python-avd[ansible-collection]" --upgrade
- name: Run ansible-test integration test cases
working-directory: ansible_collections/arista/avd
run: |
ansible-test integration --coverage --requirements -vv
ansible-test coverage xml
mv tests/output/reports/coverage.xml ./integration-coverage.xml
- name: Upload coverage from ansible-test integration
uses: actions/upload-artifact@v7
with:
name: ansible-test-integration-coverage
path: ansible_collections/arista/avd/integration-coverage.xml
# ----------------------------------- #
# Build Collection
# ----------------------------------- #
build_collection:
name: Build Ansible collection
runs-on: ubuntu-latest
steps:
- uses: actions/setup-python@v6
with:
python-version: |
3.12
- uses: actions/checkout@v6
- name: Install Python & Ansible requirements
run: |
# distlib is required when using manifest
pip install "ansible-core<2.21.0" distlib --upgrade
- name: Build Ansible collection
run: |
ansible-galaxy collection build -vvv --force ansible_collections/arista/avd
- name: Upload collection
uses: actions/upload-artifact@v7
with:
name: avd-collection
path: ./arista-avd-*.tar.gz
# ----------------------------------- #
# Galaxy Importer
# ----------------------------------- #
galaxy_importer:
name: Test galaxy-importer
runs-on: ubuntu-latest
needs: [build_collection]
steps:
- uses: actions/setup-python@v6
with:
python-version: |
3.11
- uses: actions/checkout@v6
- name: Install Python & Ansible requirements
run: |
pip install "ansible-core==2.16.0"
- name: Download collection
uses: actions/download-artifact@v8
with:
name: avd-collection
- name: Install galaxy-importer
# Install the specific version of galaxy-importer used on galaxy.ansible.com
# The version conflicts with our requirements,
# so we let the galaxy-importer version resolve remaining requirements.
run: |
pip install "galaxy-importer==0.4.31"
- name: Run galaxy-importer checks
run: python -m galaxy_importer.main *.tar.gz
- uses: actions/upload-artifact@v7
with:
name: importer-logs
path: ./importer_result.json
# ----------------------------------- #
# Ansible Lint
# Run on the built collection from Galaxy importer
# ----------------------------------- #
ansible_lint:
name: Run ansible-lint test case
runs-on: ubuntu-latest
needs: [file-changes, build_pyavd]
env:
ANSIBLE_COLLECTIONS_PATH: ${{ github.workspace }}
steps:
- uses: actions/checkout@v6
- name: Set up Python 3
uses: actions/setup-python@v6
with:
python-version: |
3.10
3.11
3.12
3.13
3.14
- name: Download pyavd Artifact
uses: actions/download-artifact@v8
with:
name: pyavd
path: /tmp/pyavd/
- name: Install Python & Ansible requirements
run: |
pip install "${{ needs.build_pyavd.outputs.wheel_file }}[ansible-collection]" --group dev --upgrade
- name: Download collection
uses: actions/download-artifact@v8
with:
name: avd-collection
- name: Extract collection
run: |
mkdir collections
tar xvzf arista-avd-*.tar.gz -C collections
- name: Run ansible-lint
working-directory: collections
run: |
ansible-lint --force-color --strict -v
# ----------------------------------- #
# Codespell
# ----------------------------------- #
codespell:
name: Check for common misspellings in text files
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: actions/setup-python@v6
with:
python-version: "3.12"
- name: Install codespell
run: pip install codespell==2.4.2
- name: Run codespell
run: codespell --config .codespellrc
# ----------------------------------- #
# j2lint
# ----------------------------------- #
j2lint:
name: Check for linting errors on Jinja2 files
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: actions/setup-python@v6
with:
python-version: "3.12"
- name: Install j2lint
run: pip install j2lint==1.2.0
- name: Run j2lint
run: j2lint .
# ----------------------------------- #
# markdownlint
# ----------------------------------- #
markdownlint:
name: Check for linting errors on Markdown files
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- name: Install markdownlint-cli2
run: npm install markdownlint-cli2 --global
- name: Run markdownlint-cli2
# Exclusions are configured in .markdownlint-cli2.yaml
run: markdownlint-cli2 "**/*.md"
- name: Check GIT status
run: sh .github/check-git-status.sh
# ----------------------------------- #
# Check schema tables in docs
# ----------------------------------- #
check_schema_tables_in_docs:
name: Check for schema tables in documentation
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6
- uses: actions/setup-python@v6
with:
python-version: "3.12"
- name: Check for schema tables in documentation
run: python development/find_missing_tables.py @.find-missing-tables-args
# ----------------------------------- #
# Test of pyavd
# ----------------------------------- #
test_pyavd:
name: Test pyavd (Python ${{ matrix.python }}, Suite ${{ matrix.suite.name }})
runs-on: ubuntu-latest
needs: [file-changes]
if: |
needs.file-changes.outputs.eos_design == 'true' ||
needs.file-changes.outputs.config_gen == 'true' ||
needs.file-changes.outputs.pyavd == 'true' ||
needs.file-changes.outputs.requirements == 'true' ||
github.event_name == 'merge_group'
strategy:
fail-fast: false
matrix:
python: ["3.10", "3.11", "3.12", "3.13", "3.14"]
suite:
- name: "Main-Tests"
id: Main-Tests
pytest_args: >-
--ignore=python-avd/tests/pyavd/molecule_scenarios/test_get_device_config.py
--ignore=python-avd/tests/pyavd/molecule_scenarios/test_negative_eos_designs.py
--ignore=python-avd/tests/schema_tools/metaschema/test_meta_schema_model.py
upload_compiled_templates: true
- name: "Excluded-Tests (test_get_device_config and test_meta_schema_model)"
id: Excluded-test_get_device_config-and-test_meta_schema_model
pytest_args: >-
python-avd/tests/pyavd/molecule_scenarios/test_get_device_config.py
python-avd/tests/schema_tools/metaschema/test_meta_schema_model.py
- name: "Excluded-Tests (test_negative_eos_designs)"
id: Excluded-test_negative_eos_designs
pytest_args: >-
python-avd/tests/pyavd/molecule_scenarios/test_negative_eos_designs.py
steps:
- uses: actions/checkout@v6
- name: Set up Python 3
uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python }}
- name: Install tox
run: |
pip install tox tox-gh-actions --upgrade
- name: Run pytest via tox for ${{ matrix.python }}
run: |
tox run -- ${{ matrix.suite.pytest_args }}
- name: Rename the coverage file
if: matrix.python == '3.11'
run: |
mv .coverage coverage-${{ matrix.suite.id }}.dat
- name: Upload pytest coverage data
if: matrix.python == '3.11'
uses: actions/upload-artifact@v7
with:
name: coverage-data-${{ matrix.suite.id }}
path: coverage-${{ matrix.suite.id }}.dat
- name: Upload eos_designs compiled templates from pytest
if: matrix.suite.upload_compiled_templates == true && matrix.python == '3.11'
uses: actions/upload-artifact@v7
with:
name: pytest-eos-designs-compiled-templates
path: python-avd/pyavd/_eos_designs/j2templates/compiled_templates/
- name: Upload eos_cli_config_gen compiled templates from pytest
if: matrix.suite.upload_compiled_templates == true && matrix.python == '3.11'
uses: actions/upload-artifact@v7
with:
name: pytest-eos-cli-config-gen-compiled-templates
path: python-avd/pyavd/_eos_cli_config_gen/j2templates/compiled_templates/
generate_pyavd_coverage_report:
name: Test pyavd python 3.11 coverage report
runs-on: ubuntu-latest
needs: [test_pyavd]
steps:
- uses: actions/checkout@v6
- name: Set up Python 3.11
uses: actions/setup-python@v6
with:
python-version: "3.11"
- name: Install coverage
run: pip install --group coverage
- name: Download coverage artifacts
uses: actions/download-artifact@v8
with:
pattern: coverage-data-*
merge-multiple: true
- name: Download eos_designs compiled templates artifact
uses: actions/download-artifact@v8
with:
name: pytest-eos-designs-compiled-templates
path: python-avd/pyavd/_eos_designs/j2templates/compiled_templates/
- name: Download eos_cli_config_gen compiled templates artifact
uses: actions/download-artifact@v8
with:
name: pytest-eos-cli-config-gen-compiled-templates
path: python-avd/pyavd/_eos_cli_config_gen/j2templates/compiled_templates/
- name: Combine and report test coverage
run: |
set -ex
coverage combine coverage-*.dat
coverage report
coverage xml
- name: Upload pytest coverage report
uses: actions/upload-artifact@v7
with:
name: pytest-coverage
path: coverage.xml
codecov:
name: Upload coverage to codecov
needs:
- ansible_test_units
- ansible_test_integration
- generate_pyavd_coverage_report
if: github.repository == 'aristanetworks/avd'
uses: ./.github/workflows/codecov.yml