From ab3c04ce5b7423ca0fbb6eee17bcd0af5a3553c5 Mon Sep 17 00:00:00 2001 From: Erik Welch Date: Wed, 25 Nov 2026 12:50:07 -0600 Subject: [PATCH 1/2] CI: report Python coverage and upload it to Codecov Every test job ran the tests under coverage, but nothing read the result. Cython's plugin didn't help either. utils.pyx is compiled before the step that asked for line tracing, and on Python 3.14+ coverage's default core can't run the plugin. Measure the Python code only, without the plugin, with paths relative to the checkout. Print the report, with missing lines, in a "Coverage report" step, and upload coverage.xml to Codecov from every job. PRs from forks upload without a token. Pushes to main need the repository secret CODECOV_TOKEN, and an upload that fails doesn't fail the job. Codecov's statuses are informational (.github/codecov.yml). --- .github/codecov.yml | 9 +++++++++ .github/workflows/test.yml | 38 ++++++++++++++++++-------------------- AGENTS.md | 5 +++-- pyproject.toml | 5 ++++- 4 files changed, 34 insertions(+), 23 deletions(-) create mode 100644 .github/codecov.yml diff --git a/.github/codecov.yml b/.github/codecov.yml new file mode 100644 index 0000000..6adee4f --- /dev/null +++ b/.github/codecov.yml @@ -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 diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 6d8b457..7391706 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -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). @@ -136,5 +120,19 @@ 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 + 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 diff --git a/AGENTS.md b/AGENTS.md index cad7326..5609936 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -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 diff --git a/pyproject.toml b/pyproject.toml index 501d5f3..d53954c 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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 From bd7c94bf3e37b778b1508c1cb03620db06df1ebc Mon Sep 17 00:00:00 2001 From: Erik Welch Date: Wed, 25 Nov 2026 13:53:40 -0600 Subject: [PATCH 2/2] CI: skip the Codecov uploader's plugins Each upload tried the uploader's gcov, Xcode, Swift and coverage.py plugins and logged a warning for each one that found nothing, in all 21 jobs. The "Coverage report" step already writes coverage.xml. --- .github/workflows/test.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 7391706..4f70c9e 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -131,6 +131,9 @@ jobs: 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.