Skip to content

Commit 449277f

Browse files
authored
Merge pull request #6 from cjermain/claude/session-011CUYo18ZqbutpJ67DM6jab
Update dependencies and achieve 100% coverage
2 parents ca24236 + 13a0238 commit 449277f

File tree

7 files changed

+179
-134
lines changed

7 files changed

+179
-134
lines changed

.codecov.yml

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
codecov:
2+
require_ci_to_pass: yes
3+
4+
coverage:
5+
status:
6+
project:
7+
default:
8+
target: 100%
9+
threshold: 0%
10+
patch:
11+
default:
12+
target: 100%
13+
14+
ignore:
15+
- "tests/"
16+
- "**/*test*.rs"
17+
18+
comment:
19+
layout: "reach,diff,flags,tree"
20+
behavior: default
21+
22+
# Exclude specific patterns from coverage
23+
# coverage:off and coverage:on comments are recognized by CodeCov

.github/workflows/CI.yml

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,19 +12,16 @@ jobs:
1212
os: ["ubuntu"]
1313
runs-on: ${{ matrix.os }}-latest
1414
steps:
15-
- uses: actions/checkout@v4
15+
- uses: actions/checkout@v5
1616
- uses: actions/setup-python@v5
1717
with:
1818
python-version: "3.12"
1919
- name: Install uv
2020
uses: astral-sh/setup-uv@v5
2121
with:
2222
enable-cache: true
23-
- uses: actions-rs/toolchain@v1
23+
- uses: dtolnay/rust-toolchain@stable
2424
with:
25-
toolchain: stable
26-
override: true
27-
profile: minimal
2825
components: llvm-tools-preview
2926
- name: Install cargo-llvm-cov
3027
uses: taiki-e/install-action@cargo-llvm-cov

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ name = "foobar"
99
crate-type = ["cdylib"]
1010

1111
[dependencies]
12-
pyo3 = { version = "0.23.3", features = ["extension-module"] }
12+
pyo3 = { version = "0.23.5", features = ["extension-module"] }
1313

1414
[package.metadata.maturin]
1515
python-source = "python"

README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,4 +99,15 @@ The last step of this process happens in the CI, where we upload both coverage
9999
files to CodeCov. [Merging reports](https://docs.codecov.com/docs/merging-reports)
100100
is an automatic feature of CodeCov, so the final view shows the combined view.
101101

102+
# Excluding code from coverage
103+
104+
The `#[pymodule]` initialization function in `src/lib.rs` is surrounded by
105+
`LCOV_EXCL_START` and `LCOV_EXCL_STOP` [exclusion markers](https://manpages.ubuntu.com/manpages/noble/man5/lcovrc.5.html).
106+
These markers instruct LCOV-compatible coverage tools to exclude the enclosed
107+
region from coverage analysis. This is necessary because PyO3's module
108+
initialization code is generated by a procedural macro and cannot be directly
109+
tested in a way that produces coverage data (see [rust-lang/rust#84605](https://github.com/rust-lang/rust/issues/84605)).
110+
The markers appear as comments in the source code and are recognized by CodeCov
111+
when processing the LCOV report generated by `cargo-llvm-cov`.
112+
102113
https://codecov.io/gh/cjermain/rust-python-coverage

pyproject.toml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@ classifiers = [
88
"Programming Language :: Python :: Implementation :: PyPy",
99
]
1010
dependencies = [
11-
"pytest>=8.3.4",
11+
"pytest>=8.4.2",
1212
"pytest-cov>=6.0.0",
13-
"maturin>=1.8.1",
13+
"maturin>=1.9.6",
1414
]
1515

1616
[build-system]
17-
requires = ["maturin>=1.0,<2.0"]
17+
requires = ["maturin>=1.9,<2.0"]
1818
build-backend = "maturin"
1919

2020
[tool.maturin]

src/lib.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,13 @@ fn pyo3_sum(a: usize, b: usize) -> PyResult<usize> {
1313
}
1414

1515
/// A Python module implemented in Rust.
16+
// LCOV_EXCL_START - PyO3 module initialization cannot be directly tested (see rust-lang/rust#84605)
1617
#[pymodule]
1718
fn _foobar(_py: Python, m: &Bound<'_, PyModule>) -> PyResult<()> {
1819
m.add_function(wrap_pyfunction!(pyo3_sum, m)?)?;
1920
Ok(())
2021
}
22+
// LCOV_EXCL_STOP
2123

2224
#[cfg(test)]
2325
mod tests {

uv.lock

Lines changed: 137 additions & 125 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)