135 lines
3.5 KiB
YAML
135 lines
3.5 KiB
YAML
# Pre-commit hooks for UnitForge
|
|
# See https://pre-commit.com for more information
|
|
# See https://pre-commit.com/hooks.html for more hooks
|
|
|
|
repos:
|
|
# yaml-language-server: $schema=https://json.schemastore.org/pre-commit-config.json
|
|
# General hooks
|
|
- repo: https://github.com/pre-commit/pre-commit-hooks
|
|
rev: v4.5.0
|
|
hooks:
|
|
- id: trailing-whitespace
|
|
- id: end-of-file-fixer
|
|
- id: check-yaml
|
|
- id: check-added-large-files
|
|
- id: check-case-conflict
|
|
- id: check-merge-conflict
|
|
- id: check-json
|
|
- id: check-toml
|
|
- id: debug-statements
|
|
- id: requirements-txt-fixer
|
|
|
|
# Python code formatting
|
|
- repo: https://github.com/psf/black
|
|
rev: 23.12.1
|
|
hooks:
|
|
- id: black
|
|
language_version: python3
|
|
args: [--line-length=88]
|
|
|
|
# Import sorting
|
|
- repo: https://github.com/PyCQA/isort
|
|
rev: 5.13.2
|
|
hooks:
|
|
- id: isort
|
|
args: [--profile=black, --line-length=88]
|
|
|
|
# Linting
|
|
- repo: https://github.com/PyCQA/flake8
|
|
rev: 7.0.0
|
|
hooks:
|
|
- id: flake8
|
|
args: ["--max-line-length=88", "--extend-ignore=E203,W503"]
|
|
|
|
# Type checking
|
|
- repo: https://github.com/pre-commit/mirrors-mypy
|
|
rev: v1.8.0
|
|
hooks:
|
|
- id: mypy
|
|
additional_dependencies:
|
|
- types-PyYAML
|
|
- types-requests
|
|
args: [--ignore-missing-imports]
|
|
|
|
# Security scanning
|
|
- repo: https://github.com/PyCQA/bandit
|
|
rev: 1.7.6
|
|
hooks:
|
|
- id: bandit
|
|
args: [-r, backend/]
|
|
exclude: tests/
|
|
|
|
# Dockerfile linting
|
|
- repo: https://github.com/hadolint/hadolint
|
|
rev: v2.12.0
|
|
hooks:
|
|
- id: hadolint-docker
|
|
args: [--ignore, DL3008, --ignore, DL3009]
|
|
|
|
# Shell script linting
|
|
- repo: https://github.com/shellcheck-py/shellcheck-py
|
|
rev: v0.9.0.6
|
|
hooks:
|
|
- id: shellcheck
|
|
args: [-e, SC1091]
|
|
|
|
# YAML formatting
|
|
- repo: https://github.com/pre-commit/mirrors-prettier
|
|
rev: v4.0.0-alpha.8
|
|
hooks:
|
|
- id: prettier
|
|
types: [yaml]
|
|
exclude: \.github/
|
|
|
|
# Local hooks for project-specific checks
|
|
- repo: local
|
|
hooks:
|
|
- id: pytest-check
|
|
name: pytest-check
|
|
entry: uv run pytest tests/ --tb=short
|
|
language: system
|
|
pass_filenames: false
|
|
always_run: true
|
|
stages: [pre-commit]
|
|
|
|
- id: unitforge-cli-check
|
|
name: unitforge-cli-check
|
|
entry: bash -c 'source .venv/bin/activate 2>/dev/null || true; ./unitforge-cli --help >/dev/null'
|
|
language: system
|
|
pass_filenames: false
|
|
always_run: true
|
|
stages: [pre-commit]
|
|
|
|
- id: check-systemd-templates
|
|
name: check-systemd-templates
|
|
entry: |
|
|
python -c "
|
|
import sys
|
|
sys.path.insert(0, 'backend')
|
|
from app.core.templates import template_registry
|
|
templates = template_registry.list_templates()
|
|
print(f'✓ Found {len(templates)} valid templates')
|
|
for t in templates:
|
|
print(f' - {t.name} ({t.unit_type.value})')
|
|
"
|
|
language: system
|
|
pass_filenames: false
|
|
always_run: true
|
|
stages: [pre-commit]
|
|
|
|
# Configuration
|
|
default_language_version:
|
|
python: python3
|
|
|
|
ci:
|
|
autofix_commit_msg: |
|
|
[pre-commit.ci] auto fixes from pre-commit.com 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: []
|
|
submodules: false
|