Context
I want to ensure that each commit I push pass tests.
I want to check this on my (client) side, i.e. before commits are even pushed (so I don't want to rely on CI tools).
Problem
Currently, I have implemented a pre-commit
hook that run my tests, so that I cannot even commit a broken state.
However, my test suite takes more than a few seconds to run. It is that much time I need to wait prior to writing my commit message. This makes it impractical to use on a daily basis; both because I frequently commit, and that I sometimes purposefully want to commit a broken state to be squashed later (I know about git commit --no-verify
, but that is not the point).
Question
So instead of checking each commit one at a time (at creation), I want to batch-test them before pushing.
How to implement a pre-push
hook that run my test suite for each new commit to be pushed?
(For the sake of simplicity, say that passing tests means test/run_tests.sh
returns 0
.)