I'm using the pre-commit hooks configuration https://pre-commit.com/ to enable pre-commit hooks
repos:
- repo: local
hooks:
- id: pytest-check
name: pytest-check
entry: pytest
language: system
pass_filenames: false
always_run: false
- id: flake8
name: flake8
entry: flake8
language: python
types: [python]
args: ['src/']
If pytest-check
fails it will also execute the flake8
hook.
Is it possible to terminate the execution if a previous hook failed, in this case flake8 would not run if the pytest-check failed.
I read through the docs but couldn't find any information on this...
you're looking for fail_fast: true
it can be specified both at the top level and at the hook level
an aside you have a few unrelated problems with your configuration:
pre-commit
, they'll be slow which will frustrate your users and often lead to them turning the whole thing offalways_run: false
is the default, no need to specify itsrc/
and pre-commit is additionally passing filenames, and you've misconfigured the multiprocessing mode) -- I'd recommend using the pycqa/flake8
repository directly which configures this correctlyrepo: local
hooks there's no reason to use args
-- just specify it directly in entry
disclaimer: I wrote pre-commit