Skip to content

Commit afa68ae

Browse files
authored
Merge pull request #6 from 56kyle/release/0.1.0
Release/0.1.0
2 parents 2de1d0b + c68a0d3 commit afa68ae

File tree

13 files changed

+2056
-21
lines changed

13 files changed

+2056
-21
lines changed

.cookiecutter.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"_commit": "f46d0e9611ca496d3600e43343a01dcfb86caee6",
2+
"_commit": "c6577daf23a9972a456f2331e679b07c049a264a",
33
"_template": "C:\\Users\\56kyl\\source\\repos\\cookiecutter-robust-python",
44
"add_rust_extension": true,
55
"author": "Kyle Oliver",

.cruft.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"template": "C:\\Users\\56kyl\\source\\repos\\cookiecutter-robust-python",
3-
"commit": "f46d0e9611ca496d3600e43343a01dcfb86caee6",
3+
"commit": "c6577daf23a9972a456f2331e679b07c049a264a",
44
"checkout": null,
55
"context": {
66
"cookiecutter": {
@@ -20,7 +20,7 @@
2020
"license": "MIT",
2121
"development_status": "Development Status :: 1 - Planning",
2222
"_template": "C:\\Users\\56kyl\\source\\repos\\cookiecutter-robust-python",
23-
"_commit": "f46d0e9611ca496d3600e43343a01dcfb86caee6"
23+
"_commit": "c6577daf23a9972a456f2331e679b07c049a264a"
2424
}
2525
},
2626
"directory": null

.github/workflows/build-rust.yml

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
name: Build Rust Crates
2+
3+
on:
4+
pull_request:
5+
paths:
6+
- "rust/**/*.rs"
7+
- "rust/Cargo.toml"
8+
- "rust/Cargo.lock"
9+
- "noxfile.py"
10+
- ".github/workflows/build-rust.yml"
11+
push:
12+
branches:
13+
- main
14+
- master
15+
paths:
16+
- "rust/**/*.rs"
17+
- "rust/Cargo.toml"
18+
- "rust/Cargo.lock"
19+
- "noxfile.py"
20+
- ".github/workflows/build-rust.yml"
21+
22+
workflow_dispatch:
23+
24+
jobs:
25+
build-rust:
26+
name: Build Rust Crates
27+
runs-on: ${{ matrix.platform.runner }}
28+
strategy:
29+
matrix:
30+
platform:
31+
- runner: ubuntu-latest
32+
target: x86_64-unknown-linux-gnu
33+
- runner: ubuntu-latest
34+
target: x86_64-unknown-linux-musl
35+
- runner: ubuntu-latest
36+
target: aarch64-unknown-linux-gnu
37+
- runner: ubuntu-latest
38+
target: aarch64-unknown-linux-musl
39+
- runner: macos-latest
40+
target: x86_64-apple-darwin
41+
- runner: macos-latest
42+
target: aarch64-apple-darwin
43+
- runner: windows-latest
44+
target: x86_64-pc-windows-msvc
45+
- runner: windows-latest
46+
target: i686-pc-windows-msvc
47+
48+
steps:
49+
- name: Checkout code
50+
uses: actions/checkout@v4
51+
52+
- name: Set up Rust
53+
uses: dtolnay/rust-toolchain@stable
54+
with:
55+
targets: ${{ matrix.platform.target }}
56+
57+
- name: Cache Rust dependencies
58+
uses: Swatinem/rust-cache@v2
59+
with:
60+
workspaces: "rust/"
61+
key: ${{ matrix.platform.target }}
62+
63+
- name: Set up cross-compilation toolchain (Linux)
64+
if: contains(matrix.platform.target, 'linux')
65+
run: |
66+
sudo apt-get update
67+
sudo apt-get install -y gcc-multilib
68+
if [[ "${{ matrix.platform.target }}" == *"aarch64"* ]]; then
69+
sudo apt-get install -y gcc-aarch64-linux-gnu
70+
fi
71+
if [[ "${{ matrix.platform.target }}" == *"musl"* ]]; then
72+
sudo apt-get install -y musl-tools
73+
fi
74+
75+
- name: Set up uv
76+
uses: astral-sh/setup-uv@v6
77+
78+
- name: Set up Python
79+
uses: actions/setup-python@v5
80+
with:
81+
python-version-file: ".github/workflows/.python-version"
82+
83+
- name: Build Rust crates for target
84+
run: |
85+
cd rust
86+
cargo build --release --target ${{ matrix.platform.target }}
87+
88+
- name: Upload Rust build artifacts
89+
uses: actions/upload-artifact@v4
90+
with:
91+
name: rust-artifacts-${{ matrix.platform.target }}
92+
path: rust/target/${{ matrix.platform.target }}/release/
93+
retention-days: 7

.github/workflows/lint-rust.yml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
name: Lint Rust Code
2+
3+
on:
4+
pull_request:
5+
paths:
6+
- "rust/**/*.rs"
7+
- "Cargo.toml"
8+
- "noxfile.py"
9+
- ".github/workflows/lint-rust.yml"
10+
push:
11+
branches:
12+
- main
13+
- master
14+
paths:
15+
- "rust/**/*.rs"
16+
- "Cargo.toml"
17+
- "noxfile.py"
18+
- ".github/workflows/lint-rust.yml"
19+
20+
workflow_dispatch:
21+
22+
jobs:
23+
lint-rust:
24+
name: Run Rust Linting Checks
25+
runs-on: ubuntu-latest
26+
27+
steps:
28+
- name: Checkout code
29+
uses: actions/checkout@v4
30+
31+
- name: Set up Rust
32+
uses: dtolnay/rust-toolchain@stable
33+
with:
34+
components: "rustfmt,clippy"
35+
36+
- name: Cache Rust dependencies
37+
uses: Swatinem/rust-cache@v2
38+
with:
39+
workspaces: "rust/"
40+
41+
- name: Set up uv
42+
uses: astral-sh/setup-uv@v6
43+
44+
- name: Set up Python
45+
uses: actions/setup-python@v5
46+
with:
47+
python-version-file: ".github/workflows/.python-version"
48+
49+
- name: Run Rust format check
50+
run: uvx nox -s format-rust
51+
52+
- name: Run Rust lint check
53+
run: uvx nox -s lint-rust

.github/workflows/test-rust.yml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
name: Test Rust Code
2+
3+
on:
4+
pull_request:
5+
paths:
6+
- "rust/**/*.rs"
7+
- "Cargo.toml"
8+
- "noxfile.py"
9+
- ".github/workflows/test-rust.yml"
10+
push:
11+
branches:
12+
- main
13+
- master
14+
paths:
15+
- "rust/**/*.rs"
16+
- "Cargo.toml"
17+
- "noxfile.py"
18+
- ".github/workflows/test-rust.yml"
19+
20+
workflow_dispatch:
21+
22+
jobs:
23+
test-rust:
24+
name: Run Rust Tests on ${{ matrix.os }}
25+
runs-on: ${{ matrix.os }}
26+
strategy:
27+
matrix:
28+
include:
29+
- { os: "ubuntu-latest" }
30+
- { os: "macos-latest" }
31+
- { os: "windows-latest" }
32+
33+
steps:
34+
- name: Checkout code
35+
uses: actions/checkout@v4
36+
37+
- name: Set up Rust
38+
run: rustup show
39+
40+
- name: Cache Rust dependencies
41+
uses: Swatinem/rust-cache@v2
42+
with:
43+
workspaces: "rust/"
44+
45+
- name: Set up uv
46+
uses: astral-sh/setup-uv@v6
47+
48+
- name: Set up Python
49+
uses: actions/setup-python@v5
50+
with:
51+
python-version-file: ".github/workflows/.python-version"
52+
53+
- name: Run Rust tests
54+
run: uvx nox -s test-rust

CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
## v0.1.0 (2025-09-18)
2+
3+
### Feat
4+
5+
- initial sync with cruft
6+
- initial commit
7+
8+
### Fix
9+
10+
- remove accidentally added file

noxfile.py

Lines changed: 58 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -39,13 +39,10 @@
3939
TEST: str = "test"
4040
COVERAGE: str = "coverage"
4141
SECURITY: str = "security"
42-
PERF: str = "perf"
4342
DOCS: str = "docs"
4443
BUILD: str = "build"
4544
RELEASE: str = "release"
4645
QUALITY: str = "quality"
47-
PYTHON: str = "python"
48-
RUST: str = "rust"
4946

5047

5148
@nox.session(python=False, name="setup-git", tags=[ENV])
@@ -88,21 +85,39 @@ def precommit(session: Session) -> None:
8885
activate_virtualenv_in_precommit_hooks(session)
8986

9087

91-
@nox.session(python=False, name="format-python", tags=[FORMAT, PYTHON, QUALITY])
88+
@nox.session(python=False, name="format-python", tags=[FORMAT, QUALITY])
9289
def format_python(session: Session) -> None:
9390
"""Run Python code formatter (Ruff format)."""
9491
session.log(f"Running Ruff formatter check with py{session.python}.")
9592
session.run("uvx", "ruff", "format", *session.posargs)
9693

9794

98-
@nox.session(python=False, name="lint-python", tags=[LINT, PYTHON, QUALITY])
95+
@nox.session(python=False, name="format-rust", tags=[FORMAT])
96+
def format_rust(session: Session) -> None:
97+
"""Run Rust code formatter (cargo fmt)."""
98+
session.log("Ensuring rustfmt component is available...")
99+
session.run("rustup", "component", "add", "rustfmt", external=True)
100+
session.log("Formatting Rust code...")
101+
session.run("cargo", "fmt", "--all", external=True)
102+
103+
104+
@nox.session(python=False, name="lint-python", tags=[LINT, QUALITY])
99105
def lint_python(session: Session) -> None:
100106
"""Run Python code linters (Ruff check, Pydocstyle rules)."""
101107
session.log(f"Running Ruff check with py{session.python}.")
102108
session.run("uvx", "ruff", "check", "--fix", "--verbose")
103109

104110

105-
@nox.session(python=PYTHON_VERSIONS, name="typecheck", tags=[TYPE, PYTHON])
111+
@nox.session(python=False, name="lint-rust", tags=[LINT, QUALITY])
112+
def lint_rust(session: Session) -> None:
113+
"""Run Rust code linters (cargo clippy)."""
114+
session.log("Ensuring clippy component is available...")
115+
session.run("rustup", "component", "add", "clippy", external=True)
116+
session.log("Running clippy lints...")
117+
session.run("cargo", "clippy", "--all-features", "--", "-D", "warnings", external=True)
118+
119+
120+
@nox.session(python=PYTHON_VERSIONS, name="typecheck")
106121
def typecheck(session: Session) -> None:
107122
"""Run static type checking (Pyright) on Python code."""
108123
session.log("Installing type checking dependencies...")
@@ -112,7 +127,7 @@ def typecheck(session: Session) -> None:
112127
session.run("pyright", "--pythonversion", session.python)
113128

114129

115-
@nox.session(python=False, name="security-python", tags=[SECURITY, PYTHON])
130+
@nox.session(python=False, name="security-python", tags=[SECURITY])
116131
def security_python(session: Session) -> None:
117132
"""Run code security checks (Bandit) on Python code."""
118133
session.log(f"Running Bandit static security analysis with py{session.python}.")
@@ -122,7 +137,15 @@ def security_python(session: Session) -> None:
122137
session.run("uvx", "pip-audit")
123138

124139

125-
@nox.session(python=PYTHON_VERSIONS, name="tests-python", tags=[TEST, PYTHON])
140+
@nox.session(python=False, name="security-rust", tags=[SECURITY])
141+
def security_rust(session: Session) -> None:
142+
"""Run code security checks (cargo audit)."""
143+
session.log("Ensuring cargo-audit is available...")
144+
session.run("cargo", "install", "cargo-audit", "--locked", external=True)
145+
session.run("cargo", "audit", "--all", external=True)
146+
147+
148+
@nox.session(python=PYTHON_VERSIONS, name="tests-python", tags=[TEST])
126149
def tests_python(session: Session) -> None:
127150
"""Run the Python test suite (pytest with coverage)."""
128151
session.log("Installing test dependencies...")
@@ -144,6 +167,15 @@ def tests_python(session: Session) -> None:
144167
)
145168

146169

170+
@nox.session(python=False, name="tests-rust", tags=[TEST])
171+
def tests_rust(session: Session) -> None:
172+
"""Test the project's rust crates."""
173+
crates: list[Path] = [cargo_toml.parent for cargo_toml in CRATES_FOLDER.glob("*/Cargo.toml")]
174+
crate_kwargs: list[str] = [f"-p {crate.name}" for crate in crates]
175+
session.run("cargo", "test", "--all-features", "--no-run", *crate_kwargs, external=True)
176+
session.run("cargo", "test", "--all-features", *crate_kwargs, external=True)
177+
178+
147179
@nox.session(python=DEFAULT_PYTHON_VERSION, name="build-docs", tags=[DOCS, BUILD])
148180
def docs_build(session: Session) -> None:
149181
"""Build the project documentation (Sphinx)."""
@@ -160,16 +192,23 @@ def docs_build(session: Session) -> None:
160192
session.run("sphinx-build", "-b", "html", "docs", str(docs_build_dir), "-W")
161193

162194

163-
@nox.session(python=False, name="build-python", tags=[BUILD, PYTHON])
195+
@nox.session(python=False, name="build-python", tags=[BUILD])
164196
def build_python(session: Session) -> None:
165197
"""Build sdist and wheel packages (uv build)."""
166198
session.log(f"Building sdist and wheel packages with py{session.python}.")
167-
session.run("uv", "build", "--sdist", "--wheel", "--out-dir", "dist/", external=True)
199+
session.run("maturin", "develop", "--uv")
168200
session.log("Built packages in ./dist directory:")
169201
for path in Path("dist/").glob("*"):
170202
session.log(f"- {path.name}")
171203

172204

205+
@nox.session(python=False, name="build-rust", tags=[BUILD])
206+
def build_rust(session: Session) -> None:
207+
"""Build standalone Rust crates for potential independent publishing."""
208+
session.log("Building Rust crates...")
209+
session.run("cargo", "build", "--release", "--manifest-path", "rust/Cargo.toml", external=True)
210+
211+
173212
@nox.session(python=False, name="build-container", tags=[BUILD])
174213
def build_container(session: Session) -> None:
175214
"""Build the Docker container image.
@@ -241,6 +280,15 @@ def publish_python(session: Session) -> None:
241280
session.run("uv", "publish", "dist/*", *session.posargs, external=True)
242281

243282

283+
@nox.session(python=False, name="publish-rust", tags=[RELEASE])
284+
def publish_rust(session: Session) -> None:
285+
"""Publish built crates to crates.io."""
286+
session.log("Publishing crates to crates.io")
287+
for cargo_toml in CRATES_FOLDER.glob("*/Cargo.toml"):
288+
crate_folder: Path = cargo_toml.parent
289+
session.run("cargo", "publish", "-p", crate_folder.name)
290+
291+
244292
@nox.session(python=False)
245293
def tox(session: Session) -> None:
246294
"""Run the 'tox' test matrix.

pyproject.toml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[project]
22
name = "robust-maturin-demo"
3-
version = "0.0.0"
3+
version = "0.1.0"
44
description = "robust-maturin-demo"
55
authors = [
66
{ name = "Kyle Oliver", email = "[email protected]" },
@@ -57,5 +57,8 @@ publish-url = "https://test.pypi.org/legacy/"
5757
explicit = true
5858

5959
[build-system]
60-
requires = ["setuptools>=61.0"]
61-
build-backend = "setuptools.build_meta"
60+
requires = ["maturin>=1.9.0,<2.0"]
61+
build-backend = "maturin"
62+
63+
[tool.maturin]
64+
rust-src = "rust"

0 commit comments

Comments
 (0)