From 08c0539651981bf54cb99f39ed3e491df0148d62 Mon Sep 17 00:00:00 2001 From: Chris Markiewicz Date: Tue, 16 Jul 2024 13:52:36 -0400 Subject: [PATCH] TOX: Add tox config --- pyproject.toml | 28 +++++++++++-- tox.ini | 110 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 135 insertions(+), 3 deletions(-) create mode 100644 tox.ini diff --git a/pyproject.toml b/pyproject.toml index 80412448..8efb7041 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -75,7 +75,7 @@ telemetry = [ "sentry-sdk >= 1.3", ] test = [ - "coverage", + "coverage[toml]", "pytest", "pytest-cov", "pytest-env", @@ -127,11 +127,21 @@ exclude = ".*" [tool.pytest.ini_options] minversion = "6" -testpaths = ["fmriprep/tests"] +testpaths = ["fmriprep"] log_cli_level = "INFO" xfail_strict = true norecursedirs = [".git"] -addopts = ["-svx", "-ra", "--strict-config", "--strict-markers", "--doctest-modules"] +addopts = [ + "-svx", + "-ra", + "--strict-config", + "--strict-markers", + "--doctest-modules", + # Config pytest-cov + "--cov=fmriprep", + "--cov-report=xml", + "--cov-config=pyproject.toml", +] doctest_optionflags = "ALLOW_UNICODE NORMALIZE_WHITESPACE ELLIPSIS" env = "PYTHONHASHSEED=0" filterwarnings = ["ignore::DeprecationWarning"] @@ -181,3 +191,15 @@ inline-quotes = "single" [tool.ruff.format] quote-style = "single" + +[tool.coverage.run] +branch = true +omit = [ + "*/_version.py" +] + +[tool.coverage.paths] +source = [ + "fmriprep", + "**/site-packages/fmriprep" +] diff --git a/tox.ini b/tox.ini new file mode 100644 index 00000000..a09cd588 --- /dev/null +++ b/tox.ini @@ -0,0 +1,110 @@ +[tox] +requires = + tox>=4 +envlist = + py3{10,11,12} + py310-min + py3{10,11,12}-pre +skip_missing_interpreters = true + +# Configuration that allows us to split tests across GitHub runners effectively +[gh-actions] +python = + 3.10: py310 + 3.11: py311 + 3.12: py312 + +[gh-actions:env] +DEPENDS = + min: min + pre: pre + +[testenv] +description = Pytest with coverage +labels = test +pip_pre = + pre: true +pass_env = + # getpass.getuser() sources for Windows: + LOGNAME + USER + LNAME + USERNAME + # Pass user color preferences through + PY_COLORS + FORCE_COLOR + NO_COLOR + CLICOLOR + CLICOLOR_FORCE + PYTHON_GIL +extras = test +setenv = + pre: PIP_EXTRA_INDEX_URL=https://pypi.anaconda.org/scientific-python-nightly-wheels/simple +deps = + min: nibabel == 4.0.1 + min: nipype == 1.8.5 + min: nitransforms == 21.0.0 + min: numpy == 1.22 + min: psutil == 5.4 + min: pybids == 0.15.2 + min: tedana == 23.0.2 + min: templateflow == 24.1.0 + +commands = + pytest --cov-report term-missing --durations=20 --durations-min=1.0 {posargs} + +[testenv:style] +description = Check our style guide +labels = check +deps = + ruff +skip_install = true +commands = + ruff check --diff + ruff format --diff + +[testenv:style-fix] +description = Auto-apply style guide to the extent possible +labels = pre-release +deps = + ruff +skip_install = true +commands = + ruff check --fix + ruff format + ruff check --select ISC001 + +[testenv:spellcheck] +description = Check spelling +labels = check +deps = + codespell[toml] +skip_install = true +commands = + codespell . {posargs} + +[testenv:build{,-strict}] +labels = + check + pre-release +deps = + build + twine +skip_install = true +set_env = + # Ignore specific known warnings: + # https://github.com/pypa/pip/issues/11684 + # https://github.com/pypa/pip/issues/12243 + strict: PYTHONWARNINGS=error,once:pkg_resources is deprecated as an API.:DeprecationWarning:pip._internal.metadata.importlib._envs,once:Unimplemented abstract methods {'locate_file'}:DeprecationWarning:pip._internal.metadata.importlib._dists +commands = + python -m build + python -m twine check dist/* + +[testenv:publish] +depends = build +labels = release +deps = + twine +skip_install = true +commands = + python -m twine upload dist/*