-
Notifications
You must be signed in to change notification settings - Fork 61
Expand file tree
/
Copy pathtox.ini
More file actions
232 lines (199 loc) · 7.08 KB
/
tox.ini
File metadata and controls
232 lines (199 loc) · 7.08 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
[tox]
# Environments selected for frequent execution during development
# Let's still include flake8-check despite a preceding autopep8 run to filter out certain errors
# (like W293 blank line in multiline strings contains whitespace, or FS003 f-string missing prefix)
# that don't get fixed by autopep8.
envlist = pep8,isort,flake8-check,mypy,typos-check,sphinx-man,sphinx-html,py-docs
minversion = 2.3.2
skipsdist = True
[requirements]
dir = {toxinidir}/requirements
[testenv:venv]
commands = {posargs}
deps =
## TESTS
[testenv]
usedevelop = False
install_command =
pip install {opts} {packages}
deps =
-r{[requirements]dir}/testenv.txt
-r{[requirements]dir}/testenv-runtime.txt
commands =
# `python -m pytest` so that the local plugin for `--full-operands` can be loaded, see https://stackoverflow.com/a/48306599
python -m pytest -p tests.pytest_full_operands \
--numprocesses=auto --junitxml=test-results/testenv-{envname}.xml -m "not completion_e2e" {posargs}
[testenv:coverage]
description = "Check the test coverage of the code"
deps =
-r{[requirements]dir}/coverage.txt
-r{[requirements]dir}/testenv.txt
-r{[requirements]dir}/testenv-runtime.txt
passenv = PYTHON_VERSION
allowlist_externals = cp
commands =
# `python -m pytest` so that the local plugin for `--full-operands` can be loaded, see https://stackoverflow.com/a/48306599
# Generate (or append results to the existing) .coverage binary file (SQLite database)
python -m pytest --cov=git_machete --cov-append --cov-branch --cov-context=test -p tests.pytest_full_operands \
--numprocesses=auto --junitxml=test-results/testenv-{envname}.xml -m "not completion_e2e" {posargs}
# Save a report to htmlcov/
coverage html --show-contexts
# Copy the coverage file so that it can be `coverage combine`d with other results
cp .coverage .coverage.{env:PYTHON_VERSION:bin}
[testenv:coverage-erase]
description = "Erase test coverage data"
deps =
-r{[requirements]dir}/coverage.txt
allowlist_externals = sh
commands =
coverage erase
# No support for globs in tox yet, alas :/
sh -c "rm -f {toxinidir}/.coverage.*"
[coverage:run]
omit = tests/*,git_machete/bin.py
relative_files = True
[coverage:report]
exclude_lines =
except InterruptedError:
except KeyboardInterrupt:
if __name__ == .__main__.:
# Let's exclude Windows-specific code from coverage.
# To speed up CI, we only run tests on Windows on special branches (like develop/master) and not on regular PRs.
# Still, if we were to include Windows-specific coverage on these branches,
# then Codecov will always misleadingly show on regular PRs to develop
# that coverage dropped when comparing to the base branch.
# Note that the same CI logic applies to macOS tests, there're just no special coverage exclusion patterns
# (as there're no macOS-specific statements anywhere in git-machete, unlike with Windows).
if sys.platform == .win32.:
pragma: no cover
raise UnexpectedMacheteException
[testenv:coverage-combine]
description = "Combine coverage results"
deps =
-r{[requirements]dir}/coverage.txt
commands =
# Combine .coverage.* files into .coverage file
coverage combine
# Print a report to console
coverage report
# Save a report to coverage.xml (uploaded to Codecov from CI, as Codecov apparently does not accept .coverage binary files)
coverage xml
[testenv:test-completions]
description = "Test shell completions"
deps =
-r{[requirements]dir}/testenv.txt
-r{[requirements]dir}/testenv-runtime.txt
commands =
pip install . # for some reason, `usedevelop = True` seems to be ignored
pytest --numprocesses=auto --junitxml=test-results/testenv-{envname}.xml -m completion_e2e {posargs}
[pytest]
markers = completion_e2e
## CODE STYLE
[testenv:pep8]
description = "Apply PEP8 formatting"
deps =
-r{[requirements]dir}/pep8.txt
# E402: module level import not at top of file
# W291: trailing whitespace
# W293: blank line contains whitespace
commands =
autopep8 --ignore=E402 --select=W291,W293 --in-place --recursive .
[testenv:flake8-check]
description = "Check code style"
deps =
-r{[requirements]dir}/flake8-check.txt
commands = flake8 --enable-extensions=FS003
# Set flake8 configuration options which are used by the `flake8` command in [testenv:flake8-check]
[flake8]
exclude = ./.*,build,dist,*egg,venv,git_machete/generated_docs.py
per-file-ignores = docs/*,flake8/*,tests/*:KW
# U101 unused argument starting with an underscore
# W504 line break occurred after a binary operator
ignore = U101, W504
import-order-style = pep8
max-line-length = 140
show-source = True
[flake8:local-plugins]
extension =
KW = keyword_argument_checker:KeywordArgumentChecker
paths = flake8
[testenv:isort]
description = "Tidy up imports in Python code"
deps =
-r{[requirements]dir}/isort.txt
commands =
autoflake --in-place --recursive --remove-all-unused-imports .
isort .
[testenv:isort-check]
description = "Check if imports in Python code are correctly sorted"
deps =
-r{[requirements]dir}/isort.txt
commands = isort --check-only .
[testenv:mypy]
deps =
-r{[requirements]dir}/mypy.txt
-r{[requirements]dir}/testenv.txt
commands =
mypy --config-file mypy.ini git_machete tests
[testenv:typos-check]
deps =
-r{[requirements]dir}/typos.txt
commands =
typos --ignore --format brief
[testenv:vulture-check]
description = "Run `vulture` static code analyzer to detect unused code"
deps =
-r{[requirements]dir}/vulture-check.txt
commands = vulture --ignore-names check_hostname,verify_mode,pytest_* git_machete/ tests/
[testenv:cyclic-import-check]
description = "Detect circular imports"
deps =
-r{[requirements]dir}/cyclic-import-check.txt
commands =
pylint --disable=all --enable=cyclic-import git_machete/
## DOCS
# Python >=3.11 is needed in envs that use Sphinx due to https://github.com/VirtusLab/git-machete/issues/936
[testenv:sphinx-html]
basepython=3.12
description = "Build Sphinx documentation in HTML"
deps =
-r{[requirements]dir}/sphinx-docs.txt
allowlist_externals = bash
commands =
bash docs/generate-sphinx-html.sh docs/html
[testenv:sphinx-man]
basepython=3.12
description = "Build Sphinx documentation in groff format (Unix man page)"
deps =
-r{[requirements]dir}/sphinx-docs.txt
allowlist_externals = bash
commands =
bash docs/generate-sphinx-man.sh docs/man
[testenv:sphinx-man-display]
basepython=3.12
description = "Build and display Sphinx documentation in groff format (Unix man page)"
deps =
depends = sphinx-man
allowlist_externals = sh
commands =
sh -c 'groff -man -Tascii < docs/man/git-machete.1 2>/dev/null'
[testenv:sphinx-man-check]
basepython=3.12
description = "Check if Unix man page is up to date with reStructuredText sources"
deps =
-r{[requirements]dir}/sphinx-docs.txt
allowlist_externals = bash
commands =
bash docs/enforce-sphinx-man-up-to-date.sh
[testenv:py-docs]
description = "Build Python documentation"
deps =
allowlist_externals = sh
commands =
sh -c "python docs/generate_py_docs.py > git_machete/generated_docs.py"
[testenv:py-docs-check]
description = "Check if Python documentation is up to date with with reStructuredText sources"
deps =
allowlist_externals = bash
commands =
bash docs/enforce-py-docs-up-to-date.sh