Skip to content

Instantly share code, notes, and snippets.

@adriantorrie
Last active December 8, 2024 13:52
Show Gist options
  • Save adriantorrie/c055ca7f3ce6b73a5ec0be014edd7e3b to your computer and use it in GitHub Desktop.
Save adriantorrie/c055ca7f3ce6b73a5ec0be014edd7e3b to your computer and use it in GitHub Desktop.
Pytest pre-commit hook
# Pre-commit rules
#
# Notes
# -----
# - Ensure you have installed the hooks, see the README for instructions.
# - When you add a new hook you must run:
# - `pre-commit run --all-files`
#
# References
# ----------
# - https://pre-commit.com
# - https://pre-commit.com/hooks.html
# - https://pre-commit.com/#adding-pre-commit-plugins-to-your-project
# - https://pre-commit.com/#regular-expressions
# - https://docs.python.org/3/library/re.html#regular-expression-syntax
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
hooks:
- id: check-added-large-files
- id: check-yaml
- id: end-of-file-fixer
- id: sort-simple-yaml
- id: trailing-whitespace
- id: check-merge-conflict
# TODO: fix conflict with black formatter
# # Python import ordering and splitting to prevent merge conflicts
# - repo: https://github.com/asottile/reorder_python_imports
# rev: v3.13.0
# hooks:
# - id: reorder-python-imports
# args: ["--application-directories=.:src"]
# Python autoformatter
- repo: https://github.com/psf/black
rev: 24.10.0
hooks:
- id: black
# Dockerfile linter
# - https://github.com/hadolint/hadolint/blob/master/docs/INTEGRATION.md#pre-commit
- repo: https://github.com/hadolint/hadolint
rev: v2.13.1-beta
hooks:
- id: hadolint-docker
files: (Dockerfile)$
# Markdown linter
# - https://github.com/markdownlint/markdownlint/blob/41fc308f0d7f2647f0ae2c2d3826f48e42d964f4/.pre-commit-hooks.yaml#L8
- repo: https://github.com/markdownlint/markdownlint
rev: v0.12.0
hooks:
- id: markdownlint_docker
language: docker_image
files: \.(md|mdown|markdown)$
entry: markdownlint/markdownlint
args: ["-s", ".markdownlint.rb"]
# Prevent secrets entering the repo
# Exclude files:
# - ./README.md
# - *.lock
- repo: https://github.com/Yelp/detect-secrets
rev: v1.5.0
hooks:
- id: detect-secrets
exclude: (^README\.md|\.lock|\.ipynb)$
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment