From 1b47cc1ba92c38c8ed346b2f98bab7fc929e2c71 Mon Sep 17 00:00:00 2001 From: Remco de Boer <29308176+redeboer@users.noreply.github.com> Date: Wed, 8 Jan 2025 22:51:29 +0100 Subject: [PATCH] DX: convert Tox config to native TOML --- .cspell.json | 1 + .taplo.toml | 7 ++ pyproject.toml | 206 +++++++++++++++++++++++++------------------------ 3 files changed, 112 insertions(+), 102 deletions(-) diff --git a/.cspell.json b/.cspell.json index f6b76dc..a4079b0 100644 --- a/.cspell.json +++ b/.cspell.json @@ -26,6 +26,7 @@ ".gitignore", ".pre-commit-config.yaml", ".prettierignore", + ".taplo.toml", ".vscode/*", "codecov.yml", "docs/conf.py", diff --git a/.taplo.toml b/.taplo.toml index 0db1df7..71fcb1b 100644 --- a/.taplo.toml +++ b/.taplo.toml @@ -10,3 +10,10 @@ compact_inline_tables = true indent_string = " " reorder_arrays = true reorder_keys = true + +[[rule]] +include = ["**/pyproject.toml"] +keys = ["tool.tox"] + +[rule.formatting] +reorder_arrays = false diff --git a/pyproject.toml b/pyproject.toml index e179bbe..1f07d86 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -335,110 +335,112 @@ sort_first = [ "project", "tool.setuptools", "tool.setuptools_scm", + "tool.tox.env_run_base", ] spaces_indent_inline_array = 4 trailing_comma_inline_array = true [tool.tox] -legacy_tox_ini = """ -[tox] -skip_install = True -skip_missing_interpreters=true -skipsdist = True -envlist = - cov, - docnb-force, - linkcheck, - sty, - -[testenv] -allowlist_externals = - pytest -commands = - pytest {posargs:tests} -description = Run all fast unit tests -passenv = * - -[testenv:cov] -allowlist_externals = - pytest -commands = - pytest {posargs:tests} \ - --cov-fail-under=85 \ - --cov-report=html \ - --cov-report=xml \ - --cov=boostcfg \ - --cov=pawian -description = Compute the test coverage of all unit tests - -[testenv:doc] -allowlist_externals = - sphinx-build -commands = - sphinx-build \ - --builder=html \ - --fail-on-warning \ - --keep-going \ - --show-traceback \ - docs/ docs/_build/html -description = Build documentation and API through Sphinx -passenv = * - -[testenv:docnb] -base = doc -description = {[testenv:doc]description} with cached notebook execution -setenv = - EXECUTE_NB = - -[testenv:docnb-force] -base = doc -description = {[testenv:doc]description} with notebook execution (no cache) -setenv = - FORCE_EXECUTE_NB = yes - -[testenv:doclive] -allowlist_externals = - sphinx-autobuild -commands = - sphinx-autobuild \ - --ignore=docs/_build \ - --ignore=docs/api \ - --open-browser \ - --port=0 \ - --re-ignore docs/.*\\.inv \ - --watch=docs \ - --watch=src \ - docs/ docs/_build/html -description = Set up a server to preview changes to the HTML pages live -passenv = * - -[testenv:docnblive] -base = doclive -description = {[testenv:doclive]description} with cached notebook execution -setenv = - EXECUTE_NB = yes - -[testenv:linkcheck] -allowlist_externals = - sphinx-build -commands = - sphinx-build \ - --builder=linkcheck \ - --show-traceback \ - docs/ docs/_build/linkcheck -description = Check external links in the documentation (requires internet connection) - -[testenv:nb] -allowlist_externals = - pytest -commands = - pytest --nbmake {posargs:docs} -description = Run all notebooks with pytest - -[testenv:sty] -allowlist_externals = - pre-commit -commands = - pre-commit run --all-files {posargs} -description = Perform all linting, formatting, and spelling checks -""" +env_list = [ + "cov", + "docnb-force", + "linkcheck", + "sty", +] +no_package = true +requires = ["tox>=4.21.0"] +skip_install = true +skip_missing_interpreters = true + +[tool.tox.env_run_base] +allowlist_externals = ["pytest"] +commands = [["pytest", {replace = "posargs", extend = true}]] +description = "Run all fast unit tests" +pass_env = ["*"] + +[tool.tox.env.cov] +allowlist_externals = ["pytest"] +commands = [ + [ + "pytest", + {replace = "posargs", extend = true}, + "--cov-fail-under=85", + "--cov-report=html", + "--cov-report=xml", + "--cov=boostcfg", + "--cov=pawian", + ], +] +description = "Compute the test coverage of all unit tests" + +[tool.tox.env.doc] +allowlist_externals = ["sphinx-build"] +commands = [ + [ + "sphinx-build", + "--builder=html", + "--fail-on-warning", + "--keep-going", + "--show-traceback", + "docs/", + "docs/_build/html", + ], +] +description = "Build documentation and API through Sphinx" + +[tool.tox.env.doclive] +allowlist_externals = ["sphinx-autobuild"] +commands = [ + [ + "sphinx-autobuild", + "--ignore=docs/_build", + "--ignore=docs/api", + "--open-browser", + "--port=0", + "--re-ignore", + "docs/.*\\.inv", + "--watch=docs", + "--watch=src", + "docs/", + "docs/_build/html", + ], +] +description = "Set up a server to preview changes to the HTML pages live" + +[tool.tox.env.docnb] +base = ["tool.tox.env.doc", "tool.tox.env_run_base"] +description = "{[tool.tox.env.doc]description} with cached notebook execution" +set_env.EXECUTE_NB = "" + +[tool.tox.env.docnb-force] +base = ["tool.tox.env.doc", "tool.tox.env_run_base"] +description = "{[tool.tox.env.doc]description} with notebook execution (no cache)" +set_env.FORCE_EXECUTE_NB = "yes" + +[tool.tox.env.docnblive] +base = ["tool.tox.env.doclive", "tool.tox.env_run_base"] +description = "{[tool.tox.env.doclive]description} with cached notebook execution" +set_env.EXECUTE_NB = "yes" + +[tool.tox.env.linkcheck] +allowlist_externals = ["sphinx-build"] +commands = [ + [ + "sphinx-build", + "--builder=linkcheck", + "--show-traceback", + "docs/", + "docs/_build/linkcheck", + ], +] +description = "Check external links in the documentation (requires internet connection)" + +[tool.tox.env.nb] +allowlist_externals = ["pytest"] +commands = [["pytest", "--nbmake", "{posargs:docs}"]] +description = "Run all notebooks with pytest" + +[tool.tox.env.sty] +allowlist_externals = ["pre-commit"] +commands = [["pre-commit", "run", "--all-files", {replace = "posargs", extend = true}]] +description = "Perform all linting, formatting, and spelling checks"