Debian Codegraph @

.github/workflows/code-testing.yml

raw symbols SCIP
1 ---
2 name: Linting and Testing ANTA
3 on:
4 push:
5 branches:
6 - main
7 pull_request:
8
9 permissions:
10 contents: read
11
12 jobs:
13 file-changes:
14 runs-on: ubuntu-latest
15 outputs:
16 code: ${{ steps.filter.outputs.code }}
17 docs: ${{ steps.filter.outputs.docs }}
18 steps:
19 - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
20 with:
21 persist-credentials: false
22 - uses: dorny/paths-filter@fbd0ab8f3e69293af611ebaee6363fc25e6d187d # v4.0.1
23 id: filter
24 with:
25 filters: |
26 code:
27 - 'anta/*'
28 - 'anta/**'
29 - 'tests/*'
30 - 'tests/**'
31 # detect dependency changes
32 - 'pyproject.toml'
33 core:
34 - 'anta/*'
35 - 'anta/reporter/*'
36 - 'anta/result_manager/*'
37 - 'anta/tools/*'
38 cli:
39 - 'anta/cli/*'
40 - 'anta/cli/**'
41 tests:
42 - 'anta/tests/*'
43 - 'anta/tests/**'
44 docs:
45 - '.github/workflows/pull-request-management.yml'
46 - 'tools/zensical_extensions/**'
47 - 'mkdocs.yml'
48 - 'docs/*'
49 - 'docs/**'
50 - 'README.md'
51 check-requirements:
52 runs-on: ubuntu-latest
53 strategy:
54 matrix:
55 python-version: ["3.10", "3.11", "3.12", "3.13", "3.14"]
56 needs: file-changes
57 steps:
58 - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
59 with:
60 persist-credentials: false
61 - name: Set up Python ${{ matrix.python-version }}
62 uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1 # v6.3.0
63 with:
64 python-version: ${{ matrix.python-version }}
65 - name: install requirements
66 run: |
67 pip install .
68 - name: install dev requirements
69 run: pip install --group dev
70 lint-python:
71 name: Check the code style
72 runs-on: ubuntu-latest
73 needs: file-changes
74 steps:
75 - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
76 with:
77 persist-credentials: false
78 - name: Setup Python
79 uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1 # v6.3.0
80 with:
81 python-version: "3.11"
82 - name: Install dependencies
83 run: pip install tox
84 - name: "Run tox linting environment"
85 run: tox run -e lint
86 type-python:
87 name: Check typing
88 runs-on: ubuntu-latest
89 needs: file-changes
90 steps:
91 - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
92 with:
93 persist-credentials: false
94 - name: Setup Python
95 uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1 # v6.3.0
96 with:
97 python-version: "3.11"
98 - name: Install dependencies
99 run: pip install tox
100 - name: "Run tox typing environment"
101 run: tox run -e type
102 test-python:
103 name: Pytest across all supported python versions
104 runs-on: ubuntu-latest
105 needs: [lint-python, type-python]
106 strategy:
107 matrix:
108 python: ["3.10", "3.11", "3.12", "3.13", "3.14"]
109 steps:
110 - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
111 with:
112 persist-credentials: false
113 - name: Setup Python
114 uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1 # v6.3.0
115 with:
116 python-version: ${{ matrix.python }}
117 - name: Install dependencies
118 run: pip install tox tox-gh-actions
119 - name: "Run pytest via tox for ${{ matrix.python }}"
120 run: tox run
121 - name: Upload coverage from pytest
122 # Coverage only runs as part of 3.11.
123 if: |
124 matrix.python == '3.11'
125 uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
126 with:
127 name: pytest-coverage
128 path: coverage.xml
129 test-python-windows:
130 name: Pytest on 3.12 for windows
131 runs-on: windows-2022
132 needs: [lint-python, type-python]
133 if: needs.file-changes.outputs.code == 'true'
134 env:
135 # Required to prevent asyncssh to fail.
136 USERNAME: WindowsUser
137 steps:
138 - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
139 with:
140 persist-credentials: false
141 - name: Setup Python
142 uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1 # v6.3.0
143 with:
144 python-version: 3.12
145 - name: Install dependencies
146 run: pip install tox tox-gh-actions
147 - name: Run pytest via tox for 3.12 on Windows
148 run: tox run
149 test-documentation:
150 name: Build offline documentation for testing
151 runs-on: ubuntu-latest
152 needs: [test-python]
153 steps:
154 - uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7.0.0
155 with:
156 fetch-depth: 0
157 persist-credentials: false
158 - name: Setup Python
159 uses: actions/setup-python@ece7cb06caefa5fff74198d8649806c4678c61a1 # v6.3.0
160 with:
161 python-version: "3.11"
162 - name: Install dependencies
163 run: |
164 # Keep generated CLI snippets stable with Click's optional subcommand rendering.
165 pip install -e ".[cli]" "click~=8.4.2" --group doc -e tools/zensical_extensions
166 - name: "Check generated CLI doc snippets"
167 run: |
168 python docs/scripts/generate_doc_snippets.py
169 if [ -n "$(git status --porcelain -- docs/snippets)" ]; then
170 git status --short -- docs/snippets
171 git diff -- docs/snippets
172 exit 1
173 fi
174 - name: "Build Zensical documentation offline"
175 run: zensical build --strict
176 benchmarks:
177 name: Benchmark ANTA for Python 3.12
178 needs: [test-python]
179 if: needs.file-changes.outputs.code == 'true' && github.repository == 'aristanetworks/anta'
180 permissions:
181 contents: read
182 id-token: write
183 uses: ./.github/workflows/codspeed.yml
184 codecov:
185 name: Upload coverage to codecov
186 needs: [test-python]
187 if: github.repository == 'aristanetworks/anta'
188 permissions:
189 contents: read
190 id-token: write
191 uses: ./.github/workflows/codecov.yml