Skip to content

Commit

Permalink
ci(pre-push hook): automate loading pre-push hook with cargo-husky
Browse files Browse the repository at this point in the history
add cargo-husky to dev-deps, create hook, update `CONTRIBUTING.md`

ratatui#214
  • Loading branch information
SLASHLogin committed Jun 23, 2023
1 parent b808305 commit a569adc
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
10 changes: 10 additions & 0 deletions .cargo-husky/hooks/pre-push
Original file line number Diff line number Diff line change
@@ -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
2 changes: 2 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
5 changes: 5 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit a569adc

Please sign in to comment.