forked from sylvester-francis/Resource-Reserver
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path.pre-commit-config.yaml
More file actions
193 lines (160 loc) · 5.47 KB
/
.pre-commit-config.yaml
File metadata and controls
193 lines (160 loc) · 5.47 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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
# Pre-commit configuration for Resource-Reserver
# Runs automatically before each commit to catch issues early
# Documentation: https://pre-commit.com
default_install_hook_types: [pre-commit, post-commit, pre-push]
default_stages: [pre-commit]
repos:
# Python code formatting with ruff
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.11.13
hooks:
# Run the ruff linter
- id: ruff
name: ruff linter (Python)
args: [--fix, --config, apps/backend/pyproject.toml]
types_or: [python]
files: ^apps/backend/.*\.py$
# Run the ruff formatter
- id: ruff-format
name: ruff formatter (Python)
types_or: [python]
args: [--config, apps/backend/pyproject.toml]
files: ^apps/backend/.*\.py$
# Additional Python code quality checks
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v5.0.0
hooks:
- id: check-added-large-files
name: Check for large files
args: ['--maxkb=1000']
- id: check-ast
name: Check Python AST
- id: check-builtin-literals
name: Check builtin type constructor use
- id: check-case-conflict
name: Check for case conflicts
- id: check-docstring-first
name: Check docstring is first
- id: check-executables-have-shebangs
name: Check executables have shebangs
- id: check-json
name: Check JSON files
- id: check-merge-conflict
name: Check for merge conflicts
- id: check-shebang-scripts-are-executable
name: Check shebang scripts are executable
- id: check-toml
name: Check TOML files
- id: check-yaml
name: Check YAML files
args: ['--unsafe'] # Allow custom tags in docker-compose.yml
- id: debug-statements
name: Check for debug statements
- id: detect-private-key
name: Detect private keys
- id: end-of-file-fixer
name: Fix end of files
- id: mixed-line-ending
name: Fix mixed line endings
- id: trailing-whitespace
name: Trim trailing whitespace
args: [--markdown-linebreak-ext=md]
- id: fix-byte-order-marker
name: Fix byte order marker
# Security scanning with bandit
- repo: https://github.com/PyCQA/bandit
rev: 1.8.3
hooks:
- id: bandit
name: bandit (Python security)
args: [-c, apps/backend/pyproject.toml]
additional_dependencies: ["bandit[toml]"]
files: ^apps/backend/(app|cli)/.*\.py$
# Dockerfile linting
- repo: https://github.com/hadolint/hadolint
rev: v2.13.1-beta
hooks:
- id: hadolint-docker
name: hadolint (Dockerfile linting)
# YAML linting
- repo: https://github.com/adrienverge/yamllint
rev: v1.35.1
hooks:
- id: yamllint
name: yamllint (YAML files)
args: [-c=.yamllint.yml]
types: [yaml]
# Shell script linting
- repo: https://github.com/shellcheck-py/shellcheck-py
rev: v0.10.0.1
hooks:
- id: shellcheck
name: shellcheck (shell scripts)
# Markdown linting and formatting
- repo: https://github.com/executablebooks/mdformat
rev: 0.7.19
hooks:
- id: mdformat
name: mdformat (Markdown)
additional_dependencies:
- mdformat-gfm
- mdformat-black
args: [--wrap, "no"]
# Local custom hooks
- repo: local
hooks:
- id: ci-pre-push
name: CI checks (pre-push)
entry: scripts/pre-push-ci.sh
language: system
pass_filenames: false
always_run: true
stages: [pre-push]
# Run pytest on modified test files
- id: pytest-check
name: pytest (Python tests)
entry: bash -c 'source venv/bin/activate && cd apps/backend && pytest --maxfail=1 --tb=short -q'
language: system
pass_filenames: false
always_run: false
files: ^apps/backend/tests/.*\.py$
# Frontend ESLint check
- id: frontend-lint
name: ESLint (Frontend)
entry: bash -c 'cd apps/frontend && bun run lint'
language: system
pass_filenames: false
files: ^apps/frontend/.*\.(ts|tsx|js|jsx)$
# Frontend build check
- id: frontend-build
name: Frontend build check
entry: bash -c 'cd apps/frontend && if command -v bun > /dev/null 2>&1; then bun run build; else npm run build; fi'
language: system
pass_filenames: false
files: ^apps/frontend/.*\.(ts|tsx|js|jsx|css)$
stages: [pre-push]
# Frontend tests
- id: frontend-test
name: Vitest (Frontend tests)
entry: bash -c 'cd apps/frontend && bun run test'
language: system
pass_filenames: false
files: ^apps/frontend/.*\.(ts|tsx)$
# Check that __init__.py files exist in Python packages
- id: check-init-files
name: Check for __init__.py files
entry: bash -c 'find apps/backend/app -name "*.py" | head -1 | xargs dirname | xargs -I{} test -f {}/__init__.py'
language: system
pass_filenames: false
files: ^apps/backend/app/.*\.py$
# CI mode - stricter checks when running in CI/CD
ci:
autofix_commit_msg: |
[pre-commit.ci] auto fixes from pre-commit hooks
for more information, see https://pre-commit.ci
autofix_prs: true
autoupdate_branch: ''
autoupdate_commit_msg: '[pre-commit.ci] pre-commit autoupdate'
autoupdate_schedule: weekly
skip: [pytest-check, frontend-build, hadolint-docker]
submodules: false