commit 279e15e9e0728af0d30657a00028694fa6caf476 from: witcher date: Sun Nov 20 20:48:44 2022 UTC Add `contrib` with `pre-commit` git hook commit - da4657ddf61416699966324b6aea7f9b302044d8 commit + 279e15e9e0728af0d30657a00028694fa6caf476 blob - 93f1234ad41dc91222ddf76d50731643a63af4c1 blob + ee0dc16a5a9427974f2c81517b1e874260651970 --- README.md +++ README.md @@ -55,6 +55,13 @@ Bugs and todo can be found at # Contributing +## git hooks + +A `pre-commit` hook is available in `contrib/githooks/pre-commit` that catches +most errors that the CI fail on. I recommend installing it in +`.git/hooks/pre-commit` to catch errors before the CI can since building Rust in +the CI is quite expensive. + ## Making changes on the database When making changes on the database, make sure that: blob - /dev/null blob + 1ba8f2fc9dc743be894cbbf3b6b7107a55ab8383 (mode 755) --- /dev/null +++ contrib/githooks/pre-commit @@ -0,0 +1,29 @@ +#!/bin/sh + +# make sure the CI would pass, too +# if an error like "failed to find data for query" happens, this is probably +# the culprit and `sqx-data.json` needs to be regenerated +export SQLX_OFFLINE=true + +if cargo fmt -- --check; then + echo "format passed" +else + echo "code isn't formatted correctly - please format with `cargo fmt`" + exit 1 +fi + +if cargo clippy -- -D warnings; then + echo "linter passed" +else + echo "linter found warnings - please check with `cargo clippy`" + exit 1 +fi + +if cargo test; then + echo "tests passed" +else + echo "tests did not pass" + exit 1 +fi + +# vim:ft=sh