110 lines
3.7 KiB
INI
110 lines
3.7 KiB
INI
[tox]
|
|
isolated_build = true
|
|
# Version 4.22 is the first one to implement support for dependency groups:
|
|
minversion = 4.22
|
|
|
|
|
|
[python-cli-options]
|
|
byte-warnings = -b
|
|
byte-errors = -bb
|
|
max-isolation = -E -s -I
|
|
some-isolation = -E -s
|
|
warnings-to-errors = -Werror
|
|
|
|
|
|
[testenv]
|
|
description = Run pytest under {envpython}
|
|
dependency_groups =
|
|
testing
|
|
commands =
|
|
{envpython} \
|
|
{[python-cli-options]byte-errors} \
|
|
{[python-cli-options]max-isolation} \
|
|
{[python-cli-options]warnings-to-errors} \
|
|
-W 'ignore:Coverage failure::pytest_cov.plugin' \
|
|
-m pytest \
|
|
{tty:--color=yes} \
|
|
{posargs:--cov-report=html:{envtmpdir}{/}htmlcov{/}}
|
|
commands_post =
|
|
-{envpython} \
|
|
{[python-cli-options]byte-errors} \
|
|
{[python-cli-options]max-isolation} \
|
|
{[python-cli-options]warnings-to-errors} \
|
|
-c \
|
|
'import atexit, os, sys; \
|
|
os.getenv("GITHUB_ACTIONS") == "true" or sys.exit(); \
|
|
import coverage; \
|
|
gh_summary_fd = open(\
|
|
os.environ["GITHUB_STEP_SUMMARY"], encoding="utf-8", mode="a",\
|
|
); \
|
|
atexit.register(gh_summary_fd.close); \
|
|
cov = coverage.Coverage(); \
|
|
cov.load(); \
|
|
cov.report(file=gh_summary_fd, output_format="markdown")'
|
|
{envpython} \
|
|
{[python-cli-options]byte-errors} \
|
|
{[python-cli-options]max-isolation} \
|
|
{[python-cli-options]warnings-to-errors} \
|
|
-c \
|
|
'import os, pathlib, sys; \
|
|
os.getenv("GITHUB_ACTIONS") == "true" or sys.exit(); \
|
|
cov_report_arg_prefix = "--cov-report=xml:"; \
|
|
test_report_arg_prefix = "--junitxml="; \
|
|
cov_reports = [\
|
|
arg[len(cov_report_arg_prefix):] for arg in sys.argv \
|
|
if arg.startswith(cov_report_arg_prefix)\
|
|
]; \
|
|
test_reports = [\
|
|
arg[len(test_report_arg_prefix):] for arg in sys.argv \
|
|
if arg.startswith(test_report_arg_prefix)\
|
|
]; \
|
|
cov_report_file = cov_reports[-1] if cov_reports else None; \
|
|
test_report_file = test_reports[-1] if test_reports else None; \
|
|
gh_output_fd = open(\
|
|
os.environ["GITHUB_OUTPUT"], encoding="utf-8", mode="a",\
|
|
); \
|
|
cov_report_file and \
|
|
print(f"cov-report-files={cov_report_file !s}", file=gh_output_fd); \
|
|
test_report_file and \
|
|
print(f"test-result-files={test_report_file !s}", file=gh_output_fd); \
|
|
print("codecov-flags=pytest", file=gh_output_fd); \
|
|
gh_output_fd.close()' \
|
|
{posargs}
|
|
# Print out the output coverage dir and a way to serve html:
|
|
{envpython} \
|
|
{[python-cli-options]byte-errors} \
|
|
{[python-cli-options]max-isolation} \
|
|
{[python-cli-options]warnings-to-errors} \
|
|
-c\
|
|
'import pathlib, shlex, sys; \
|
|
cov_html_report_arg_prefix = "--cov-report=html:"; \
|
|
cov_html_reports = [\
|
|
arg[len(cov_html_report_arg_prefix):] for arg in sys.argv \
|
|
if arg.startswith(cov_html_report_arg_prefix)\
|
|
]; \
|
|
cov_html_reports or sys.exit(); \
|
|
cov_html_report_dir = pathlib.Path(cov_html_reports[-1]); \
|
|
index_file = cov_html_report_dir / "index.html";\
|
|
index_file.exists() or sys.exit(); \
|
|
html_url = f"file://\{index_file\}";\
|
|
browse_cmd = shlex.join(("python3", "-Im", "webbrowser", html_url)); \
|
|
serve_cmd = shlex.join((\
|
|
"python3", "-Im", "http.server", \
|
|
"--directory", str(cov_html_report_dir), "0", \
|
|
)); \
|
|
print(f"\nTo open the HTML coverage report, run\n\n\
|
|
\t\{browse_cmd !s\}\n");\
|
|
print(f"To serve \
|
|
the HTML coverage report with a local web server, use\n\n\
|
|
\t\{serve_cmd !s\}\n")' \
|
|
{posargs:--cov-report=html:{envtmpdir}{/}htmlcov{/}}
|
|
package = skip
|
|
pass_env =
|
|
CI
|
|
GITHUB_*
|
|
SSH_AUTH_SOCK
|
|
TERM
|
|
set_env =
|
|
COVERAGE_PROCESS_START = {toxinidir}{/}.coveragerc
|
|
wheel_build_env = .pkg
|