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.
How to ensure that all pre-commit hooks pass in CI/CD
Asked Answered
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
© 2022 - 2024 — McMap. All rights reserved.