From 9aa5b23d8bdcd0ab049ccb692e0b585b70098c38 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Francis=20Clairicia-Rose-Claire-Jos=C3=A9phine?= Date: Thu, 25 Apr 2024 08:10:59 +0200 Subject: [PATCH] tox: Configuration update (#277) --- .pre-commit-config.yaml | 39 +++------------------------------- tox.ini | 46 +++++++++++++++++++++++++---------------- 2 files changed, 31 insertions(+), 54 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 24f9361f..eeffa9ee 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -16,42 +16,9 @@ repos: - repo: local hooks: - id: mypy - name: mypy (project) - entry: tox run -q -r -e mypy-full - language: system - files: ^(src/) - types_or: [python, pyi] - require_serial: true - pass_filenames: false - - id: mypy - name: mypy (tests) - files: ^((src|tests)/) - entry: tox run -q -r -e mypy-test - language: system - types_or: [python, pyi] - require_serial: true - pass_filenames: false - - id: mypy - name: mypy (docs) - files: ^((src|docs/source)/) - exclude: ^(docs/source/conf.py)$ - entry: tox run -q -r -e mypy-docs - language: system - types_or: [python, pyi] - require_serial: true - pass_filenames: false - - id: mypy - name: mypy (benchmark/servers) - files: ^((src|benchmark_server)/) - entry: tox run -q -e mypy-benchmark_server - language: system - types_or: [python, pyi] - require_serial: true - pass_filenames: false - - id: mypy - name: mypy (benchmark/micro-benchs) - files: ^((src|micro_benchmarks)/) - entry: tox run -q -e mypy-micro_benchmarks + name: mypy + files: ^((src|tests|docs/source|benchmark_server|micro_benchmarks)/) + entry: tox run -q -f mypy language: system types_or: [python, pyi] require_serial: true diff --git a/tox.ini b/tox.ini index c5e3d231..3295ab64 100644 --- a/tox.ini +++ b/tox.ini @@ -18,6 +18,7 @@ envlist = skip_missing_interpreters = true [base] +wheel_build_env = {package_env} setenv = PYTHONUNBUFFERED = 1 PDM_CHECK_UPDATE = False @@ -28,7 +29,7 @@ source_dir = {[docs]root_dir}{/}source extensions_dir = {[docs]source_dir}{/}_extensions examples_dir = {[docs]source_dir}{/}_include{/}examples -[base-pytest] +[pytest-conf] setenv = # TODO: setenv substitution does not work for PYTHONHASHSEED (https://github.com/tox-dev/tox/issues/2872) # PYTHONHASHSEED = 100 @@ -41,15 +42,16 @@ cov_opts = --cov --cov-report='' [testenv:py311-other-{tests,docstrings}] package = wheel +wheel_build_env = {[base]wheel_build_env} platform = docstrings: linux groups = test setenv = {[base]setenv} - {[base-pytest]setenv} + {[pytest-conf]setenv} PYTHONHASHSEED = 0 - PYTEST_ADDOPTS = {[base-pytest]addopts} --no-cov + PYTEST_ADDOPTS = {[pytest-conf]addopts} --no-cov commands = tests: pytest -m "not unit and not functional" {posargs} docstrings: pytest --doctest-modules {posargs} {toxinidir}{/}src @@ -58,6 +60,7 @@ commands = [testenv:{py311,py312}-{unit,functional}-{__standard__,cbor,msgpack}] package = wheel +wheel_build_env = {[base]wheel_build_env} groups = test coverage @@ -65,39 +68,41 @@ groups = msgpack: msgpack setenv = {[base]setenv} - {[base-pytest]setenv} + {[pytest-conf]setenv} PYTHONHASHSEED = 100 - PYTEST_ADDOPTS = {[base-pytest]addopts} {[base-pytest]cov_opts} + PYTEST_ADDOPTS = {[pytest-conf]addopts} {[pytest-conf]cov_opts} COVERAGE_FILE = .coverage.{envname} !py311: COVERAGE_CORE=sysmon - unit: TESTS_ROOTDIR = {[base-pytest]unit_tests_rootdir} - functional: TESTS_ROOTDIR = {[base-pytest]functional_tests_rootdir} + unit: TESTS_ROOTDIR = {[pytest-conf]unit_tests_rootdir} + functional: TESTS_ROOTDIR = {[pytest-conf]functional_tests_rootdir} passenv = PYTEST_MAX_WORKERS commands = - __standard__: pytest -n "{env:PYTEST_MAX_WORKERS:auto}" --dist={[base-pytest]xdist_dist} -m "not feature" {posargs} {env:TESTS_ROOTDIR} + __standard__: pytest -n "{env:PYTEST_MAX_WORKERS:auto}" --dist={[pytest-conf]xdist_dist} -m "not feature" {posargs} {env:TESTS_ROOTDIR} cbor: pytest -m "feature_cbor" {posargs} {env:TESTS_ROOTDIR} msgpack: pytest -m "feature_msgpack" {posargs} {env:TESTS_ROOTDIR} [testenv:{py311,py312}-functional-sniffio] package = wheel +wheel_build_env = {[base]wheel_build_env} groups = test coverage sniffio setenv = {[base]setenv} - {[base-pytest]setenv} + {[pytest-conf]setenv} PYTHONHASHSEED = 100 - PYTEST_ADDOPTS = {[base-pytest]addopts} {[base-pytest]cov_opts} + PYTEST_ADDOPTS = {[pytest-conf]addopts} {[pytest-conf]cov_opts} COVERAGE_FILE = .coverage.{envname} !py311: COVERAGE_CORE=sysmon - TESTS_ROOTDIR = {[base-pytest]functional_tests_rootdir} + TESTS_ROOTDIR = {[pytest-conf]functional_tests_rootdir} commands = pytest -m "feature_sniffio" {posargs} {env:TESTS_ROOTDIR} [testenv:{py311,py312}-functional-{asyncio_proactor,uvloop}] package = wheel +wheel_build_env = {[base]wheel_build_env} platform = asyncio_proactor: win32 uvloop: linux|darwin @@ -107,21 +112,21 @@ groups = uvloop: uvloop setenv = {[base]setenv} - {[base-pytest]setenv} + {[pytest-conf]setenv} PYTHONHASHSEED = 100 - PYTEST_ADDOPTS = {[base-pytest]addopts} {[base-pytest]cov_opts} + PYTEST_ADDOPTS = {[pytest-conf]addopts} {[pytest-conf]cov_opts} COVERAGE_FILE = .coverage.{envname} !py311: COVERAGE_CORE=sysmon - TESTS_ROOTDIR = {[base-pytest]functional_tests_rootdir} + TESTS_ROOTDIR = {[pytest-conf]functional_tests_rootdir} asyncio_proactor: ASYNCIO_EVENTLOOP = asyncio-proactor uvloop: ASYNCIO_EVENTLOOP = uvloop passenv = PYTEST_MAX_WORKERS commands = - pytest -n "{env:PYTEST_MAX_WORKERS:auto}" --dist={[base-pytest]xdist_dist} --asyncio-event-loop="{env:ASYNCIO_EVENTLOOP}" -m "asyncio and not feature" {posargs} {env:TESTS_ROOTDIR} + pytest -n "{env:PYTEST_MAX_WORKERS:auto}" --dist={[pytest-conf]xdist_dist} --asyncio-event-loop="{env:ASYNCIO_EVENTLOOP}" -m "asyncio and not feature" {posargs} {env:TESTS_ROOTDIR} [testenv:coverage] -skip_install = True +skip_install = true depends = {py311,py312}-{unit,functional}-{__standard__,cbor,msgpack} {py311,py312}-functional-{sniffio,asyncio_proactor,uvloop} @@ -150,6 +155,7 @@ commands = [testenv:mypy-{full,test,docs,benchmark_server,micro_benchmarks}] package = wheel +wheel_build_env = {[base]wheel_build_env} platform = benchmark_server: linux groups = @@ -191,6 +197,7 @@ commands = [testenv:pre-commit] skip_install = true +ignore_outcome = true # Only trigger a warning on failure. groups = pre-commit setenv = @@ -204,15 +211,16 @@ commands = [testenv:benchmark-micro] package = wheel +wheel_build_env = {[base]wheel_build_env} groups = micro-benchmarks cbor msgpack setenv = {[base]setenv} - {[base-pytest]setenv} + {[pytest-conf]setenv} PYTHONHASHSEED = 0 - PYTEST_ADDOPTS = {[base-pytest]addopts} + PYTEST_ADDOPTS = {[pytest-conf]addopts} commands = pytest -c pytest-benchmark.ini {posargs:--benchmark-histogram=benchmark_reports{/}benchmark} @@ -222,6 +230,8 @@ groups = benchmark-servers setenv = {[base]setenv} + + # Python version BENCHMARK_PYTHON_VERSION = {env:BENCHMARK_PYTHON_VERSION:3.11} # Image tag