Skip to content

Commit 236083a

Browse files
committed
feat: add minimal pre-commit infrastructure
- Add pre-commit configuration with essential checks only - Check YAML, TOML, JSON syntax - Check for merge conflicts and large files - Enforce LF line endings (fix 2 test files with CRLF) - Add debug statement detection - Integrate ruff for Python formatting and linting - Add GitHub workflow for pre-commit CI - No unnecessary Python code changes
1 parent 7bc3dfd commit 236083a

4 files changed

Lines changed: 21541 additions & 2569 deletions

File tree

.github/workflows/pre-commit.yml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
name: Pre-commit
2+
3+
on:
4+
pull_request:
5+
push:
6+
branches: [main]
7+
8+
jobs:
9+
pre-commit:
10+
runs-on: ubuntu-latest
11+
steps:
12+
- uses: actions/checkout@v5
13+
- uses: actions/setup-python@v5
14+
with:
15+
python-version: '3.12'
16+
- uses: pre-commit/action@v3.0.1

.pre-commit-config.yaml

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
# Pre-commit hooks for Buttercup CRS
2+
# See https://pre-commit.com for more information
3+
4+
repos:
5+
# Standard file fixes
6+
- repo: https://github.com/pre-commit/pre-commit-hooks
7+
rev: v5.0.0
8+
hooks:
9+
- id: check-yaml
10+
args: [--allow-multiple-documents]
11+
exclude: 'deployment/k8s/.*\.(yaml|yml)$'
12+
- id: check-added-large-files
13+
args: [--maxkb=1000]
14+
- id: check-merge-conflict
15+
- id: mixed-line-ending
16+
args: [--fix=lf]
17+
- id: check-toml
18+
- id: check-json
19+
- id: debug-statements
20+
21+
# Ruff - Python linting and formatting
22+
- repo: https://github.com/astral-sh/ruff-pre-commit
23+
rev: v0.12.0
24+
hooks:
25+
# Run the formatter first
26+
- id: ruff-format
27+
types_or: [python, pyi]
28+
29+
# Then run the linter with auto-fix
30+
- id: ruff
31+
types_or: [python, pyi]
32+
args: [--fix, --exit-non-zero-on-fix]
33+
34+
# Global exclusions for files that should never be checked
35+
exclude: |
36+
(?x)^(
37+
external/.*|
38+
.*\.pb\.py|
39+
.*_pb2\.py|
40+
.*_pb2_grpc\.py|
41+
.*/\.venv/.*|
42+
.*/\.mypy_cache/.*|
43+
.*/\.ruff_cache/.*|
44+
.*/\.pytest_cache/.*|
45+
__pycache__/.*|
46+
.*\.egg-info/.*
47+
)$
48+
49+
# Configuration
50+
fail_fast: false
51+
ci:
52+
autofix_prs: true
53+
autoupdate_schedule: weekly

0 commit comments

Comments
 (0)