-
Notifications
You must be signed in to change notification settings - Fork 2
/
tox.ini
142 lines (132 loc) · 3.96 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
[tox]
# Default environments to run with vanilla `tox`
envlist = py, lint
# See: https://flake8.pycqa.org/en/latest/user/configuration.html#project-configuration
# and: https://github.com/PyCQA/flake8/issues/234
# TL;DR: keep in tox.ini until ?
[flake8]
max-line-length = 88
exclude =
.git
.eggs
.tox
ignore =
# Missing blank line after last section (waste of space...)
D413,
# I document the class, not __init__
D107,
# Lining up operators is less important than making it easy for users to understand.
W504
[testenv]
# Required to be able to send coverage reports from Travis to codecov
passenv = PYTHONWARNINGS TOXENV CI TRAVIS TRAVIS_*
usedevelop = true
deps =
pytest
pytest-cov
# not a real dependency, but used if available <3
Pygments
commands =
pytest . {posargs}
{envpython} -V -V
[testenv:flake8]
# Skipping install for flake8 is OK.
skip_install = true
deps =
flake8
flake8-docstrings
flake8-import-order
pep8-naming
pytest-flake8
commands =
flake8 --version
pytest --flake8 -m flake8 ci_exec/ demos/ docs/ tests/
[testenv:mypy]
# To test that the py.typed gets installed correctly, we need to install.
skip_install = false
deps =
mypy
pytest-mypy
types-docutils
types-Pygments
commands =
mypy --version
pytest --mypy -m mypy ci_exec/ docs/ tests/
# Copy the demos directory to the temp dir, and run mypy with the current
# working directory as the temp dir. Doing this to validate that the
# py.typed gets installed as expected. Otherwise, consuming packages do
# not have the ability to run mypy :scream:
{envpython} -c "import shutil; import os.path as osp; \
shutil.rmtree(osp.join('{envtmpdir}', 'demos'), ignore_errors=True); \
shutil.copytree('demos', osp.join('{envtmpdir}', 'demos'))"
{envpython} -c "import subprocess; \
subprocess.run(['mypy', '--pretty', 'demos'], \
cwd='{envtmpdir}', check=True)"
[testenv:lint]
# Since mypy needs to install this needs to install too.
skip_install = false
deps =
{[testenv:flake8]deps}
{[testenv:mypy]deps}
commands =
{[testenv:flake8]commands}
{[testenv:mypy]commands}
[testenv:demos]
passenv = TERM
# In order to get coverage from the demos, we need to inform `python` invokations to
# actually run `coverage`.
setenv =
CI_EXEC_DEMOS_COVERAGE = YES
skip_install = true
deps =
coverage[toml]
commands =
# Intended use case of this in CI is to do multiple passes, e.g.:
#
# tox -e demos -- <demo name>
# tox -e demos -- <demo name> --animate
#
# We run things in parallel, as well as demos/__main__.py invokes the "shell"
# scripts with `coverage run -p <...>` as well. The implication: after running
# everything, we need to `coverage combine -a` on CI to merge all results.
coverage run -p demos/ {posargs}
[testenv:docs]
deps =
-rdocs/requirements.txt
commands =
sphinx-build -W -n -b html -d {envtmpdir}/doctrees docs/source {envtmpdir}/html
[testenv:linkcheck]
deps =
-rdocs/requirements.txt
commands =
sphinx-build -W -n -b linkcheck -d {envtmpdir}/doctrees docs/source {envtmpdir}/linkcheck
[testenv:dist]
skip_install = true
deps =
wheel
setuptools
readme_renderer
twine
commands =
# TODO: this is deprecated, but gives a legit exit code (twine check dist/* does not).
{envpython} setup.py check -r -s
{envpython} setup.py sdist
{envpython} setup.py bdist_wheel
twine check dist/*
# Not exactly a typical thing to do with tox...but suits my workflow.
[testenv:clean]
skip_install = true
deps =
whitelist_externals =
find
rm
commands =
rm -f .coverage
rm -rf build/
rm -rf dist/
rm -rf ci_exec.egg-info/
rm -rf .eggs/
find . -name "*.py[co]" -type f -exec rm -f \{\} +
find . -name "__pycache__" -type d -exec rm -rf \{\} +
find . -type d -name ".cache" -exec rm -rf \{\} +
find . -type d -name ".mypy_cache" -exec rm -rf \{\} +