-
Notifications
You must be signed in to change notification settings - Fork 56
/
Copy pathtox.ini
200 lines (175 loc) · 6.07 KB
/
tox.ini
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
[tox]
# Environments selected for frequent execution during development
# Let's still include pep8-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,pep8-check,mypy,vulture-check,sphinx-man,sphinx-html,py-docs
minversion = 2.3.2
skipsdist = True
[requirements]
dir = {toxinidir}/requirements
[testenv]
usedevelop = False
install_command =
pip install {opts} {packages}
deps =
-r{[requirements]dir}/testenv.txt
allowlist_externals = mkdir
commands =
mkdir -p test-results/
# `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:test-completions]
description = "Test shell completions"
commands =
pip install -e . # for some reason, `usedevelop = True` seems to be ignored
mkdir -p test-results/
pytest --numprocesses=auto --junitxml=test-results/testenv-{envname}.xml -m completion_e2e {posargs}
[pytest]
markers = completion_e2e
[testenv:pep8]
description = "Apply PEP8 formatting"
deps =
-r{[requirements]dir}/pep8.txt
# E402 module level import not at top of file
commands =
autopep8 --ignore=E402 --in-place --recursive .
[testenv:pep8-check]
description = "Check if formatting conforms to PEP 8"
deps =
-r{[requirements]dir}/pep8-check.txt
commands = flake8 --enable-extensions=FS003
# Set flake8 configuration options which are used by the `flake8` command in [testenv:pep8-check]
[flake8]
exclude = ./.*,build,dist,*egg,venv,git_machete/generated_docs.py
# 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
[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: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:venv]
commands = {posargs}
[testenv:coverage]
description = "Check the test coverage of the code"
deps =
-r{[requirements]dir}/coverage.txt
-r{[requirements]dir}/testenv.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 EOFError:
except InterruptedError:
except KeyboardInterrupt:
if __name__ == .__main__.:
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
# 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)"
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"
# The generation of the python docs uses git_machete package
deps =
-r{[requirements]dir}/py-docs.txt
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 =
-r{[requirements]dir}/py-docs.txt
allowlist_externals = bash
commands =
bash docs/enforce-py-docs-up-to-date.sh
[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