From a569adca664a1e93215b4c933ee0bc6ce663911e Mon Sep 17 00:00:00 2001 From: SLASHLogin Date: Fri, 23 Jun 2023 11:40:54 +0200 Subject: [PATCH] ci(pre-push hook): automate loading pre-push hook with cargo-husky add cargo-husky to dev-deps, create hook, update `CONTRIBUTING.md` #214 --- .cargo-husky/hooks/pre-push | 10 ++++++++++ CONTRIBUTING.md | 2 ++ Cargo.toml | 5 +++++ 3 files changed, 17 insertions(+) create mode 100644 .cargo-husky/hooks/pre-push diff --git a/.cargo-husky/hooks/pre-push b/.cargo-husky/hooks/pre-push new file mode 100644 index 0000000000..de3e16d72b --- /dev/null +++ b/.cargo-husky/hooks/pre-push @@ -0,0 +1,10 @@ +#!/usr/bin/env bash + +if command cargo-make >/dev/null 2>&1; then # Check if cargo-make is installed + echo "cargo-make installed, running..." +else + echo "cargo-make not installed, installing..." + cargo install cargo-make +fi + +cargo make ci diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 8a1623612b..af005b69aa 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -48,6 +48,8 @@ Any idea with a large scale impact on the crate or its users should ideally be d To avoid any issues that may arrise with the CI/CD by not following the [conventional commit](https://www.conventionalcommits.org/en/v1.0.0/) syntax, we recommend to install [Commitizen](https://commitizen-tools.github.io/commitizen/).\ By using this tool you automatically follow the configuration defined in [.cz.toml](.cz.toml). +Additionally, we're using [cargo-husky](https://github.com/rhysd/cargo-husky) to automatically load pre-commit hook, which will run `cargo make ci` before each commit. It will load the hook automatically when you run `cargo test`. If `cargo-make` is not installed, it will install it for you.\ +This will ensure that your code is formatted, compiles and passes all tests before you commit. If you want to skip this check, you can use `git commit --no-verify`. ## Continuous Integration diff --git a/Cargo.toml b/Cargo.toml index 854e145668..cfae72d2e5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -53,6 +53,11 @@ argh = "0.1" criterion = { version = "0.5", features = ["html_reports"] } fakeit = "1.1" +[dev-dependencies.cargo-husky] +version = "1" +default-features = false # Disable features which are enabled by default +features = ["user-hooks"] + [[bench]] name = "paragraph" harness = false