-
Notifications
You must be signed in to change notification settings - Fork 0
/
tox.ini
159 lines (140 loc) · 4.37 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
#: -- TOX CONFIG -----------------------------------------------------------------------
[tox]
package = commit_msg_jira_hook
minversion = 3.15.0
#: For locally skipping missing interpreters use `tox -s false`
skip_missing_interpreters = true
#: Activate isolated build environment - PEP-517 and PEP-518.
isolated_build = true
#: Application -> True; Library -> False
skipsdist = false
envlist =
pre-commit
py3{10,9,8,7,6}
coverage
package
safety
[testenv]
description = basic config env
passenv =
PYTEST_*
HOME
CI
setenv =
PIP_DISABLE_VERSION_CHECK = 1
COVERAGE_FILE = {env:COVERAGE_FILE:{toxworkdir}/.coverage.{envname}}
download = true
[testenv:pre-commit]
description = format and check the code
passenv =
SSH_AUTH_SOCK
extras =
pre-commit
testing
ignore_errors = true
commands =
pre-commit run {posargs} --all-files --show-diff-on-failure
python -c \
'from pathlib import Path; \
exe = Path(r"{envbindir}")/"pre-commit"; \
print(f"""HINT: to add checks as pre-commit hook run: "\{exe\} install".""")'
[testenv:safety]
description = check all dependencies for known vulnerabilities
skip_install = true
deps =
poetry>=0.12
safety
commands =
#: write py script creating requirements.txt
python -c \
'f=open(r"{envtmpdir}/safety.py","w"); \
f.write("""import subprocess\n"""); \
f.write("""import re\n"""); \
f.write("""with open("{envtmpdir}/requirements.txt","w") as f:\n"""); \
f.write(""" cmd = subprocess.run(["poetry", "show"], capture_output=True)\n"""); \
f.write(""" cmd.check_returncode()\n"""); \
f.write(""" f.write(re.sub(r\"([\\w-]+)[ (!)]+([\\d.a-z-]+).*\", r\"\\1==\\2\", cmd.stdout.decode()))\n"""); \
f.close()'
python {envtmpdir}/safety.py
safety check -r {envtmpdir}/requirements.txt --full-report
[testenv:py{py3,39,38,37,36}]
description = run tests with {basepython}
extras = testing
commands =
pytest \
--basetemp="{envtmpdir}" \
--cov "{envsitepackagesdir}/{[tox]package}" \
--cov-fail-under 0 \
--junitxml {toxworkdir}/junit.{envname}.xml \
-n={env:PYTEST_XDIST_N:auto} \
{posargs:tests}
[testenv:coverage]
description = combine coverage data and create report; generates a diff coverage
against origin/master (can be changed by setting DIFF_AGAINST env var)
depends = py{py3,39,38,37,36}
passenv =
{[testenv]passenv}
DIFF_AGAINST
setenv = COVERAGE_FILE={toxworkdir}/.coverage
skip_install = true
deps =
coverage[toml]>=5,<6
diff_cover
parallel_show_output = true
commands =
coverage combine
coverage report -m
coverage xml -o {toxworkdir}/coverage.xml
coverage html -d {toxworkdir}/htmlcov
diff-cover --compare-branch {env:DIFF_AGAINST:origin/master} {toxworkdir}/coverage.xml
[testenv:package]
description = check sdist and wheel
skip_install = true
deps =
poetry>=0.12
twine
commands =
poetry build -vvv
twine check dist/*
[testenv:dev]
description = create dev env
deps =
safety
flake8>=3.8.3
bandit>=1.6.2
pydocstyle>=5.1.0
rstcheck>=3.3.1
skip_install = true
whitelist_externals = poetry
commands =
poetry install -E "testing pre-commit"
#: HACK: Add `devtools.debug()` to `__builtins__` via `_debug.pth` in venv site-packages
python -c \
'f=open(r"{envsitepackagesdir}/_debug.pth","w"); \
f.write("import devtools;__builtins__.update(debug=devtools.debug)\n"); \
f.close()'
python -m pip list --format=columns
safety check --full-report
python -c 'print("PYTHON INTERPRETER LOCATION: " + r"{envpython}")'
#: -- MYPY CONFIG ----------------------------------------------------------------------
# TODO: 06.06.2020: move config to pyproject.toml when supported
[mypy]
warn_unused_ignores = true
show_error_codes = true
;warn_unused_configs = true
;scripts_are_modules = true
;ignore_missing_imports = true
#: -- FLAKE8 CONFIG --------------------------------------------------------------------
# TODO: 06.06.2020: move config to pyproject.toml when supported
[flake8]
count = true
statistics = true
extend_exclude =
*venv*/,
*.egg,
build/,
extend_ignore = E203
max_line_length = 88
max_complexity = 20
pytest_fixture_no_parentheses = true
format = "${cyan}%(path)s${reset}:${yellow_bold}%(row)d${reset}:${green_bold}%(col)d${reset}: ${red_bold}%(code)s${reset} %(text)s"