Set up pre-commit hooks
- add pre-commit and pre-merge hooks:
+ run `poetry run nox -s pre-commit` on staged *.py files
+ run common pre-commit hooks for validations that could not be
achieved with tools in the develop environment so easily
+ run `poetry run nox -s pre-merge` before merges and pushes
- implement the "pre-commit" and "pre-merge" sessions in nox
+ include a little hack to deal with the positional arguments
passed by the pre-commit framework
- provide more documentation on the nox sessions
This commit is contained in:
parent
9fc5b4816a
commit
da233e2e35
4 changed files with 171 additions and 15 deletions
38
.pre-commit-config.yaml
Normal file
38
.pre-commit-config.yaml
Normal file
|
|
@ -0,0 +1,38 @@
|
|||
default_stages: [commit] # only used if a hook does not specify stages
|
||||
fail_fast: true
|
||||
repos:
|
||||
# Run the local formatting, linting, and testing tool chains.
|
||||
- repo: local
|
||||
hooks:
|
||||
- id: local-pre-commit-checks
|
||||
name: Run code formatters and linters
|
||||
entry: poetry run nox -s pre-commit --
|
||||
language: system
|
||||
stages: [commit]
|
||||
types: [python]
|
||||
- id: local-pre-merge-checks
|
||||
name: Run the entire test suite
|
||||
entry: poetry run nox -s pre-merge --
|
||||
language: system
|
||||
stages: [merge-commit, push]
|
||||
types: [python]
|
||||
# Enable hooks provided by the pre-commit project to
|
||||
# enforce rules that local tools could not that easily.
|
||||
- repo: https://github.com/pre-commit/pre-commit-hooks
|
||||
rev: v3.2.0
|
||||
hooks:
|
||||
- id: check-added-large-files
|
||||
args: [--maxkb=100]
|
||||
- id: check-case-conflict
|
||||
- id: check-builtin-literals
|
||||
- id: check-merge-conflict
|
||||
- id: check-toml
|
||||
- id: check-yaml
|
||||
- id: end-of-file-fixer
|
||||
stages: [commit] # overwrite the default
|
||||
- id: mixed-line-ending
|
||||
args: [--fix=no]
|
||||
- id: no-commit-to-branch
|
||||
args: [--branch, main]
|
||||
- id: trailing-whitespace
|
||||
stages: [commit] # overwrite the default
|
||||
Loading…
Add table
Add a link
Reference in a new issue