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)
- Code coverage: Automated coverage reports with cargo-llvm-cov and Codecov
- Release automation: Automatic GitHub releases and crates.io publishing
- Template-safe defaults: CI/CD skips publishing when package name is
example-sum-package-name
- Click "Use this template" on GitHub to create a new repository
- Clone your new repository
- Update
Cargo.toml:- Change
namefromexample-sum-package-nameto your package name - Update
description,repository, anddocumentationURLs - Update
[lib]name and[[bin]]name
- Change
- Update imports in
src/main.rs,tests/, andexamples/ - 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 CLI binary
cargo run -- --a 3 --b 7
# 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_sum_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 (requires rust-script: cargo install rust-script)
rust-script scripts/check-file-size.rs
# Run all checks
cargo fmt --check && cargo clippy --all-targets --all-features && rust-script scripts/check-file-size.rs.
├── .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
├── experiments/ # Experiment and debug scripts
│ ├── test-changelog-parsing.rs # Changelog parsing validation
│ └── test-crates-io-check.rs # Crates.io version check validation
├── scripts/ # Rust scripts (via rust-script)
│ ├── bump-version.rs # Version bumping utility
│ ├── check-changelog-fragment.rs # Changelog fragment validation
│ ├── check-file-size.rs # File size validation script
│ ├── check-release-needed.rs # Release necessity check
│ ├── check-version-modification.rs # Version modification detection
│ ├── collect-changelog.rs # Changelog collection script
│ ├── create-changelog-fragment.rs # Changelog fragment creation
│ ├── create-github-release.rs # GitHub release creation
│ ├── detect-code-changes.rs # Code change detection for CI
│ ├── get-bump-type.rs # Version bump type determination
│ ├── get-version.rs # Version extraction from Cargo.toml
│ ├── git-config.rs # Git configuration for CI
│ ├── publish-crate.rs # Crates.io publishing
│ ├── rust-paths.rs # Rust root path detection
│ └── version-and-commit.rs # CI/CD version management
├── src/
│ ├── lib.rs # Library entry point
│ ├── main.rs # CLI binary (uses lino-arguments)
│ └── sum.rs # Sum function module
├── tests/
│ ├── unit_tests.rs # Unit test entry point
│ ├── unit/
│ │ ├── mod.rs
│ │ ├── sum.rs # Unit tests for sum function
│ │ └── ci-cd/
│ │ ├── mod.rs
│ │ └── changelog_parsing.rs # CI/CD changelog parsing tests
│ ├── integration_tests.rs # Integration test entry point
│ └── integration/
│ ├── mod.rs
│ └── sum.rs # CLI 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
The template includes a simple CLI sum application using lino-arguments (a drop-in replacement for clap that also supports .lenv and .env files). This demonstrates:
- Library module (
src/sum.rs) with a pure function - CLI binary (
src/main.rs) usinglino-argumentsfor argument parsing - Unit tests (
tests/unit/sum.rs) testing the function directly - Integration tests (
tests/integration/sum.rs) testing the full CLI binary
- rustfmt: Standard Rust code formatter
- Clippy: Rust linter with pedantic and nursery lints enabled
- Pre-commit hooks: Automated checks before each commit
The template supports multiple levels of testing:
- Unit tests: In
tests/unit/directory, testing functions directly - Integration tests: In
tests/integration/directory, testing CLI binary - CI/CD tests: In
tests/unit/ci-cd/directory, testing CI/CD script logic - Doc tests: In documentation examples using
///comments - Examples: In
examples/directory (also serve as documentation)
Users can easily delete CI/CD tests in tests/unit/ci-cd/ if not needed.
This template uses a fragment-based changelog system similar to Changesets and Scriv.
# 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:
- Change detection: Only runs relevant jobs based on changed files
- Changelog check: Validates changelog fragments on PRs with code changes
- Version check: Prevents manual version modification in PRs
- Linting: rustfmt and Clippy checks
- Test matrix: 3 OS (Ubuntu, macOS, Windows) with Rust stable
- Code coverage: cargo-llvm-cov with Codecov upload
- Building: Release build and package validation
- Auto release: Automatic releases when changelog fragments are merged to main
- Manual release: Workflow dispatch with version bump type selection
- Documentation: Automatic docs deployment to GitHub Pages after release
The default package name example-sum-package-name triggers skip logic in CI/CD scripts:
publish-crate.rsskips crates.io publishingcreate-github-release.rsskips GitHub release creation
Rename the package in Cargo.toml to enable full CI/CD publishing.
After creating a repository from this template:
-
Update
Cargo.toml:- Change
namefield fromexample-sum-package-name - Update
repositoryanddocumentationURLs - Change
[lib]name and[[bin]]name
- Change
-
Update imports:
src/main.rstests/unit/sum.rstests/integration/sum.rsexamples/basic_usage.rs
-
Update badges in this
README.md
All scripts in scripts/ are Rust scripts that use rust-script.
Install rust-script with: cargo install rust-script
| Command | Description |
|---|---|
cargo test |
Run all tests |
cargo fmt |
Format code |
cargo clippy |
Run lints |
cargo run -- --a 3 --b 7 |
Run CLI (sum 3 + 7) |
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 |
use example_sum_package_name::sum;
fn main() {
let result = sum(2, 3);
println!("2 + 3 = {result}");
}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: