Skip to content

Commit 1700900

Browse files
committed
Added test coverage.
1 parent 71b038d commit 1700900

File tree

6 files changed

+279
-69
lines changed

6 files changed

+279
-69
lines changed

.github/workflows/test.yml

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,9 @@ name: "Testing package"
22

33
on:
44
pull_request:
5+
push:
6+
branches:
7+
- master
58

69
jobs:
710
py-lint:
@@ -83,7 +86,7 @@ jobs:
8386
- uses: actions-rs/toolchain@v1
8487
with:
8588
toolchain: stable
86-
components: clippy
89+
components: clippy,llvm-tools-preview
8790
override: true
8891
- uses: actions/setup-python@v6
8992
with:
@@ -95,17 +98,23 @@ jobs:
9598
run: docker compose up -d --wait
9699
- id: setup-venv
97100
name: Setup virtualenv
98-
run: python -m venv .venv
99-
- name: Build lib
100-
uses: PyO3/maturin-action@v1
101-
with:
102-
command: dev --uv
103-
sccache: true
101+
run: uv venv
104102
- name: Run pytest
105103
run: |
106104
set -e
107-
source .venv/bin/activate
108-
pytest -vv -n auto python/tests
105+
source <(cargo llvm-cov show-env --sh)
106+
export CARGO_TARGET_DIR=$CARGO_LLVM_COV_TARGET_DIR
107+
export CARGO_INCREMENTAL=1
108+
cargo llvm-cov clean --workspace
109+
uv run -- maturin dev --uv
110+
uv run -- pytest -vv -n auto python/tests --cov natsrpy --cov-report xml
111+
cargo llvm-cov report --lcov --output-path coverage.lcov
112+
- uses: codecov/codecov-action@v6
113+
with:
114+
fail_ci_if_error: false
115+
token: ${{ secrets.CODECOV_TOKEN }}
116+
files: ./coverage.lcov,./coverage.xml
117+
verbose: true
109118
- name: Teardown docker
110119
if: always()
111120
run: docker compose down

.pre-commit-config.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,7 @@ repos:
7676
language: python
7777
additional_dependencies:
7878
- mypy
79+
- maturin
7980
entry: python ./scripts/stubtest.py
8081
pass_filenames: false
8182
always_run: true

Cargo.toml

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,10 +27,15 @@ thiserror = "2.0.18"
2727
time = "0.3.47"
2828
tokio = { version = "1.50.0", features = ["full"] }
2929

30+
[profile.dev]
31+
opt-level = 0
32+
lto = "off"
33+
incremental = true
34+
3035
[profile.release]
31-
lto = "fat"
32-
codegen-units = 1
3336
opt-level = 3
34-
strip = true
3537
debug = false
38+
strip = true
39+
lto = "fat"
3640
panic = "abort"
41+
codegen-units = 1

README.md

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -56,16 +56,28 @@ As of for now, our documentation is only availabe in source code. You can see it
5656
## Development
5757

5858
We use stable rust and pyo3 for writing python extension module.
59+
In order to build the project, use uv and maturin.
5960

60-
In order to run the project use maturin:
61+
uv is used for all python-side dependencies (including dev deps).
62+
Maturin is used only for building rust-side.
6163

6264
```bash
6365
# To create .venv folder
6466
uv venv
67+
# Sync deps
68+
uv sync --locked
6569
# To build and install the package in a virtual environment
66-
maturin dev --uv
70+
uv run -- maturin dev --uv
6771
```
6872

73+
If you want to setup automatic rebuilds, use this command:
74+
75+
```bash
76+
uv run -- python -m maturin_import_hook site install
77+
```
78+
79+
It will force rebuild project when rust code changes.
80+
6981
For lints please use `pre-commit`.
7082

7183
```bash

pyproject.toml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,11 @@ classifiers = [
1313
"Programming Language :: Rust",
1414
"Topic :: System :: Networking",
1515
]
16-
dynamic = ["version"]
1716
dependencies = [
18-
"typing-extensions>=4.14.0",
17+
"maturin-import-hook>=0.3.0",
18+
"typing-extensions>=4.14.0",
1919
]
20+
dynamic = ["version"]
2021

2122
[[project.authors]]
2223
name = "Pavel Kirilin"
@@ -25,16 +26,21 @@ email = "s3riussan@gmail.com"
2526
[dependency-groups]
2627
dev = [
2728
"anyio>=4,<5",
29+
"maturin>=1,<2",
2830
"mypy>=1.19.1,<2",
2931
"pre-commit>=4.5.1,<5",
3032
"pytest>=9,<10",
33+
"pytest-cov>=7,<8",
3134
"pytest-xdist>=3,<4",
3235
]
3336

3437
[build-system]
3538
requires = ["maturin>=1.12,<2.0"]
3639
build-backend = "maturin"
3740

41+
[tool.uv]
42+
package = false
43+
3844
[tool.maturin]
3945
bindings = "pyo3"
4046
features = ["pyo3/extension-module"]

0 commit comments

Comments
 (0)