10 releases (5 breaking)
Uses new Rust 2024
new 0.5.1 | May 14, 2025 |
---|---|
0.4.2 | May 9, 2025 |
0.3.1 | May 1, 2025 |
0.2.2 | Apr 25, 2025 |
0.0.1 | Aug 18, 2022 |
#54 in Cargo plugins
891 downloads per month
2.5MB
765 lines
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.
Warning: Preflight is currently in development, and will be subject to breaking changes.
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
[[preflight]] # Create new table entry for different behaviours
run_when = [
"commit",
"push",
] # Default values: ["push"]
# List of branch names to run on, below is an example.
# If the list is empty (default), then it will run on any branch.
branches = [
"main",
"my_feature",
"supinie_dev",
] # Default values: []
checks = [
"fmt", # `cargo fmt -- --check`
"clippy", # `cargo clippy -- -D warnings`
"test", # `cargo test`
"unused_deps", # uses `cargo-shear`
"secrets", # uses `ripsecrets`
"check_tests", # `cargo check --tests`
"check_examples", # `cargo check --examples`
"check_benches", # `cargo check --benches`
] # Default values: ["fmt", "test"]
autofix = false # Enables autofix functionality (for fmt and clippy)
over_ride = false # Enables override functionality
Example Config:
[[preflight]]
run_when = ["commit"]
branches = []
checks = [
"fmt",
"clippy",
]
autofix = true
over_ride = true
[[preflight]]
run_when = ["push"]
branches = [
"main",
"master",
]
checks = [
"fmt",
"clippy",
"test",
"unused_deps",
"secrets",
]
autofix = false
over_ride = false
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
- Automatically remove unused hooks
- Properly overwrite old hooks
- Check for secrets
- Check semver for libs
- Check multiple commits for last "stable" commit
- Run on
cargo publish
These are in no particular order, and many will introduce breaking changes.
Dependencies
~30–43MB
~813K SLoC