diff --git a/.githooks/pre-commit b/.githooks/pre-commit new file mode 100644 index 0000000..d2918ae --- /dev/null +++ b/.githooks/pre-commit @@ -0,0 +1,14 @@ +#!/bin/sh +# SPDX-License-Identifier: MIT OR Apache-2.0 + +set -e + +# just test +cargo --locked nextest run --all-features +cargo test --doc --all-features + +# just lint +taplo format --check +taplo lint +cargo fmt --all --check +cargo clippy --examples --tests --benches --all-features --all-targets --locked diff --git a/.justfile b/.justfile index a98c0a4..4216673 100644 --- a/.justfile +++ b/.justfile @@ -40,6 +40,9 @@ lints: toml-check-fmt toml-lint check-fmt clippy # Rust all tests test: unit-test doctest +# Run all code-quality checks +precommit: test lints + # Publish crate to crates.io publish: cargo publish --token $CARGO_REGISTRY_TOKEN @@ -51,3 +54,6 @@ audit: # Check GitHub Actions security analysis with `zizmor` check-github-actions-security: zizmor . + +# Performs one-time repo setup +setup: git config core.hooksPath .githooks diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index be0da2f..bb2ecd5 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -80,3 +80,5 @@ you can run the basic CI checks in your local environment: modern test runner for Rust. - [`cargo-audit`](https://docs.rs/cargo-audit/latest/cargo_audit/): tool to check `Cargo.lock` files for security vulnerabilities. + +Please do `git config core.hooksPath .githooks` to automatically run these tools on each commit.