Skip to content

Commit 7392176

Browse files
committed
Add CI workflows, Python/WASM bindings scaffolding, and build automation
1 parent dd0e1d7 commit 7392176

11 files changed

Lines changed: 195 additions & 1 deletion

File tree

.github/dependabot.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# To get started with Dependabot version updates, you'll need to specify which
2+
# package ecosystems to update and where the package manifests are located.
3+
# Please see the documentation for all configuration options:
4+
# https://docs.github.com/code-security/dependabot/dependabot-version-updates/configuration-options-for-the-dependabot.yml-file
5+
6+
version: 2
7+
updates:
8+
- package-ecosystem: "cargo"
9+
directory: "/"
10+
schedule:
11+
interval: "weekly"

.github/workflows/rust.yml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
name: Rust
2+
3+
on:
4+
push:
5+
branches: ["main"]
6+
pull_request:
7+
branches: ["main"]
8+
9+
env:
10+
CARGO_TERM_COLOR: always
11+
12+
jobs:
13+
call-ci:
14+
uses: qntx/workflows/.github/workflows/rust.yml@main

.github/workflows/stale.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
name: Close Stale Issues and PRs
2+
3+
on:
4+
schedule:
5+
- cron: "30 1 * * *"
6+
workflow_dispatch:
7+
8+
jobs:
9+
close-stale:
10+
uses: qntx/workflows/.github/workflows/stale.yml@main

Cargo.lock

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

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[workspace]
2-
members = ["sodo"]
2+
members = ["sodo", "sodo-py", "sodo-wasm"]
33
# Only check / build main crates by default (check all with `--workspace`)
44
default-members = ["sodo"]
55

Makefile

Lines changed: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
# Makefile for Rust project using Cargo
2+
3+
.PHONY: all
4+
all: pre-commit
5+
6+
# Build the project with all features enabled in release mode
7+
.PHONY: build
8+
build:
9+
cargo build --release --all-features
10+
11+
# Update dependencies to their latest compatible versions
12+
.PHONY: update
13+
update:
14+
cargo update
15+
16+
# Run the project with all features enabled in release mode
17+
.PHONY: run
18+
run:
19+
cargo run --release --all-features
20+
21+
# Run all tests with all features enabled
22+
.PHONY: test
23+
test:
24+
cargo test --all-features
25+
26+
# Run benchmarks with all features enabled
27+
.PHONY: bench
28+
bench:
29+
cargo bench --all-features
30+
31+
# Run Clippy linter with nightly toolchain, fixing issues automatically
32+
# and applying strict linting rules
33+
.PHONY: clippy
34+
clippy:
35+
cargo +nightly clippy --fix \
36+
--all-targets \
37+
--all-features \
38+
--allow-dirty \
39+
--allow-staged \
40+
-- -D warnings \
41+
-W clippy::pedantic \
42+
-W clippy::nursery \
43+
-W clippy::unwrap_used \
44+
-W clippy::expect_used
45+
46+
# Format the code using rustfmt with nightly toolchain
47+
.PHONY: fmt
48+
fmt:
49+
cargo +nightly fmt
50+
51+
# Generate documentation for all crates and open it in the browser
52+
.PHONY: doc
53+
doc:
54+
cargo +nightly doc --all-features --no-deps --open
55+
56+
# Generate CHANGELOG.md using git-cliff
57+
.PHONY: cliff
58+
cliff:
59+
git-cliff
60+
git cliff --output CHANGELOG.md
61+
62+
# Check for unused dependencies using cargo-udeps with nightly toolchain
63+
.PHONY: udeps
64+
udeps:
65+
cargo +nightly udeps --all-features
66+
67+
# Update and run udeps to check for unused dependencies
68+
.PHONY: udeps-check
69+
udeps-check:
70+
cargo update
71+
cargo +nightly udeps --all-features
72+
73+
# Build the wasm package
74+
.PHONY: wasm-build
75+
wasm-build:
76+
@echo "Building WASM package..."
77+
(cd option-wasm && wasm-pack build --target web && wasm-pack pack pkg)
78+
79+
# Publish the wasm package to npm
80+
# Note: You must be logged in to npm for this to work (`npm login`)
81+
.PHONY: wasm-publish
82+
wasm-publish: wasm-build
83+
@echo "Publishing WASM package to npm..."
84+
(cd option-wasm/pkg && npm pkg fix && npm pkg set name="@qntx/option" && npm publish --access public)
85+
86+
# Convenience target to build and publish wasm
87+
.PHONY: wasm
88+
wasm: wasm-publish
89+
90+
# Sync Python environment using uv
91+
.PHONY: uv-sync
92+
uv-sync:
93+
uv venv
94+
uv lock --upgrade
95+
uv sync
96+
maturin build
97+
maturin develop --uv
98+
99+
# Run pre-commit hooks on all files
100+
.PHONY: pre-commit
101+
pre-commit:
102+
$(MAKE) udeps
103+
$(MAKE) build
104+
$(MAKE) test
105+
$(MAKE) clippy
106+
$(MAKE) fmt
107+
$(MAKE) cliff
108+
$(MAKE) wasm-build
109+
$(MAKE) uv-sync

rust-toolchain.toml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
[toolchain]
2+
channel = "stable"

sodo-py/Cargo.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[package]
2+
name = "sodo-py"
3+
version = "0.1.0"
4+
edition = "2024"
5+
6+
[dependencies]

sodo-py/src/lib.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
pub fn add(left: u64, right: u64) -> u64 {
2+
left + right
3+
}
4+
5+
#[cfg(test)]
6+
mod tests {
7+
use super::*;
8+
9+
#[test]
10+
fn it_works() {
11+
let result = add(2, 2);
12+
assert_eq!(result, 4);
13+
}
14+
}

sodo-wasm/Cargo.toml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[package]
2+
name = "sodo-wasm"
3+
version = "0.1.0"
4+
edition = "2024"
5+
6+
[dependencies]

0 commit comments

Comments
 (0)