Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

maintain: Convert tox conf to native TOML #459

Merged
merged 2 commits into from
Oct 22, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
149 changes: 81 additions & 68 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -60,77 +60,90 @@ xfail_strict = true


[tool.tox]
legacy_tox_ini = '''
[tox]
requires = ["tox>=4.21.1"]
# Only run pytest envs when no args given to tox
envlist = py{39,310,311,312,313}
isolated_build = True

[testenv:py{39,310,311,312,313}]
description = run tests
deps =
-r tests/requirements.txt
commands =
pytest {posargs:--cov}

[testenv:profile]
description = run profiler (use e.g. `firefox .tox/prof/combined.svg` to open)
deps =
-r tests/requirements.txt
pytest-profiling
commands =
pytest tests/test_for_profiler.py --profile-svg --pstats-dir "{toxworkdir}/prof"
python -c 'import pathlib; print("profiler svg output under file://\{0\}".format(pathlib.Path(r"{toxworkdir}") / "prof" / "combined.svg"))'

[testenv:pre-commit]
description = run linters (except mypy)
skip_install = True
deps = pre-commit
commands = pre-commit run {posargs:--all}

[testenv:mypy]
description = run mypy
basepython = python3.11
deps =
-r tests/requirements.txt
mypy==1.11.2
commands =
mypy {posargs:src/ tests/}

[testenv:hook]
description = test mdformat's own pre-commit hook against the README file
skip_install = True
deps = pre-commit
commands =
pre-commit try-repo . mdformat --files README.md

[testenv:cli]
description = run mdformat's own CLI
commands = mdformat {posargs}

[testenv:docs]
description = invoke sphinx-build to build the HTML docs
skip_install = True
deps =
-r docs/requirements.txt
commands =
sphinx-build -d "{toxworkdir}/docs_doctree" docs/ "{toxworkdir}/docs_out" -W -b html {posargs}
python -c 'import pathlib; print("documentation available under file://\{0\}".format(pathlib.Path(r"{toxworkdir}") / "docs_out" / "index.html"))'

[testenv:fuzz]
description = run the fuzzer (needs "apt install clang")
deps =
-r fuzzer/requirements.txt
allowlist_externals =
mkdir
cp
commands =
env_list = ["3.9", "3.10", "3.11", "3.12", "3.13"]

[tool.tox.env_run_base]
description = "run tests under {base_python}"
deps = [
"-r tests/requirements.txt",
]
commands = [
["pytest", { replace = "posargs", default = ["--cov"], extend = true }],
]

[tool.tox.env."profile"]
description = "run profiler (use e.g. `firefox .tox/prof/combined.svg` to open)"
deps = [
"-r tests/requirements.txt",
"pytest-profiling",
]
commands = [
["pytest", "tests/test_for_profiler.py", "--profile-svg", "--pstats-dir", "{toxworkdir}/prof"],
["python", "-c", 'import pathlib; print("profiler svg output under file://\{0\}".format(pathlib.Path(r"{toxworkdir}") / "prof" / "combined.svg"))'],
]

[tool.tox.env."pre-commit"]
description = "run linters (except mypy)"
skip_install = true
deps = ["pre-commit"]
commands = [
["pre-commit", "run", { replace = "posargs", default = ["--all"], extend = true }],
]

[tool.tox.env."mypy"]
description = "run mypy"
basepython = ["python3.11"]
deps = [
"-r tests/requirements.txt",
"mypy==1.11.2",
]
commands = [
["mypy", { replace = "posargs", default = ["src/", "tests/"], extend = true }],
]

[tool.tox.env."hook"]
description = "test mdformat's own pre-commit hook against the README file"
skip_install = true
deps = ["pre-commit"]
commands = [
["pre-commit", "try-repo", ".", "mdformat", "--files", "README.md"],
]

[tool.tox.env."cli"]
description = "run mdformat's own CLI"
commands = [
["mdformat", { replace = "posargs", extend = true }],
]

[tool.tox.env."docs"]
description = "invoke sphinx-build to build the HTML docs"
skip_install = true
deps = [
"-r docs/requirements.txt",
]
commands = [
["sphinx-build", "-d", "{toxworkdir}/docs_doctree", "docs/", "{toxworkdir}/docs_out", "-W", "-b", "html", { replace = "posargs", extend = true }],
["python", "-c", 'import pathlib; print("documentation available under file://\{0\}".format(pathlib.Path(r"{toxworkdir}") / "docs_out" / "index.html"))'],
]

[tool.tox.env."fuzz"]
description = 'run the fuzzer (needs "apt install clang")'
deps = [
"-r fuzzer/requirements.txt",
]
allowlist_externals = [
"mkdir",
"cp",
]
commands = [
# Create a folder for persistent corpus and use README.md as initial seed
mkdir -p {toxworkdir}/fuzzer-corpus
cp -n README.md {toxworkdir}/fuzzer-corpus/README.md
["mkdir", "-p", "{toxworkdir}/fuzzer-corpus"],
["cp", "-n", "README.md", "{toxworkdir}/fuzzer-corpus/README.md"],
# Run fuzzer
python fuzzer/fuzz.py {toxworkdir}/fuzzer-corpus {posargs:-len_control=10000}
'''
["python", "fuzzer/fuzz.py", "{toxworkdir}/fuzzer-corpus", { replace = "posargs", default = ["-len_control=10000"], extend = true }],
]


[tool.coverage.run]
Expand Down