Rust CI/CD Cheat Sheet

Cargo workspaces, caching, and cross-compilation

Last Updated: November 21, 2025

Pipeline Steps

Step Command
Format cargo fmt --all
Lint cargo clippy --all-targets
Test cargo test
Build cargo build --release

Commands

cargo fetch
Pre-fetch deps
cargo build --target x86_64-unknown-linux-gnu
Cross compile
cargo publish --dry-run
Validate crate

Caching

Cache `.cargo` directories and incremental compilation artifacts to speed subsequent runs.

💡 Pro Tip: Cache `~/.cargo/registry`, run `cargo fmt` + `clippy`, and build for target triples.
← Back to DevOps & Cloud | Browse all categories | View all cheat sheets