rust-ai-driven-development-pipeline-template
A comprehensive template for AI-driven Rust development with full CI/CD pipeline support.
Features
- 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
Quick Start
Using This Template
- 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!
Development Setup
# Clone the repository
# Build the project
# Run tests
# Run the example binary
# Run an example
Running Tests
# Run all tests
# Run tests with verbose output
# Run doc tests
# Run a specific test
# Run tests with output
Code Quality Checks
# Format code
# Check formatting (CI style)
# Run Clippy lints
# Check file size limits (requires rust-script: cargo install rust-script)
# Run all checks
&& &&
Project Structure
.
├── .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/ # Rust scripts (via rust-script)
│ ├── bump-version.rs # Version bumping utility
│ ├── check-file-size.rs # File size validation script
│ ├── collect-changelog.rs # Changelog collection script
│ ├── create-github-release.rs # GitHub release creation
│ ├── detect-code-changes.rs # Detects code changes for CI
│ ├── get-bump-type.rs # Determines version bump type
│ └── version-and-commit.rs # 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
Design Choices
Code Quality Tools
-
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
Testing Strategy
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)
Changelog Management
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
# Edit the fragment to document your changes
CI/CD Pipeline
The 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
Release Automation
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
Configuration
Updating Package Name
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 Configuration
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)
rustfmt Configuration
Uses default rustfmt settings. To customize, create a rustfmt.toml:
= "2021"
= 100
= 4
Scripts Reference
All scripts in scripts/ are Rust scripts that use rust-script.
Install rust-script with: cargo install rust-script
| Script | Description |
|---|---|
cargo test |
Run all tests |
cargo fmt |
Format code |
cargo clippy |
Run lints |
cargo run --example basic_usage |
Run example |
rust-script scripts/check-file-size.rs |
Check file size limits |
rust-script scripts/bump-version.rs |
Bump version |
Example Usage
use ;
async
See examples/basic_usage.rs for more examples.
Contributing
Contributions are welcome! Please see CONTRIBUTING.md for guidelines.
Development Workflow
- 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
License
Unlicense - Public Domain
This is free and unencumbered software released into the public domain. See LICENSE for details.
Acknowledgments
Inspired by: