Skip to content
Merged
Show file tree
Hide file tree
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
9 changes: 9 additions & 0 deletions .github/codecov.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# Codecov's statuses report coverage on PRs but never fail them.
coverage:
status:
project:
default:
informational: true
patch:
default:
informational: true
41 changes: 21 additions & 20 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -102,30 +102,14 @@ jobs:
- name: Build
run: |
pip install -e . --no-deps
- name: Configure coverage
run: |
# Cython's coverage plugin (see [tool.coverage.run] in pyproject.toml)
# needs coverage's C tracer. Where conda-forge has no compiled build of
# coverage for a Python (3.15t, for now), it installs a pure-Python build
# that lacks the tracer. There, loading the plugin raises ImportError and
# every `coverage run` dies before it runs anything, so run the tests
# directly instead.
if python -c "import Cython.Coverage" 2>/dev/null; then
coverage erase
echo "COV=coverage run -a --branch" >> "$GITHUB_ENV"
else
echo "Cython coverage plugin unusable here; running without coverage"
python -VV
echo "COV=python" >> "$GITHUB_ENV"
fi
- name: Test
env:
CYTHON_COVERAGE: true
PYVER: ${{ matrix.python-version }}
run: |
pytest -s -k test_print_jit_config
$COV -m pytest
$COV suitesparse_graphblas/tests/test_initialize.py
# Coverage of the Python code; see [tool.coverage.run] in pyproject.toml.
coverage run -a -m pytest
coverage run -a suitesparse_graphblas/tests/test_initialize.py
if [[ $PYVER == *t ]]; then
# Without a GIL, threads run Python code in parallel, so also run each test in 4
# threads at once, 10 times each, to find races (in psg, GraphBLAS, or a test).
Expand All @@ -136,5 +120,22 @@ jobs:
- name: create_headers.py check
if: (! contains(matrix.os, 'windows'))
run: |
$COV suitesparse_graphblas/create_headers.py
coverage run -a suitesparse_graphblas/create_headers.py
git diff --exit-code # error if anything changed
- name: Coverage report
run: |
coverage report --show-missing
coverage xml
- name: Upload coverage to Codecov
uses: codecov/codecov-action@303a32d7a59b442fa8d48b6a1cc6825c09c847a5 # v7.1.1
with:
files: coverage.xml
disable_search: true
# The "Coverage report" step wrote coverage.xml, so skip the uploader's own search for
# gcov, Xcode, Swift and coverage.py data (it only logs a warning for each).
plugins: noop
name: ${{ matrix.os }} ${{ matrix.python-version }}
# PRs from forks upload without a token. Pushes to main need the repository
# secret CODECOV_TOKEN. An upload that fails doesn't fail the job.
token: ${{ secrets.CODECOV_TOKEN }}
fail_ci_if_error: false
5 changes: 3 additions & 2 deletions AGENTS.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,9 @@ only be called once per process, so `test_initialize.py` is run as a separate pr
docker run --rm -w /tmp psg-test python3 -m suitesparse_graphblas.tests.test_initialize
```

Coverage runs in CI use `CYTHON_COVERAGE=true` so the Cython `utils.pyx` extension is
recompiled with line tracing.
CI measures coverage of the Python code only, prints it in the "Coverage report" step, and
uploads it to Codecov. It doesn't trace `utils.pyx` (see `[tool.coverage.run]` in
`pyproject.toml`).

## Architecture: how the binding is generated and assembled

Expand Down
5 changes: 4 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,13 @@ line_length = 100
skip_glob = ["*.pxd", "*.pyx"]

[tool.coverage.run]
# Python code only. Cython's plugin for `utils.pyx` needs a build with line tracing, and on
# Python 3.14+ coverage's default core (sys.monitoring) can't run it.
branch = true
source = ["suitesparse_graphblas"]
omit = []
plugins = ["Cython.Coverage"]
# Paths relative to the checkout, so reports from every CI job line up.
relative_files = true

[tool.coverage.report]
ignore_errors = false
Expand Down
Loading