close
Skip to content

fix(ci): use cargo-llvm-cov for Python SDK coverage#2817

Merged
hubcio merged 6 commits into
apache:masterfrom
atharvalade:fix-python-codecov-coverage
Feb 26, 2026
Merged

fix(ci): use cargo-llvm-cov for Python SDK coverage#2817
hubcio merged 6 commits into
apache:masterfrom
atharvalade:fix-python-codecov-coverage

Conversation

@atharvalade
Copy link
Copy Markdown
Contributor

Which issue does this PR close?

Closes #2816

Rationale

The Python SDK is built with maturin/PyO3, meaning all business logic is compiled Rust. pytest-cov can only measure Python source, so it produced empty reports and the Codecov upload silently failed.

What changed?

pytest-cov was generating empty coverage reports because there is no Python source code to instrument in a native Rust extension.

Replaced pytest-cov with cargo-llvm-cov, which instruments the Rust code at build time and collects profiling data when Python tests call into the compiled .so. This follows the same pattern used by pydantic-core and PyO3 itself.

Local Execution

  • Not passed (CI-only workflow changes)
  • Pre-commit hooks ran

AI Usage

  1. Opus 4.6
  2. Researched how pydantic-core and PyO3 handle coverage, then scaffolded the workflow changes
  3. Compared against pydantic-core and PyO3 CI workflows to verify the approach is correct
  4. Yes

Python SDK is a native Rust extension, so switch from pytest-cov to cargo-llvm-cov following pydantic-core/PyO3 pattern.
@codecov
Copy link
Copy Markdown

codecov Bot commented Feb 26, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 67.57%. Comparing base (d5d31e5) to head (103d806).
⚠️ Report is 1 commits behind head on master.

Additional details and impacted files
@@             Coverage Diff              @@
##             master    #2817      +/-   ##
============================================
- Coverage     68.07%   67.57%   -0.50%     
  Complexity      708      708              
============================================
  Files          1018     1027       +9     
  Lines         82550    83147     +597     
  Branches      60005    60015      +10     
============================================
- Hits          56194    56188       -6     
- Misses        24016    24608     +592     
- Partials       2340     2351      +11     
Flag Coverage Δ
csharp 67.06% <ø> (-0.19%) ⬇️
go 6.84% <ø> (ø)
java 54.02% <ø> (ø)
node 92.26% <ø> (-0.04%) ⬇️
python 0.00% <ø> (?)
rust 69.61% <ø> (-0.02%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.
see 23 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Source llvm-cov env in same shell as build to ensure instrumentation
cargo-llvm-cov show-env uses RUSTC_WRAPPER not RUSTFLAGS, which
maturin does not pass through. Use RUSTFLAGS and raw llvm tools.
@hubcio hubcio merged commit 6f01169 into apache:master Feb 26, 2026
111 of 114 checks passed
kriti-sc pushed a commit to kriti-sc/iggy that referenced this pull request Mar 6, 2026
Co-authored-by: Maciej Modzelewski <maciej@modzelewski.dev>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(ci): use cargo-llvm-cov for Python SDK coverage

3 participants