#dev-tools #ci #git #git-cli #cli

app cargo-preflight

A custom Cargo subcommand to run local 'CI' on certain Git actions

6 releases

Uses new Rust 2024

new 0.2.2 Apr 25, 2025
0.2.1 Apr 25, 2025
0.1.1 Apr 22, 2025
0.0.1 Aug 18, 2022

#92 in Cargo plugins

Download history 3/week @ 2025-02-24 4/week @ 2025-03-03 433/week @ 2025-04-21

433 downloads per month

MIT license

2.5MB
446 lines

Preflight ferris

Preflight 🛫

Preflight is a custom Cargo subcommand to run local "CI" on certain Git actions.

Preflight's aim is to ensure that trivially broken commits don't reach your remote, wasting CI time, adding extra fix commits, and most importantly saving you the embarrasment.

Preflight runs as a git hook to automatically run checks on commit or push.

Installing Preflight

cargo install cargo-preflight

Configuring Preflight

Preflight can be configured by running:

cargo preflight --config

which will open a configuration wizard to walk you through the available options.

Alteratively, Preflight can be manually configured by editing the global ~/.config/cargo-preflight/preflight.toml configuration or local <your repo>/.preflight.toml configuration files.

Possible Options

run_when = [
    "commit",
    "push",
] # Default values: ["push"]

checks = [
    "fmt", # `cargo fmt -- --check`
    "clippy", # `cargo clippy -- -D warnings`
    "test", # `cargo test`
    "check_tests", # `cargo check --tests`
    "check_examples",  # `cargo check --examples`
    "check_benches", # `cargo check --benches`
    "unused_deps", # uses `cargo-shear`
] # Default values: ["fmt", "test"]

autofix = false # Enables autofix functionality (for fmt and clippy)

over_ride = false # Enables override functionality

Using Preflight

Preflight can be enabled in a repository by running:

cargo preflight --init

Preflight can also be run as a one-off test with the cargo preflight command.

Note: Currently, Preflight only supports Linux systems.

Roadmap

  • Override if checks fail
  • Auto-fix failed checks (when applicable, ie. clippy, fmt)
  • Set which branch(es) Preflight will run against
  • Different checks for different hooks
  • Check for secrets
  • Check semver for libs
  • Check multiple commits for last "stable" commit
  • Run on cargo publish
  • Automatically remove unused hooks
  • Properly overwrite old hooks

These are in no particular order, and many will introduce breaking changes.

Dependencies

~13–25MB
~372K SLoC