-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy path.pre-commit-config.yaml
More file actions
151 lines (137 loc) · 4.82 KB
/
Copy path.pre-commit-config.yaml
File metadata and controls
151 lines (137 loc) · 4.82 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
default_install_hook_types: [pre-commit, commit-msg, pre-push]
default_stages: [pre-commit]
minimum_pre_commit_version: 4.0.0
repos:
# These meta hooks check the pre-commit configuration itself.
- repo: meta
hooks:
- id: check-hooks-apply
- id: check-useless-excludes
# Commitizen enforces semantic and conventional commit messages.
- repo: https://github.com/commitizen-tools/commitizen
rev: 4fbeae7861663ecf4b4989211eba41c1a3fb1227 # frozen: v4.13.9
hooks:
- id: commitizen
name: Check conventional commit message
stages: [commit-msg]
# Enable a whole bunch of useful helper hooks, too.
# See https://pre-commit.com/hooks.html for more hooks.
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: 3e8a8703264a2f4a69428a0aa4dcb512790b2c8c # frozen: v6.0.0
hooks:
- id: check-case-conflict
- id: check-merge-conflict
- id: check-added-large-files
stages: [pre-commit]
args: [--maxkb=500]
- id: end-of-file-fixer
stages: [pre-commit]
- id: trailing-whitespace
args: [--markdown-linebreak-ext=md]
stages: [pre-commit]
- id: detect-private-key
- id: detect-aws-credentials
args: [--allow-missing-credentials]
- id: check-yaml
- id: check-toml
# Check and prettify the configuration files.
- repo: https://github.com/macisamuele/language-formatters-pre-commit-hooks
rev: 4380fbb73a154b5f5624794c1c78d9719ccc860f # frozen: v2.16.0
hooks:
- id: pretty-format-yaml
args: [--autofix]
# Commenting this out because https://github.com/pappasam/toml-sort/issues/11
# - id: pretty-format-toml
# args: [--autofix]
#
# Backend.
#
# Sort imports.
- repo: https://github.com/pycqa/isort
rev: a333737ed43df02b18e6c95477ea1b285b3de15a # frozen: 8.0.1
hooks:
- id: isort
name: Sort import statements
files: ^backend/
args: [--settings-path, backend/develop.toml]
stages: [pre-commit]
# Add Black code formatters.
- repo: https://github.com/ambv/black
rev: c6755bb741b6481d6b3d3bb563c83fa060db96c9 # frozen: 26.3.1
hooks:
- id: black
name: Format code
files: ^backend/
args: [--config, backend/develop.toml]
- repo: https://github.com/asottile/blacken-docs
rev: dda8db18cfc68df532abf33b185ecd12d5b7b326 # frozen: 1.20.0
hooks:
- id: blacken-docs
name: Format code in docstrings
files: ^backend/
types: [text, python]
args: [--line-length, '120']
additional_dependencies: [black==26.3.1]
# Upgrade and rewrite Python idioms.
- repo: https://github.com/asottile/pyupgrade
rev: 75992aaa40730136014f34227e0135f63fc951b4 # frozen: v3.21.2
hooks:
- id: pyupgrade
name: Upgrade code idioms
files: ^backend/src/template_jobs/|^backend/tests/
args: [--py313-plus]
# Similar to pylint, with a few more/different checks. For more available
# extensions: https://github.com/DmytroLitvinov/awesome-flake8-extensions
- repo: https://github.com/pycqa/flake8
rev: d93590f5be797aabb60e3b09f2f52dddb02f349f # frozen: 7.3.0
hooks:
- id: flake8
name: Check flake8 issues
files: ^backend/src/template_jobs/|^backend/tests/
types: [text, python]
additional_dependencies: [flake8-bugbear==25.11.29, flake8-builtins==3.1.0, flake8-comprehensions==3.17.0, flake8-docstrings==1.7.0, flake8-logging==1.8.0, flake8-mutable==1.2.0, flake8-noqa==1.4.0, flake8-print==5.0.0, flake8-pyi==25.5.0, flake8-pytest-style==2.2.0, flake8-rst-docstrings==0.4.0, pep8-naming==0.15.1]
args: [--config, backend/.flake8]
# Run Pylint from the local repo to make sure venv packages
# specified in pyproject.toml are available.
- repo: local
hooks:
- id: pylint
name: Check pylint issues
entry: pylint
language: python
files: ^backend/src/template_jobs/|^backend/tests/
types: [text, python]
args: [--rcfile, backend/develop.toml]
# Type-check all Python code.
- repo: local
hooks:
- id: mypy
name: Check typing annotations
entry: mypy
language: python
files: ^backend/src/template_jobs/|^backend/tests/
types: [text, python]
args: [--config-file, backend/develop.toml]
# Check for potential security issues.
- repo: https://github.com/PyCQA/bandit
rev: 92ae8b82fb422a639f0ed8d99e96cea769594e08 # frozen: 1.9.4
hooks:
- id: bandit
name: Check for security issues
files: ^backend/src/template_jobs/|^backend/tests/
types: [text, python]
args: [--configfile, backend/develop.toml]
additional_dependencies: ['bandit[toml]']
# On push to the remote, run the unit tests.
- repo: local
hooks:
- id: pytest
name: Run unit tests
entry: env COVERAGE_CORE=sysmon pytest -c backend/develop.toml --cov-config backend/develop.toml backend/src/template_jobs/ backend/tests/ backend/docs/
language: python
verbose: true
always_run: true
pass_filenames: false
stages: [pre-push]