-
Notifications
You must be signed in to change notification settings - Fork 77
Expand file tree
/
Copy pathtox.ini
More file actions
151 lines (127 loc) · 4.33 KB
/
tox.ini
File metadata and controls
151 lines (127 loc) · 4.33 KB
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
[tox]
minversion = 4
# relies on the correct version of Python installed
# (we rely on CI for the test matrix)
envlist = ruff,tests-core,tests-all,mypy-core,ty-core,mypy-all,ty-all
# NOTE: we don't run end2end by default since it requires elaborate setup
# 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 = "promnesia"
pass_env =
# 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
#
MY_CONFIG
set_env =
# do not add current working directory to pythonpath
# generally this is more robust and safer, prevents weird issues later on
PYTHONSAFEPATH=1
runner = uv-venv-lock-runner
uv_sync_locked = false
[testenv:ruff]
skip_install = true
dependency_groups = testing
commands =
{envpython} -m ruff check \
{posargs}
# just the very core tests with minimal dependencies
[testenv:tests-core]
dependency_groups = testing
commands =
# posargs allow test filtering, e.g. tox ... -- -k test_name
{envpython} -m pytest \
--pyargs {[testenv]package_name} \
# note: sources are tested in tests-all
--ignore src/promnesia/sources \
--ignore src/promnesia/tests/sources \
{posargs}
[testenv:tests-all]
dependency_groups = testing-all
commands =
# used in some tests
{envpython} -m my.core module install \
my.google.takeout.parser \
my.hypothesis
{envpython} -m pytest \
--pyargs {[testenv]package_name} \
{posargs}
[testenv:end2end]
pass_env =
{[testenv]pass_env}
DISPLAY # needed to launch browser
XAUTHORITY # for pyautogui -- see https://stackoverflow.com/questions/48103873/pip3-install-pyautogui-error-code-1
set_env =
{[testenv]set_env}
# for some reason pytest struggles to discover tests otherwise?
# unless we add (even if empty) conftest.py and __init__.py files
PYTHONSAFEPATH=
PYTEST_TIMEOUT=120
dependency_groups = testing-end2end
commands =
{envpython} -m my.core module install my.hypothesis
{envpython} -m pytest \
--pyargs \
tests.test_end2end \
{posargs}
[testenv:mypy-core]
dependency_groups = typecheck
commands =
{envpython} -m mypy --no-install-types \
# note: sources are tested separately, below
-p {[testenv]package_name} --exclude 'sources/*' \
# txt report is a bit more convenient to view on CI
--txt-report .coverage.mypy-core \
--html-report .coverage.mypy-core \
{posargs}
[testenv:ty-core]
# had some weird failures on windows only? skip for now
platform = ^(?!win32).*$
dependency_groups = typecheck
commands =
{envpython} -m ty \
check src \
--exclude '**/sources/' \
{posargs}
[testenv:typecheck-all_base]
hpi_modules =
my.browser.export \
my.fbmessenger \
my.github.ghexport \
my.google.takeout.parser \
my.hypothesis \
my.instapaper \
my.pocket \
my.reddit
[testenv:mypy-all]
dependency_groups = typecheck-all
commands =
{envpython} -m my.core module install {[testenv:typecheck-all_base]hpi_modules}
{envpython} -m mypy --no-install-types \
-p {[testenv]package_name} \
--txt-report .coverage.mypy-all \
--html-report .coverage.mypy-all \
# this is for github actions to upload to codecov.io
# sadly xml coverage crashes on windows... so we need to disable it
{env:CI_MYPY_COVERAGE} \
{posargs}
# ugh. a bit crap to run it separately
# but first will need to move tests inside the package if we want otherwise?
# and I recall it was problematic at times..
{envpython} -m mypy --no-install-types \
-p tests --exclude 'testdata/*' \
{posargs}
[testenv:ty-all]
dependency_groups = typecheck-all
commands =
{envpython} -m my.core module install {[testenv:typecheck-all_base]hpi_modules}
{envpython} -m ty \
check \
{posargs}