-
Notifications
You must be signed in to change notification settings - Fork 19
/
tox.ini
52 lines (44 loc) · 1.61 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
[tox]
minversion = 3.21
# relies on the correct version of Python installed
envlist = ruff,tests,mypy
# https://github.com/tox-dev/tox/issues/20#issuecomment-247788333
# hack to prevent .tox from crapping to the project directory
toxworkdir = {env:TOXWORKDIR_BASE:}{toxinidir}/.tox
[testenv]
# TODO how to get package name from setuptools?
package_name = "grasp_backend"
passenv =
# useful for tests to know they are running under ci
CI
CI_*
# respect user's cache dirs to prevent tox from crapping into project dir
PYTHONPYCACHEPREFIX
MYPY_CACHE_DIR
RUFF_CACHE_DIR
# note: --use-pep517 below is necessary for tox --parallel flag to work properly
# otherwise it seems that it tries to modify .eggs dir in parallel and it fails
[testenv:ruff]
commands =
{envpython} -m pip install --use-pep517 -e .[testing]
{envpython} -m ruff check src/ tests/
[testenv:tests]
commands =
{envpython} -m pip install --use-pep517 -e .[testing]
# posargs allow test filtering, e.g. tox ... -- -k test_name
{envpython} -m pytest \
src \
{posargs}
# TODO hmm --pyargs {[testenv]package_name} isn't working due to extra conftest in tests/ directory??
[testenv:mypy]
commands =
{envpython} -m pip install --use-pep517 -e .[testing]
{envpython} -m mypy --install-types --non-interactive \
-p {[testenv]package_name} \
# txt report is a bit more convenient to view on CI
--txt-report .coverage.mypy \
--html-report .coverage.mypy \
{posargs}
{envpython} -m mypy --install-types --non-interactive \
-p tests \
{posargs}