forked from SpanPanel/span
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.pre-commit-config.yaml
More file actions
140 lines (130 loc) · 4.67 KB
/
.pre-commit-config.yaml
File metadata and controls
140 lines (130 loc) · 4.67 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
repos:
# Pre-commit hooks for essential file checks only
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
hooks:
- id: check-yaml
exclude: '\..*_cache/.*|dist/.*|venv/.*'
- id: check-toml
exclude: '\..*_cache/.*|dist/.*|venv/.*'
- id: check-json
exclude: '\..*_cache/.*|dist/.*|venv/.*'
- id: check-added-large-files
- id: check-merge-conflict
exclude: '\..*_cache/.*|dist/.*|venv/.*'
- id: debug-statements
exclude: '^tests/.*|\..*_cache/.*|dist/.*|venv/.*'
- id: trailing-whitespace
exclude: '\..*_cache/.*|dist/.*|venv/.*'
- id: end-of-file-fixer
exclude: '\..*_cache/.*|dist/.*|venv/.*'
- id: mixed-line-ending
args: ['--fix=lf']
exclude: '\..*_cache/.*|dist/.*|venv/.*'
# Pylint check for import-outside-toplevel (run before ruff)
- repo: local
hooks:
- id: pylint-import-check
name: pylint import-outside-toplevel check
entry: poetry run pylint
language: system
args: ['--disable=all', '--enable=import-outside-toplevel', '--score=no', 'custom_components/span_panel/']
pass_filenames: false
files: \.py$
exclude: '^tests/.*|^scripts/.*'
# Ruff for linting, import sorting, and primary formatting
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.11.13
hooks:
- id: ruff-format
exclude: '^tests/.*|scripts/.*|\..*_cache/.*|dist/.*|venv/.*'
- id: ruff-check
args: ['--fix']
exclude: '^tests/.*|scripts/.*|\..*_cache/.*|dist/.*|venv/.*'
# MyPy for type checking
- repo: https://github.com/pre-commit/mirrors-mypy
rev: v1.16.0
hooks:
- id: mypy
additional_dependencies:
- httpx
- pydantic
- typing-extensions
- pytest
- homeassistant-stubs
- types-PyYAML
- types-aiofiles
args: ['--config-file=pyproject.toml']
exclude: '^tests/.*|^scripts/.*|docs/.*|\..*_cache/.*|dist/.*|venv/.*'
# Markdownlint for markdown files
- repo: https://github.com/DavidAnson/markdownlint-cli2
rev: v0.18.1
hooks:
- id: markdownlint-cli2
args: ['--config', '.markdownlint-cli2.jsonc']
exclude: '\..*_cache/.*|dist/.*|venv/.*|\.venv/.*|node_modules/.*|htmlcov/.*|tests/.*'
# Markdown formatting using shared script (local only)
- repo: local
hooks:
- id: markdown-format
name: Format markdown files
entry: scripts/fix-markdown.sh
language: system
args: [.]
types: [markdown]
pass_filenames: false
always_run: true
stages: [manual]
# Check for common security issues
- repo: https://github.com/PyCQA/bandit
rev: 1.8.3
hooks:
- id: bandit
args: ['-c', 'pyproject.toml']
additional_dependencies: ['bandit[toml]']
exclude: '^tests/.*|^scripts/.*|\..*_cache/.*|dist/.*|venv/.*'
# Poetry check for pyproject.toml validation
- repo: https://github.com/python-poetry/poetry
rev: 2.1.3
hooks:
- id: poetry-check
- id: poetry-lock
# Radon for code metrics and maintainability (local)
- repo: local
hooks:
- id: radon-complexity
name: radon complexity check
entry: poetry run radon
language: system
args: ['cc', '--min=B', '--show-complexity', 'custom_components/span_panel/']
pass_filenames: false
files: \.py$
- id: radon-maintainability
name: radon maintainability index
entry: poetry run radon
language: system
args: ['mi', '--min=B', '--show', 'custom_components/span_panel/']
pass_filenames: false
files: \.py$
# Coverage check with pytest output and coverage report
- repo: local
hooks:
- id: pytest-cov-summary
name: coverage summary
entry: bash
language: system
args: ['-c', 'echo "Running tests with coverage..."; poetry run pytest tests/ --cov=custom_components/span_panel --cov-config=pyproject.toml --cov-report=term-missing:skip-covered -v; exit_code=$?; echo; if [ $exit_code -eq 0 ]; then echo "✅ Tests passed with coverage report above"; else echo "❌ Tests failed"; fi; exit $exit_code']
pass_filenames: false
always_run: true
verbose: true
# Sync dependencies from manifest.json to CI workflow (run last)
- repo: local
hooks:
- id: sync-dependencies
name: sync dependency versions between manifest.json and CI workflow
entry: python scripts/sync-dependencies.py
language: system
pass_filenames: false
always_run: true
stages: [pre-commit]
verbose: true