A comprehensive template for AI-driven Rust development with full CI/CD pipeline support.
- Rust stable support: Works with Rust stable version
- Cross-platform testing: CI runs on Ubuntu, macOS, and Windows
- Comprehensive testing: Unit tests, integration tests, and doc tests
- Code quality: rustfmt + Clippy with pedantic lints
- Pre-commit hooks: Automated code quality checks before commits
- CI/CD pipeline: GitHub Actions with multi-platform support
- Changelog management: Fragment-based changelog (like Changesets/Scriv)
- Release automation: Automatic GitHub releases
- Click "Use this template" on GitHub to create a new repository
- Clone your new repository
- Update
Cargo.tomlwith your package name and description - Rename the library and binary in
Cargo.toml - Update imports in tests and examples
- Build and start developing!
# Clone the repository
git clone https://github.com/link-foundation/rust-ai-driven-development-pipeline-template.git
cd rust-ai-driven-development-pipeline-template
# Build the project
cargo build
# Run tests
cargo test
# Run the example binary
cargo run
# Run an example
cargo run --example basic_usage# Run all tests
cargo test
# Run tests with verbose output
cargo test --verbose
# Run doc tests
cargo test --doc
# Run a specific test
cargo test test_add_positive_numbers
# Run tests with output
cargo test -- --nocapture# Format code
cargo fmt
# Check formatting (CI style)
cargo fmt --check
# Run Clippy lints
cargo clippy --all-targets --all-features
# Check file size limits
node scripts/check-file-size.mjs
# Run all checks
cargo fmt --check && cargo clippy --all-targets --all-features && node scripts/check-file-size.mjs.
├── .github/
│ └── workflows/
│ └── release.yml # CI/CD pipeline configuration
├── changelog.d/ # Changelog fragments
│ ├── README.md # Fragment instructions
│ └── *.md # Individual changelog entries
├── examples/
│ └── basic_usage.rs # Usage examples
├── scripts/
│ ├── bump-version.mjs # Version bumping utility
│ ├── check-file-size.mjs # File size validation script
│ ├── collect-changelog.mjs # Changelog collection script
│ ├── create-github-release.mjs # GitHub release creation
│ ├── detect-code-changes.mjs # Detects code changes for CI
│ ├── get-bump-type.mjs # Determines version bump type
│ └── version-and-commit.mjs # CI/CD version management
├── src/
│ ├── lib.rs # Library entry point
│ └── main.rs # Binary entry point
├── tests/
│ └── integration_test.rs # Integration tests
├── .gitignore # Git ignore patterns
├── .pre-commit-config.yaml # Pre-commit hooks configuration
├── Cargo.toml # Project configuration
├── CHANGELOG.md # Project changelog
├── CONTRIBUTING.md # Contribution guidelines
├── LICENSE # Unlicense (public domain)
└── README.md # This file
-
rustfmt: Standard Rust code formatter
- Ensures consistent code style across the project
- Configured to run on all Rust files
-
Clippy: Rust linter with comprehensive checks
- Pedantic and nursery lints enabled for strict code quality
- Catches common mistakes and suggests improvements
- Enforces best practices
-
Pre-commit hooks: Automated checks before each commit
- Runs rustfmt to ensure formatting
- Runs Clippy to catch issues early
- Runs tests to prevent broken commits
The template supports multiple levels of testing:
- Unit tests: In
src/lib.rsusing#[cfg(test)]modules - Integration tests: In
tests/directory - Doc tests: In documentation examples using
///comments - Examples: In
examples/directory (also serve as documentation)
This template uses a fragment-based changelog system similar to:
- Changesets (JavaScript)
- Scriv (Python)
Benefits:
- No merge conflicts: Multiple PRs can add fragments without conflicts
- Per-PR documentation: Each PR documents its own changes
- Automated collection: Fragments are collected during release
- Consistent format: Template ensures consistent changelog entries
# Create a changelog fragment
touch changelog.d/$(date +%Y%m%d_%H%M%S)_my_change.md
# Edit the fragment to document your changesThe GitHub Actions workflow provides:
- Linting: rustfmt and Clippy checks
- Changelog check: Warns if PRs are missing changelog fragments
- Test matrix: 3 OS (Ubuntu, macOS, Windows) with Rust stable
- Building: Release build and package validation
- Release: Automated GitHub releases when version changes
The release workflow supports:
- Auto-release: Automatically creates releases when version in Cargo.toml changes
- Manual release: Trigger releases via workflow_dispatch with version bump type
- Changelog collection: Automatically collects fragments during release
- GitHub releases: Automatic creation with CHANGELOG content
After creating a repository from this template:
-
Update
Cargo.toml:- Change
namefield - Update
repositoryanddocumentationURLs - Change
[lib]and[[bin]]names
- Change
-
Rename the crate in imports:
tests/integration_test.rsexamples/basic_usage.rssrc/main.rs
Clippy is configured in Cargo.toml under [lints.clippy]:
- Pedantic lints enabled for strict code quality
- Nursery lints enabled for additional checks
- Some common patterns allowed (e.g.,
module_name_repetitions)
Uses default rustfmt settings. To customize, create a rustfmt.toml:
edition = "2021"
max_width = 100
tab_spaces = 4| Script | Description |
|---|---|
cargo test |
Run all tests |
cargo fmt |
Format code |
cargo clippy |
Run lints |
cargo run --example basic_usage |
Run example |
node scripts/check-file-size.mjs |
Check file size limits |
node scripts/bump-version.mjs |
Bump version |
use my_package::{add, multiply, delay};
#[tokio::main]
async fn main() {
// Basic arithmetic
let sum = add(2, 3); // 5
let product = multiply(2, 3); // 6
println!("2 + 3 = {sum}");
println!("2 * 3 = {product}");
// Async operations
delay(1.0).await; // Wait for 1 second
}See examples/basic_usage.rs for more examples.
Contributions are welcome! Please see CONTRIBUTING.md for guidelines.
- Fork the repository
- Create a feature branch:
git checkout -b feature/my-feature - Make your changes and add tests
- Run quality checks:
cargo fmt && cargo clippy && cargo test - Add a changelog fragment
- Commit your changes (pre-commit hooks will run automatically)
- Push and create a Pull Request
Unlicense - Public Domain
This is free and unencumbered software released into the public domain. See LICENSE for details.
Inspired by: