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

1

13

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.

If answered 19/5, 2021 at 17:56 Comment(0)
P
31

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

Psychoanalysis answered 19/5, 2021 at 21:30 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.