Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions .github/workflows/build-rust-wheels.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ on:
env:
PACKAGE_NAME: json2xml_rs
PYTHON_VERSION: '3.12'
RUST_VERSION: '1.96.0'
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion: Consider deriving the Rust version from a single source of truth (e.g., rust-toolchain.toml) instead of hardcoding it here.

Hardcoding RUST_VERSION here can drift from the version in rust-toolchain* or what developers use locally. If you already define the toolchain elsewhere, consider either relying on setup-rust-toolchain’s default (reading rust-toolchain*) or defining the version once (e.g., in a reusable workflow/env) and referencing it here to keep CI and local environments aligned.

Suggested implementation:

env:
  PACKAGE_NAME: json2xml_rs
  PYTHON_VERSION: '3.12'

      - name: Install Rust toolchain
        uses: actions-rust-lang/setup-rust-toolchain@46268bd060767258de96ed93c1251119784f2ab6 # v1


permissions:
contents: read
Expand All @@ -33,6 +34,11 @@ jobs:
with:
python-version: ${{ env.PYTHON_VERSION }}

- name: Install Rust ${{ env.RUST_VERSION }}
uses: actions-rust-lang/setup-rust-toolchain@46268bd060767258de96ed93c1251119784f2ab6 # v1
with:
toolchain: ${{ env.RUST_VERSION }}

- name: Build wheels
uses: PyO3/maturin-action@e83996d129638aa358a18fbd1dfb82f0b0fb5d3b # v1
with:
Expand Down Expand Up @@ -62,6 +68,11 @@ jobs:
python-version: ${{ env.PYTHON_VERSION }}
architecture: ${{ matrix.target }}

- name: Install Rust ${{ env.RUST_VERSION }}
uses: actions-rust-lang/setup-rust-toolchain@46268bd060767258de96ed93c1251119784f2ab6 # v1
with:
toolchain: ${{ env.RUST_VERSION }}

- name: Build wheels
uses: PyO3/maturin-action@e83996d129638aa358a18fbd1dfb82f0b0fb5d3b # v1
with:
Expand Down Expand Up @@ -89,6 +100,11 @@ jobs:
with:
python-version: ${{ env.PYTHON_VERSION }}

- name: Install Rust ${{ env.RUST_VERSION }}
uses: actions-rust-lang/setup-rust-toolchain@46268bd060767258de96ed93c1251119784f2ab6 # v1
with:
toolchain: ${{ env.RUST_VERSION }}

- name: Build wheels
uses: PyO3/maturin-action@e83996d129638aa358a18fbd1dfb82f0b0fb5d3b # v1
with:
Expand All @@ -109,6 +125,11 @@ jobs:
steps:
- uses: actions/checkout@df4cb1c069e1874edd31b4311f1884172cec0e10 # v6.0.3

- name: Install Rust ${{ env.RUST_VERSION }}
uses: actions-rust-lang/setup-rust-toolchain@46268bd060767258de96ed93c1251119784f2ab6 # v1
with:
toolchain: ${{ env.RUST_VERSION }}

- name: Build sdist
uses: PyO3/maturin-action@e83996d129638aa358a18fbd1dfb82f0b0fb5d3b # v1
with:
Expand Down
8 changes: 7 additions & 1 deletion .github/workflows/rust-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ on:

env:
CARGO_TERM_COLOR: always
RUST_VERSION: '1.96.0'

permissions:
contents: read
Expand All @@ -31,6 +32,7 @@ jobs:
- name: Install Rust
uses: actions-rust-lang/setup-rust-toolchain@46268bd060767258de96ed93c1251119784f2ab6 # v1
with:
toolchain: ${{ env.RUST_VERSION }}
components: rustfmt, clippy

- name: Check formatting
Expand All @@ -43,7 +45,7 @@ jobs:

- name: Run Rust unit tests
working-directory: rust
run: cargo test --no-default-features
run: cargo test

rust-test:
name: Build & Test (${{ matrix.os }}, Python ${{ matrix.python-version }})
Expand All @@ -63,6 +65,8 @@ jobs:

- name: Install Rust
uses: actions-rust-lang/setup-rust-toolchain@46268bd060767258de96ed93c1251119784f2ab6 # v1
with:
toolchain: ${{ env.RUST_VERSION }}

- name: Install maturin
run: pip install maturin
Expand Down Expand Up @@ -107,6 +111,8 @@ jobs:

- name: Install Rust
uses: actions-rust-lang/setup-rust-toolchain@46268bd060767258de96ed93c1251119784f2ab6 # v1
with:
toolchain: ${{ env.RUST_VERSION }}

- name: Install maturin
run: pip install maturin
Expand Down
2 changes: 2 additions & 0 deletions lat.md/architecture.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@ The Rust extension crate targets the Rust 2024 edition and pins `rust-version` t

The Cargo feature layout separates normal Rust/PyO3 tests from extension-module builds. `cargo test` uses the default `python` feature without extension-module linking, while maturin enables the `extension-module` feature for wheel builds.

Release and CI workflows install the pinned Rust toolchain before building wheels or running Rust checks, so hosted runners do not silently use an older default compiler.

## Release packaging

Package releases keep the Python wrapper and Rust accelerator versioned together so optional fast installs receive compatible wheels.
Expand Down
Loading