Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to ensure that all pre-commit hooks pass in CI/CD

My team uses Pre-commit in our repositories to run various code checks and formatters. Most of my teammates use it but some skip it entirely by committing with git commit --no-verify. Is there anyway to run something in CI/CD to ensure all Pre-commit hooks pass (we're using GitHub actions). If at least one hooks fails, then throw an error.

like image 930
Johnny Metz Avatar asked Feb 03 '26 11:02

Johnny Metz


1 Answers

There are several choices:

  • an adhoc job which runs pre-commit run --all-files as demonstrated in pre-commit.com docs (you probably also want --show-diff-on-failure if you're using formatters)
  • pre-commit.ci a CI system specifically built for this purpose
  • pre-commit/action a github action which is in maintenance-only mode (not recommended for new usecases)

disclaimer: I created pre-commit, and pre-commit.ci, and the github action

like image 154
Anthony Sottile Avatar answered Feb 05 '26 07:02

Anthony Sottile