Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
8bc2adf
add option to generate test coverage report without codecov
Jun 9, 2024
91f4170
update step name
Jun 10, 2024
b297ce4
update matrix script
zacharyburnett Jun 10, 2024
32d4115
[pre-commit.ci] auto fixes from pre-commit.com hooks
pre-commit-ci[bot] Jun 10, 2024
03f3d11
upload `.coverage.*` file to combine
zacharyburnett Jun 11, 2024
7d11824
list files
zacharyburnett Jun 21, 2024
2c4aa19
use runner.os instead of matrix value
zacharyburnett Jun 21, 2024
d3a9592
combine and report coverage
zacharyburnett Jun 21, 2024
8f00431
undo style formatting
zacharyburnett Jun 21, 2024
f3c3d29
set run shell
zacharyburnett Jun 21, 2024
2e7203a
set job name as `report coverage` to be explicit
zacharyburnett Jun 21, 2024
9660cce
use conditional ifs instead of continue-of-error
zacharyburnett Jun 24, 2024
12c5455
reorder ls and mv
zacharyburnett Jun 26, 2024
82addf6
find .coverage
zacharyburnett Jun 26, 2024
f20972d
use `find` to find `.coverage`
zacharyburnett Jun 26, 2024
3330921
rename job to indicate that it is reporting overall coverage
zacharyburnett Jun 27, 2024
6c4dc8c
always run coverage report
zacharyburnett Jun 27, 2024
d14c5a3
search in current directory for coverage file
Dec 4, 2024
6c504db
Test a different thing
Cadair Dec 4, 2024
7374fa0
Apply suggestions from code review
Cadair Dec 4, 2024
77e673a
Update .github/workflows/tox.yml
Cadair Dec 4, 2024
758a58d
Update .github/workflows/tox.yml
Cadair Dec 4, 2024
d86a14b
Update .github/workflows/tox.yml
Cadair Dec 4, 2024
fb26195
update script hex and resolve conflict
zacharyburnett Nov 12, 2025
ce2cffe
Fixup PR gh-207
neutrinoceros Nov 10, 2025
0fe6358
restore assumption that pytest-cov is ubuquitous
neutrinoceros Nov 12, 2025
4bf4a8c
Merge pull request #2 from neutrinoceros/fixup-207-c
zacharyburnett Nov 12, 2025
3f7a04e
Fix PR 207 (for real)
neutrinoceros Nov 13, 2025
da2c801
Merge pull request #3 from neutrinoceros/debug-207
zacharyburnett Nov 13, 2025
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
8 changes: 8 additions & 0 deletions .github/workflows/test_tox.yml
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,14 @@ jobs:
a/
cache-key: cache-${{ github.run_id }}

test_coverage_github:
uses: ./.github/workflows/tox.yml
with:
coverage: github
envs: |
- linux: py313-covcheck
- linux: py314-covcheck

test_artifact_upload:
uses: ./.github/workflows/tox.yml
with:
Expand Down
56 changes: 50 additions & 6 deletions .github/workflows/tox.yml

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -203,3 +203,6 @@ $RECYCLE.BIN/
### Pycharm
.idea
.history

# uv
uv.lock
4 changes: 2 additions & 2 deletions docs/source/tox.rst
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,8 @@ This option has no effect if ``pytest`` is ``false``.
coverage
^^^^^^^^

A space separated list of coverage providers to upload to. Currently
only ``codecov`` is supported. Default is to not upload coverage
A space separated list of coverage providers to upload to, either
``codecov`` or ``github``. Default is to not upload coverage
reports.

See also, ``CODECOV_TOKEN`` secret.
Expand Down
5 changes: 5 additions & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ concurrency = [
"pytest-repeat>=0.9.3",
"pytest-run-parallel>=0.4.4",
]
covcheck = [
"coverage[toml] ; python_version < '3.11'",
"coverage>=7.11.3",
"pytest-cov>=7.0.0",
]
test = [
"hypothesis>=6.113.0",
"pytest>=8.3.5",
Expand Down
68 changes: 49 additions & 19 deletions tools/tox_matrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# requires-python = "==3.12"
# dependencies = [
# "click==8.2.1",
# "packaging==25.0",
# "pyyaml==6.0.2",
# ]
# ///
Expand All @@ -11,6 +12,7 @@

import click
import yaml
from packaging.version import InvalidVersion, Version


@click.command()
Expand All @@ -32,9 +34,26 @@
@click.option("--runs-on", default="")
@click.option("--default-python", default="")
@click.option("--timeout-minutes", default="360")
def load_tox_targets(envs, libraries, posargs, toxdeps, toxargs, pytest, pytest_results_summary,
coverage, conda, setenv, display, cache_path, cache_key,
cache_restore_keys, artifact_path, runs_on, default_python, timeout_minutes):
def load_tox_targets(
envs,
libraries,
posargs,
toxdeps,
toxargs,
pytest,
pytest_results_summary,
coverage,
conda,
setenv,
display,
cache_path,
cache_key,
cache_restore_keys,
artifact_path,
runs_on,
default_python,
timeout_minutes,
):
"""Script to load tox targets for GitHub Actions workflow."""
# Load envs config
envs = yaml.load(envs, Loader=yaml.BaseLoader)
Expand Down Expand Up @@ -84,23 +103,23 @@ def load_tox_targets(envs, libraries, posargs, toxdeps, toxargs, pytest, pytest_
# Create matrix
matrix = {"include": []}
for env in envs:
matrix["include"].append(get_matrix_item(
env,
global_libraries=global_libraries,
global_string_parameters=string_parameters,
runs_on=default_runs_on,
default_python=default_python,
))
matrix["include"].append(
get_matrix_item(
env,
global_libraries=global_libraries,
global_string_parameters=string_parameters,
runs_on=default_runs_on,
default_python=default_python,
)
)

# Output matrix
print(json.dumps(matrix, indent=2))
with open(os.environ["GITHUB_OUTPUT"], "a") as f:
f.write(f"matrix={json.dumps(matrix)}\n")


def get_matrix_item(env, global_libraries, global_string_parameters,
runs_on, default_python):

def get_matrix_item(env, global_libraries, global_string_parameters, runs_on, default_python):
# define spec for each matrix include (+ global_string_parameters)
item = {
"os": None,
Expand Down Expand Up @@ -142,8 +161,16 @@ def get_matrix_item(env, global_libraries, global_string_parameters,
else:
item["python_version"] = env.get("default_python") or default_python

# if Python is <3.10 we can't use macos-latest which is arm64
try:
if Version(item["python_version"]) < Version("3.10") and item["os"] == "macos-latest":
item["os"] = "macos-12"
except InvalidVersion:
# python_version might be for example 'pypy-3.10' which won't parse
pass

# set name
item["name"] = env.get("name") or f'{item["toxenv"]} ({item["os"]})'
item["name"] = env.get("name") or f"{item['toxenv']} ({item['os']})"

# set artifact-name (replace invalid path characters)
item["artifact-name"] = re.sub(r"[\\ /:<>|*?\"']", "-", item["name"])
Expand All @@ -152,11 +179,14 @@ def get_matrix_item(env, global_libraries, global_string_parameters,
# set pytest_flag
item["pytest_flag"] = ""
sep = r"\\" if platform == "windows" else "/"
if item["pytest"] == "true" and "codecov" in item.get("coverage", ""):
item["pytest_flag"] += (
rf"--cov-report=xml:${{GITHUB_WORKSPACE}}{sep}coverage.xml ")
if item["pytest"] == "true" and item["pytest-results-summary"] == "true":
item["pytest_flag"] += rf"--junitxml ${{GITHUB_WORKSPACE}}{sep}results.xml "
if item["pytest"] == "true":
if "codecov" in item.get("coverage", ""):
item["pytest_flag"] += (
rf"--cov --cov-report=xml:${{GITHUB_WORKSPACE}}{sep}coverage.xml "
)

if item["pytest-results-summary"] == "true":
item["pytest_flag"] += rf"--junitxml ${{GITHUB_WORKSPACE}}{sep}results.xml "

# set libraries
env_libraries = env.get("libraries")
Expand Down
5 changes: 5 additions & 0 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ envlist =
py{,py}3{10,13}-python_version
libraries
cache-{setup,verify}
covcheck

[testenv]
allowlist_externals =
Expand All @@ -17,6 +18,9 @@ allowlist_externals =
bash
rolldice
which
dependency_groups =
covcheck: covcheck
covcheck: test
skip_install = true
passenv = MY_VAR
commands =
Expand Down Expand Up @@ -48,6 +52,7 @@ commands =
artifact-upload: bash -c "echo 'hello world' > test.txt"
# Verify that freethreaded builds are using freethreaded interpreter
py313t: python -c "import sys; assert 'free-threading' in sys.version"
covcheck: coverage run --parallel-mode -m pytest --pyargs test_package {posargs}

[testenv:pep8]
description = verify pep8
Expand Down
Loading