From 087d867cecc07cf96a47f33c3cd2f02fd2d2a8fc Mon Sep 17 00:00:00 2001 From: Chris Markiewicz Date: Fri, 13 Dec 2024 21:01:34 -0500 Subject: [PATCH] chore: Add tox.ini, update pytest config --- pyproject.toml | 17 ++++++- tox.ini | 127 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 142 insertions(+), 2 deletions(-) create mode 100644 tox.ini diff --git a/pyproject.toml b/pyproject.toml index d940ed1654..7d32087383 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -150,8 +150,22 @@ per-file-ignores = [ ] [tool.pytest.ini_options] +minversion = "6" +testpaths = ["sdcflows"] +log_cli_level = "INFO" +xfail_strict = true norecursedirs = [".git"] -addopts = "-svx --doctest-modules --strict-markers" +addopts = [ + "-svx", + "-ra", + "--strict-config", + "--strict-markers", + "--doctest-modules", + # Config pytest-cov + "--cov=sdcflows", + "--cov-report=xml", + "--cov-config=pyproject.toml", +] doctest_optionflags = "ALLOW_UNICODE NORMALIZE_WHITESPACE ELLIPSIS" env = "PYTHONHASHSEED=0" filterwarnings = ["ignore::DeprecationWarning"] @@ -164,7 +178,6 @@ markers = [ [tool.coverage.run] branch = true -concurrency = 'multiprocessing' omit = [ '*/tests/*', '*/__init__.py', diff --git a/tox.ini b/tox.ini new file mode 100644 index 0000000000..a5376611f7 --- /dev/null +++ b/tox.ini @@ -0,0 +1,127 @@ +[tox] +requires = + tox>=4 + tox-uv +envlist = + py3{9,10,11,12,13}-latest + py39-min + py3{11,12,13}-pre + style + spellcheck +skip_missing_interpreters = true + +# Configuration that allows us to split tests across GitHub runners effectively +[gh-actions] +python = + 3.9: py39 + 3.10: py310 + 3.11: py311 + 3.12: py312 + 3.13: py313 + +[gh-actions:env] +DEPENDS = + min: min + latest: latest + pre: pre + +[testenv] +description = Pytest with coverage +labels = test +pip_pre = + pre: true +pass_env = + TEMPLATEFLOW_HOME + # Freesurfer variables searched for + FREESURFER_HOME + SUBJECTS_DIR + FS_LICENSE + # CI variables + TEST_DATA_HOME + TEST_OUTPUT_DIR + TEST_WORK_DIR + FMRIPREP_REGRESSION_SOURCE + CACHED_WORK_DIRECTORY + # CircleCI-specific + CIRCLE_NPROCS + SAVE_CIRCLE_ARTIFACTS + # 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 +deps = + # Waiting on a release + py313: traits @ git+https://github.com/enthought/traits.git@10954eb +extras = tests +setenv = + pre: PIP_EXTRA_INDEX_URL=https://pypi.anaconda.org/scientific-python-nightly-wheels/simple + pre: UV_EXTRA_INDEX_URL=https://pypi.anaconda.org/scientific-python-nightly-wheels/simple +uv_resolution = + min: lowest-direct + +commands = + pytest --durations=20 --durations-min=1.0 --cov-report term-missing {posargs:-n auto} + +[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/*