Skip to content

Instantly share code, notes, and snippets.

@heeh
Created December 5, 2025 14:39
Show Gist options
  • Select an option

  • Save heeh/9b5eb62df5a6367045d6d75c060cb6ef to your computer and use it in GitHub Desktop.

Select an option

Save heeh/9b5eb62df5a6367045d6d75c060cb6ef to your computer and use it in GitHub Desktop.
Rust pre-build Checks
echo "=== Running Rust pre-build checks ==="
# 1. Format check
echo "[1/5] Checking formatting (cargo fmt)"
cargo fmt --all -- --check
# 2. Lints (Clippy)
echo "[2/5] Running Clippy with warnings as errors"
cargo clippy --all-targets --all-features -- -D warnings
# 3. Security: dependency audit
if command -v cargo-audit >/dev/null 2>&1; then
echo "[3/5] Running cargo-audit"
cargo audit
else
echo "[3/5] Skipped cargo-audit (not installed)"
fi
# 4. Deny config (optional but recommended)
if command -v cargo-deny >/dev/null 2>&1; then
echo "[4/5] Running cargo-deny"
cargo deny check
else
echo "[4/5] Skipped cargo-deny (not installed)"
fi
# 5. Tests
echo "[5/5] Running tests"
cargo test --all
echo "=== All checks passed. Building ==="
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment