I’m using pre-commit with my projects, including the helpful pre-commit.ci and the pre-commit Github Action. I’m running into the Github action raising an error for the no-commit-to-branch
hook when merging pull requests. The context of why I’m using both and solutions I’ve considered but haven’t figured out how to implement is below.
To preserve Github Action minutes, I want to cancel my Github Action test workflow when pre-commit identifies errors. I haven’t figured out how to do that using pre-commit.ci (by having the test Github Action workflow monitor the result of the pre-commit.ci run and cancel if it encounters unfixable errors). However, I was able to use the pre-commit GitHub Action as a first step in my test workflow and use that to have the rest of the test workflow canceled if the pre-commit step encounters failures. This means I’m using redundant pre-commit checks, but achieved my goal (assume pre-commit hook setup and run is fast relative to tests).
The only problem I’m running into is that I’d like to enable the no-commit-to-branch
hook, but not have it run in my test Github Action workflow when I’m merging a Pull Request, which by definition causes the hook to fail.
I’m open to suggestions to:
- Detect the status of pre-commit.ci run for a Pull Request and cancel my test workflow for that Pull Request when pre-commit.ci encounters unfixable items.
- Configure the
no-commit-to-branch
hook so it doesn’t run when merging Pull Requests in GitHub - Solve this in a way I haven’t considered
Thanks in advance for your thoughts!