Skip to content

Commit

Permalink
tox: Configuration update (#277)
Browse files Browse the repository at this point in the history
  • Loading branch information
francis-clairicia authored Apr 25, 2024
1 parent 79588f1 commit 9aa5b23
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 54 deletions.
39 changes: 3 additions & 36 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
46 changes: 28 additions & 18 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ envlist =
skip_missing_interpreters = true

[base]
wheel_build_env = {package_env}
setenv =
PYTHONUNBUFFERED = 1
PDM_CHECK_UPDATE = False
Expand All @@ -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
Expand All @@ -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
Expand All @@ -58,46 +60,49 @@ commands =

[testenv:{py311,py312}-{unit,functional}-{__standard__,cbor,msgpack}]
package = wheel
wheel_build_env = {[base]wheel_build_env}
groups =
test
coverage
cbor: cbor
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
Expand All @@ -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}
Expand Down Expand Up @@ -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 =
Expand Down Expand Up @@ -191,6 +197,7 @@ commands =

[testenv:pre-commit]
skip_install = true
ignore_outcome = true # Only trigger a warning on failure.
groups =
pre-commit
setenv =
Expand All @@ -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}

Expand All @@ -222,6 +230,8 @@ groups =
benchmark-servers
setenv =
{[base]setenv}

# Python version
BENCHMARK_PYTHON_VERSION = {env:BENCHMARK_PYTHON_VERSION:3.11}

# Image tag
Expand Down

0 comments on commit 9aa5b23

Please sign in to comment.