-
Notifications
You must be signed in to change notification settings - Fork 61
/
Copy pathtox.ini
169 lines (147 loc) Β· 5.46 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
160
161
162
163
164
165
166
167
168
169
[tox]
minversion = 3.21
# relies on the correct version of Python installed
envlist = ruff,tests-core,tests-all,demo,mypy-core,mypy-misc
# 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 = "my"
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
setenv =
HPI_MODULE_INSTALL_USE_UV=true
uv_seed = true # seems necessary so uv creates separate venvs per tox env?
# 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]
deps =
-e .[testing]
commands =
{envpython} -m ruff check my/
# just the very core tests with minimal dependencies
[testenv:tests-core]
deps =
-e .[testing]
commands =
{envpython} -m pytest \
# importlib is the new suggested import-mode
# without it test package names end up as core.tests.* instead of my.core.tests.*
--import-mode=importlib \
--pyargs {[testenv]package_name}.core \
# ignore orgmode because it imports orgparse
# tbh not sure if it even belongs to core, maybe move somewhere else..
# same with pandas?
--ignore my/core/orgmode.py \
{posargs}
# todo maybe also have core tests and misc tests? since ideally want them without dependencies
[testenv:tests-all]
setenv =
# deliberately set to nonexistent path to check the fallback logic
# TODO not sure if need it?
MY_CONFIG=nonexistent
HPI_TESTS_USES_OPTIONAL_DEPS=true
deps =
-e .[testing]
uv # for hpi module install
cachew
ijson # optional dependency for various modules
commands =
{envpython} -m my.core module install \
## tz/location
my.location.google \
my.time.tz.via_location \
my.ip.all \
my.location.gpslogger \
my.location.fallback.via_ip \
my.google.takeout.parser \
##
my.calendar.holidays \
my.orgmode \ # my.body.weight dep
my.coding.commits \
my.pdfs \
my.reddit.rexport
{envpython} -m pytest \
# importlib is the new suggested import-mode
# without it test package names end up as core.tests.* instead of my.core.tests.*
--import-mode=importlib \
--pyargs {[testenv]package_name}.core {[testenv]package_name}.tests \
{posargs}
[testenv:demo]
deps =
git+https://github.com/karlicoss/hypexport
commands =
{envpython} ./demo.py
[testenv:mypy-core]
deps =
-e .[testing,optional]
orgparse # for core.orgmode
gpxpy # for hpi query --output gpx
commands =
{envpython} -m mypy --no-install-types \
-p {[testenv]package_name}.core \
--txt-report .coverage.mypy-core \
--html-report .coverage.mypy-core \
{posargs}
# specific modules that are known to be mypy compliant (to avoid false negatives)
# todo maybe split into separate jobs? need to add comment how to run
[testenv:mypy-misc]
deps =
-e .[testing,optional]
uv # for hpi module install
lxml-stubs # for my.smscalls
types-protobuf # for my.google.maps.android
types-Pillow # for my.photos
commands =
{envpython} -m my.core module install \
my.arbtt \
my.browser.export \
my.coding.commits \
my.emfit \
my.endomondo \
my.fbmessenger.export \
my.github.ghexport \
my.goodreads \
my.google.maps.android \
my.google.takeout.parser \
my.hackernews.harmonic \
my.hypothesis \
my.instapaper \
my.ip.all \
my.kobo \
my.location.gpslogger \
my.monzo.monzoexport \
my.orgmode \
my.pdfs \
my.pinboard \
my.pocket \
my.reddit.pushshift \
my.reddit.rexport \
my.rescuetime \
my.runnerup \
my.smscalls \
my.stackexchange.stexport \
my.time.tz.via_location
{envpython} -m mypy --no-install-types \
-p {[testenv]package_name} \
--txt-report .coverage.mypy-misc \
--html-report .coverage.mypy-misc \
{posargs}
{envpython} -m mypy --no-install-types \
tests
# note: this comment doesn't seem relevant anymore, but keeping it in case the issue happens again
# > ugh ... need to reset HOME, otherwise user's site-packages are somehow leaking into mypy's path...
# > see https://github.com/python/mypy/blob/f6fb60ef69738cbfe2dfe56c747eca8f03735d8e/mypy/modulefinder.py#L487
# > this is particularly annoying when user's config is leaking and mypy isn't running against the repository config
# useful flags:
# * sitepackages = true to inherit user/globally installed packages (default false)
# * skip_install = true -- not sure when useful? (default false)
# * -e to run specific subenvironment
# * pass arguments with -- , e.g. `tox -e tests -- -k some_test_name` to only run one test with pytest