From 189831209ad9333742c88f1db66032eb80918206 Mon Sep 17 00:00:00 2001 From: Spencer Ferris <3319370+spencewenski@users.noreply.github.com> Date: Sat, 2 Nov 2024 22:40:41 -0700 Subject: [PATCH] chore: Use justfile scripts for pre-commit/pre-push hooks (#494) --- .cargo-husky/hooks/pre-commit | 2 +- .cargo-husky/hooks/pre-push | 49 +---------------------------------- justfile | 41 +++++++++++++++++++++++++++-- 3 files changed, 41 insertions(+), 51 deletions(-) diff --git a/.cargo-husky/hooks/pre-commit b/.cargo-husky/hooks/pre-commit index 1de06aa8..803c8b21 100644 --- a/.cargo-husky/hooks/pre-commit +++ b/.cargo-husky/hooks/pre-commit @@ -3,4 +3,4 @@ # Exit immediately if any command returns non-zero exit status. set -e -cargo fmt --all --check +just pre-commit diff --git a/.cargo-husky/hooks/pre-push b/.cargo-husky/hooks/pre-push index e07e64bc..2e2bc393 100755 --- a/.cargo-husky/hooks/pre-push +++ b/.cargo-husky/hooks/pre-push @@ -3,51 +3,4 @@ # Exit immediately if any command returns non-zero exit status. set -e -# `fmt` doesn't depend on which features are enabled -echo "### fmt --all --check ###" -cargo fmt --all --check - -# With no features -echo "### build --no-default-features ###" -RUSTFLAGS="-D warnings" cargo build --no-default-features -echo "### nextest run --no-default-features ###" -cargo nextest run --no-default-features --no-fail-fast -# Nextest doesn't support doc tests, run those separately -echo "### test --doc --no-default-features ###" -cargo test --doc --no-default-features --no-fail-fast -echo "### check --no-default-features ###" -cargo check --no-default-features -echo "### clippy --all-targets --no-default-features -- -D warnings ###" -cargo clippy --all-targets --no-default-features -- -D warnings - -# With default features -echo "### build ###" -cargo build -echo "### nextest run ###" -cargo nextest run --no-fail-fast -# Nextest doesn't support doc tests, run those separately -echo "### test --doc ###" -cargo test --doc --no-fail-fast -echo "### check ###" -cargo check -echo "### clippy --all-targets -- -D warnings ###" -cargo clippy --all-targets -- -D warnings - -# With all features -echo "### build --all-features ###" -cargo build --all-features -echo "### nextest run --all-features ###" -cargo nextest run --all-features --no-fail-fast -# Nextest doesn't support doc tests, run those separately -echo "### test --doc --all-features ###" -cargo test --doc --all-features --no-fail-fast -echo "### check --all-features ###" -cargo check --all-features -echo "### clippy --all-targets --all-features -- -D warnings ###" -cargo clippy --all-targets --all-features -- -D warnings - -echo "### cargo doc --all-features --no-deps ###" -RUSTDOCFLAGS="-D rustdoc::all -A rustdoc::private_intra_doc_links" cargo doc --all-features --no-deps - -echo "### cargo minimal-versions check --direct --all-features ###" -cargo minimal-versions check --direct --all-features --no-dev-deps +just pre-push diff --git a/justfile b/justfile index 594c08be..124744f6 100644 --- a/justfile +++ b/justfile @@ -33,6 +33,9 @@ test-all: test-unit test-book-all test-watch: cargo watch -s 'just test' +insta: + cargo insta review --workspace + serve-book: mdbook serve book @@ -65,9 +68,43 @@ alias fmt := format format: cargo fmt +check-fmt: + cargo fmt --all --check + +pre-commit: check-fmt +pre-push: check-fmt + +check-no-features: + cargo nextest run --no-default-features --no-fail-fast + # Nextest doesn't support doc tests, run those separately + cargo test --doc --no-default-features --no-fail-fast + cargo check --no-default-features + cargo clippy --all-targets --no-default-features -- -D warnings + +check-default-features: + # With default features + cargo nextest run --no-fail-fast + # Nextest doesn't support doc tests, run those separately + cargo test --doc --no-fail-fast + cargo check + cargo clippy --all-targets -- -D warnings + +check-all-features: + # With all features + cargo nextest run --all-features --no-fail-fast + # Nextest doesn't support doc tests, run those separately + cargo test --doc --all-features --no-fail-fast + cargo check --all-features + cargo clippy --all-targets --all-features -- -D warnings + +check-docs: + RUSTDOCFLAGS="-D rustdoc::all -A rustdoc::private_intra_doc_links" cargo doc --all-features --no-deps + +check-msrv: + cargo minimal-versions check --direct --all-features --no-dev-deps + # Run a suite of checks. These checks are fairly comprehensive and will catch most issues. However, they are still less than what is run in CI. -check: - .cargo-husky/hooks/pre-push +check: check-fmt check-no-features check-default-features check-all-features check-docs check-msrv # Check if the Codecov config is valid validate-codecov-config: