forked from andreoliwa/nitpick
-
Notifications
You must be signed in to change notification settings - Fork 0
/
tox.ini
147 lines (134 loc) · 5.17 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
[tox]
# https://tox.readthedocs.io/en/latest/config.html
isolated_build = True
envlist = clean,lint,py310,py39,py38,py37,docs,report
# https://github.com/ymyzk/tox-gh-actions breaks with "InterpreterNotFound" when there is a "requires" key
# clean: commands succeeded
# lint: commands succeeded
# ERROR: py310: InterpreterNotFound: python3.10
# py39: commands succeeded
# py38: commands succeeded
# ERROR: py37: InterpreterNotFound: python3.7
# docs: commands succeeded
# report: commands succeeded
requires =
# Installing with "requires" even though it's not the recommended option
# https://github.com/enpaul/tox-poetry-installer/#installing
tox-poetry-installer[poetry] >= 0.9.0
[testenv]
description = Run tests with pytest and coverage
extras = test
depends =
{py310,py39,py38,py37}: clean
report: py310,py39,py38,py37
setenv =
PY_IGNORE_IMPORTMISMATCH = 1
commands =
python -m pip --version
# Useful to debug on GitHub Actions
python -m pip install icecream
# https://pytest-cov.readthedocs.io/en/latest/config.html#caveats
# https://docs.pytest.org/en/stable/skipping.html
# show extra test summary info for all tests except passed (failed/error/skipped/xfail/xpassed):
python -m pytest --cov-config=tox.ini --cov --cov-append --cov-report=term-missing --doctest-modules -s -ra {posargs:}
[testenv:clean]
description = Erase data for the coverage report before running tests
platform = linux
skip_install = true
deps = coverage
commands = coverage erase
[testenv:lint]
description = Lint all files with pre-commit
basepython = python3.9
platform = linux
# pylint needs both these extras:
extras =
# Install pylint itself
lint
# For pylint to inspect tests
test
deps =
pip>=21.1
safety
# Run nitpick and pylint with tox, because local repos don't seem to work well with https://pre-commit.ci/
commands =
# Run Nitpick locally on itself
nitpick fix
pylint src/
safety check
[testenv:report]
description = Coverage report
platform = linux
skip_install = true
deps = coverage
commands =
coverage report
coverage html
[testenv:docs]
description = Build the HTML docs using Sphinx (sphinx-build, API docs, link checks)
basepython = python3.9
platform = linux
extras = doc
# https://tox.readthedocs.io/en/latest/config.html#conf-allowlist_externals
allowlist_externals =
git
printf
passenv = GITHUB_ACTIONS GITHUB_REF_NAME
commands =
# TODO: fix: this step is optional because it generates a different output on GitHub Actions (Ubuntu)
- python3 docs/autofix_docs.py
sphinx-apidoc --force --follow-links --module-first --separate --implicit-namespaces --ext-autodoc --ext-doctest --ext-intersphinx --ext-todo --ext-coverage --ext-imgmath --ext-mathjax --ext-ifconfig --ext-viewcode --ext-githubpages --output-dir docs/source src/nitpick/
# Use these options to debug Sphinx: -nWT --keep-going -vvv
sphinx-build --color -j auto -d "{toxworkdir}/docs_doctree" -b html docs "{toxworkdir}/docs_out" {posargs}
# If files were created/changed by the commands above, the git repo will be dirty and the next commands will fail.
git add .
git status
printf "\n\033[1;31mIf tox failed at this point, it means that files were created (see above) and documentation is missing.\n\033[1;31mRun \033[32minvoke doc\033[1;31m in your development machine and commit the generated .rst files.\033[0m\n"
# TODO: fix: this step is optional because it generates a different output on GitHub Actions (Ubuntu)
- git diff-index --quiet HEAD --
# Run link checks after building the docs
# To stop failing when a page is unreachable, add a hyphen at the start of the line:
# https://tox.readthedocs.io/en/latest/example/basic.html#ignoring-exit-code
# Some errors during link check have to be ignored.
# E.g.: when a new TOML style is added, its link will be broken until a new release is published.
- sphinx-build --color -j auto -b linkcheck docs "{toxworkdir}/docs_out"
[pytest]
# https://docs.pytest.org/en/stable/customize.html#tox-ini
addopts =
# Disable HTTP requests on tests (any network calls, actually)
# https://github.com/miketheman/pytest-socket#usage
--disable-socket
norecursedirs = .* build dist CVS _darcs {arch} *.egg venv var docs
# https://docs.pytest.org/en/stable/reference.html#confval-testpaths
testpaths = src tests
markers =
tool_nitpick: options to add to the [tool.nitpick] section on remote styles (see project_remote)
[coverage:run]
# https://coverage.readthedocs.io/en/latest/config.html#run
branch = true
parallel = true
source = src/
omit =
tests/*
.tox/*
*/pypoetry/virtualenvs/*
# This config is needed by https://github.com/marketplace/actions/coveralls-python#usage
relative_files = True
[coverage:report]
# https://coverage.readthedocs.io/en/latest/config.html#report
show_missing = true
precision = 2
skip_covered = true
skip_empty = true
sort = Cover
# https://coverage.readthedocs.io/en/latest/excluding.html#advanced-exclusion
exclude_lines =
pragma: no cover
def __repr__
if self.debug:
if settings.DEBUG
if TYPE_CHECKING:
raise AssertionError
raise NotImplementedError
if 0:
if __name__ == .__main__.: