Skip to content

Commit 3348c31

Browse files
authored
Switch to uv and update CI workflows (#52)
Switches to `uv` for dependency management and tooling. Also updates the CI definition, adding a benchmark workflow, and updating the CI workflow to be similar to the one from `codecov-rs`.
1 parent 500513b commit 3348c31

File tree

17 files changed

+390
-388
lines changed

17 files changed

+390
-388
lines changed

.config/nextest.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[profile.default.junit]
2+
path = "core-test-results.xml"

.envrc

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
# using uv-managed python is currently broken because it sets a wrong `libdir`:
2+
# https://github.com/astral-sh/rye/discussions/851
3+
# https://github.com/astral-sh/rye/issues/646
4+
# https://github.com/astral-sh/uv/issues/8879
5+
# https://github.com/astral-sh/uv/issues/8429
6+
# https://github.com/astral-sh/uv/issues/7369
7+
uv sync --no-install-project --python-preference only-system
8+
source .venv/bin/activate

.github/workflows/bench.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: Benchmarks
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
workflow_dispatch:
9+
10+
jobs:
11+
benchmarks:
12+
name: Benchmarks
13+
runs-on: ubuntu-latest
14+
steps:
15+
- uses: actions/checkout@v4
16+
17+
- run: rustup toolchain install stable --profile minimal --no-self-update
18+
- uses: cargo-bins/cargo-binstall@main
19+
- run: cargo binstall cargo-codspeed
20+
- uses: Swatinem/rust-cache@v2
21+
22+
- run: cargo codspeed build
23+
- uses: CodSpeedHQ/action@v3
24+
with:
25+
run: cargo codspeed run
26+
token: ${{ secrets.CODSPEED_TOKEN }}

.github/workflows/ci.yml

Lines changed: 114 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,114 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches:
6+
- main
7+
pull_request:
8+
9+
env:
10+
RUSTFLAGS: -Dwarnings
11+
12+
jobs:
13+
lint:
14+
name: Lint
15+
runs-on: ubuntu-latest
16+
steps:
17+
- uses: actions/checkout@v4
18+
19+
- run: rustup toolchain install stable --profile minimal --component rustfmt --component clippy --no-self-update
20+
- uses: Swatinem/rust-cache@v2
21+
22+
- uses: actions/setup-python@v5
23+
24+
- run: cargo fmt --all -- --check
25+
- run: cargo clippy --all-features --workspace --tests --examples -- -D clippy::all
26+
27+
doctest:
28+
name: Documentation (and Tests)
29+
runs-on: ubuntu-latest
30+
env:
31+
RUSTDOCFLAGS: -Dwarnings
32+
steps:
33+
- uses: actions/checkout@v4
34+
35+
- run: rustup toolchain install stable --profile minimal --no-self-update
36+
- uses: Swatinem/rust-cache@v2
37+
38+
- uses: actions/setup-python@v5
39+
40+
- run: cargo test --workspace --all-features --doc
41+
- run: cargo doc --workspace --all-features --document-private-items --no-deps
42+
43+
test:
44+
name: Test
45+
runs-on: ubuntu-latest
46+
steps:
47+
- uses: actions/checkout@v4
48+
49+
- run: rustup toolchain install stable --profile minimal --component llvm-tools-preview --no-self-update
50+
- uses: Swatinem/rust-cache@v2
51+
- uses: taiki-e/install-action@cargo-llvm-cov
52+
- uses: taiki-e/install-action@nextest
53+
54+
- uses: actions/setup-python@v5
55+
- uses: astral-sh/setup-uv@v3
56+
- run: uv sync --all-extras --dev
57+
58+
- run: cargo llvm-cov nextest --lcov --output-path core.lcov --workspace --all-features --all-targets
59+
- run: mv target/nextest/default/core-test-results.xml .
60+
61+
- name: Run Python tests
62+
run: |
63+
source .venv/bin/activate
64+
65+
# Clear prior profile data
66+
cargo llvm-cov clean --workspace
67+
68+
# Set env vars so maturin will build our Rust code with coverage instrumentation
69+
source <(cargo llvm-cov show-env --export-prefix)
70+
maturin develop --uv
71+
72+
# Run Python tests. Any Rust code exercised by these tests will emit coverage data
73+
pytest --cov --junitxml=python-test-results.xml
74+
75+
# Turn the Rust coverage data into an lcov file
76+
cargo llvm-cov --no-run --lcov --output-path bindings.lcov
77+
78+
- name: Upload coverage data to Codecov
79+
if: ${{ !cancelled() }}
80+
uses: codecov/codecov-action@v4
81+
with:
82+
files: ./core.lcov,./bindings.lcov,./.coverage
83+
token: ${{ secrets.CODECOV_ORG_TOKEN }}
84+
url: ${{ secrets.CODECOV_URL }}
85+
disable_search: true
86+
verbose: true
87+
- name: Upload test results to Codecov
88+
if: ${{ !cancelled() }}
89+
uses: codecov/test-results-action@v1
90+
with:
91+
files: ./core-test-results.xml,./python-test-results.xml
92+
token: ${{ secrets.CODECOV_ORG_TOKEN }}
93+
url: ${{ secrets.CODECOV_URL }}
94+
disable_search: true
95+
verbose: true
96+
97+
- name: Upload coverage data to Codecov (Staging)
98+
if: ${{ !cancelled() }}
99+
uses: codecov/codecov-action@v4
100+
with:
101+
files: ./core.lcov,./bindings.lcov,./.coverage
102+
token: ${{ secrets.CODECOV_ORG_TOKEN_STAGING }}
103+
url: ${{ secrets.CODECOV_STAGING_API_URL }}
104+
disable_search: true
105+
verbose: true
106+
- name: Upload test results to Codecov (Staging)
107+
if: ${{ !cancelled() }}
108+
uses: codecov/test-results-action@v1
109+
with:
110+
files: ./core-test-results.xml,./python-test-results.xml
111+
token: ${{ secrets.CODECOV_ORG_TOKEN_STAGING }}
112+
url: ${{ secrets.CODECOV_STAGING_API_URL }}
113+
disable_search: true
114+
verbose: true

.github/workflows/test.yml

Lines changed: 0 additions & 63 deletions
This file was deleted.

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
/target
22
.venv
3-
__pycache__
3+
__pycache__
4+
.coverage
5+
/*.xml

.python-version

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
3.12

0 commit comments

Comments
 (0)