8000 GitHub - supinie/cargo-preflight: Preflight is a custom Cargo subcommand to run local "CI" on certain Git actions.
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

supinie/cargo-preflight

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

49 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

Warning: Preflight is currently in development, and will be subject to breaking changes.

Installing Preflight

cargo install cargo-preflight

nixpkgs:

testing in a temporary shell:

nix-shell -p cargo-preflight

or through Nix config:

  environment.systemPackages = [
    pkgs.cargo-preflight
  ];

or in a dev shell:

# shell.nix example
{ pkgs ? import <nixpkgs> {} }:
pkgs.mkShell {
  buildInputs = [ pkgs.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.

About

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

Topics

Resources

License

Stars

Watchers

Forks

Contributors 2

  •  
  •  

Languages

0