From 0b669acac07a2b325316a46cca01a5cb85eede3b Mon Sep 17 00:00:00 2001 From: Owen Jacobson Date: Wed, 17 Jun 2020 17:39:07 -0400 Subject: Provide a git hook to automate tests. When enabled, these hooks run the same tests as Travis, every commit. There's nothing inherently wrong with a failing test run (it's a useful signal), but the turnaround time for responding to Travis is a lot longer than the turnaround time for responding to a local test failure. The tradeoff here is that `git commit`, which is a _very_ common operation, takes considerably longer when the hooks are enabled, and runs a higher risk of giving users doorway effect issues. --- .git-hooks/pre-commit | 8 ++++++++ .git-hooks/pre-merge-commit | 7 +++++++ 2 files changed, 15 insertions(+) create mode 100755 .git-hooks/pre-commit create mode 100755 .git-hooks/pre-merge-commit (limited to '.git-hooks') diff --git a/.git-hooks/pre-commit b/.git-hooks/pre-commit new file mode 100755 index 0000000..7fd95fb --- /dev/null +++ b/.git-hooks/pre-commit @@ -0,0 +1,8 @@ +#!/bin/bash -e + +# dup of the list in .travis.yml +cargo build --locked +cargo test +cargo fmt -- --check +cargo clippy -- --deny warnings +cargo udeps --locked --all-targets diff --git a/.git-hooks/pre-merge-commit b/.git-hooks/pre-merge-commit new file mode 100755 index 0000000..efdecc9 --- /dev/null +++ b/.git-hooks/pre-merge-commit @@ -0,0 +1,7 @@ +#!/bin/bash -e + +# Run the pre-commit hook on merges, too. + +if [ -x .git-hooks/pre-commit ]; then + exec .git-hooks/pre-commit +fi -- cgit v1.2.3