187 lines
6.6 KiB
INI
187 lines
6.6 KiB
INI
[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
|
|
|
|
|
|
# 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 my/
|
|
|
|
|
|
# just the very core tests with minimal dependencies
|
|
[testenv:tests-core]
|
|
commands =
|
|
{envpython} -m pip install --use-pep517 -e .[testing]
|
|
|
|
# seems that denylist tests rely on it? ideally we should get rid of this in tests-core
|
|
{envpython} -m pip install orjson
|
|
|
|
{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 my.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 \
|
|
# causes error during test collection on 3.8
|
|
# dataset is deprecated anyway so whatever
|
|
--ignore my/core/dataset.py \
|
|
# this test uses orjson which is an optional dependency
|
|
# it would be covered by tests-all
|
|
-k 'not test_nt_serialize' \
|
|
{posargs}
|
|
|
|
|
|
# todo maybe also have core tests and misc tests? since ideally want them without dependencies
|
|
[testenv:tests-all]
|
|
# deliberately set to nonexistent path to check the fallback logic
|
|
# TODO not sure if need it?
|
|
setenv = MY_CONFIG = nonexistent
|
|
commands =
|
|
{envpython} -m pip install --use-pep517 -e .[testing]
|
|
|
|
# installed to test my.core.serialize while using simplejson and not orjson
|
|
{envpython} -m pip install simplejson
|
|
{envpython} -m pytest \
|
|
tests/serialize_simplejson.py \
|
|
{posargs}
|
|
|
|
{envpython} -m pip install cachew
|
|
{envpython} -m pip install orjson
|
|
|
|
{envpython} -m my.core module install my.location.google
|
|
{envpython} -m pip install ijson # optional dependency
|
|
|
|
# tz/location
|
|
{envpython} -m my.core module install my.time.tz.via_location
|
|
{envpython} -m my.core module install my.ip.all
|
|
{envpython} -m my.core module install my.location.gpslogger
|
|
{envpython} -m my.core module install my.location.fallback.via_ip
|
|
{envpython} -m my.core module install my.google.takeout.parser
|
|
|
|
{envpython} -m my.core module install my.calendar.holidays
|
|
|
|
# my.body.weight dep
|
|
{envpython} -m my.core module install my.orgmode
|
|
|
|
{envpython} -m my.core module install my.coding.commits
|
|
|
|
{envpython} -m my.core module install my.pdfs
|
|
|
|
{envpython} -m my.core module install 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}.tests \
|
|
{posargs}
|
|
|
|
{envpython} -m pytest tests \
|
|
# ignore some tests which might take a while to run on ci..
|
|
--ignore tests/takeout.py \
|
|
--ignore tests/extra/polar.py \
|
|
# dont run simplejson compatibility test since orjson is now installed
|
|
--ignore tests/serialize_simplejson.py \
|
|
{posargs}
|
|
|
|
|
|
[testenv:demo]
|
|
commands =
|
|
{envpython} -m pip install git+https://github.com/karlicoss/hypexport
|
|
{envpython} ./demo.py
|
|
|
|
|
|
[testenv:mypy-core]
|
|
commands =
|
|
{envpython} -m pip install --use-pep517 -e .[testing,optional]
|
|
{envpython} -m pip install orgparse # used it core.orgmode?
|
|
{envpython} -m pip install gpxpy # for hpi query --output gpx
|
|
|
|
{envpython} -m mypy --install-types --non-interactive \
|
|
-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]
|
|
commands =
|
|
{envpython} -m pip install --use-pep517 -e .[testing,optional]
|
|
|
|
{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 --install-types --non-interactive \
|
|
-p {[testenv]package_name} \
|
|
--txt-report .coverage.mypy-misc \
|
|
--html-report .coverage.mypy-misc \
|
|
{posargs}
|
|
|
|
{envpython} -m mypy --install-types --non-interactive \
|
|
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
|