|
| 1 | +# Pre-commit hooks for F5 XC API Spec Validation Framework |
| 2 | +# See https://pre-commit.com for more information |
| 3 | +# Run: pre-commit install && pre-commit run --all-files |
| 4 | + |
| 5 | +default_install_hook_types: [pre-commit, commit-msg] |
| 6 | +default_stages: [pre-commit] |
| 7 | + |
| 8 | +repos: |
| 9 | + # ============================================================================= |
| 10 | + # General File Hygiene & Unix Standards |
| 11 | + # ============================================================================= |
| 12 | + - repo: https://github.com/pre-commit/pre-commit-hooks |
| 13 | + rev: v5.0.0 |
| 14 | + hooks: |
| 15 | + # Whitespace & Line Endings |
| 16 | + - id: trailing-whitespace |
| 17 | + args: [--markdown-linebreak-ext=md] |
| 18 | + - id: end-of-file-fixer |
| 19 | + - id: mixed-line-ending |
| 20 | + args: [--fix=lf] |
| 21 | + - id: fix-byte-order-marker |
| 22 | + |
| 23 | + # File Validation |
| 24 | + - id: check-yaml |
| 25 | + args: [--unsafe] |
| 26 | + - id: check-json |
| 27 | + - id: check-toml |
| 28 | + - id: check-xml |
| 29 | + - id: check-ast |
| 30 | + - id: check-executables-have-shebangs |
| 31 | + - id: check-shebang-scripts-are-executable |
| 32 | + |
| 33 | + # Git Safety |
| 34 | + - id: check-merge-conflict |
| 35 | + - id: check-case-conflict |
| 36 | + - id: check-added-large-files |
| 37 | + args: [--maxkb=1000] |
| 38 | + - id: no-commit-to-branch |
| 39 | + args: [--branch, main, --branch, master] |
| 40 | + |
| 41 | + # Security - Private Keys |
| 42 | + - id: detect-private-key |
| 43 | + |
| 44 | + # Python Specific |
| 45 | + - id: check-docstring-first |
| 46 | + - id: debug-statements |
| 47 | + - id: name-tests-test |
| 48 | + args: [--pytest-test-first] |
| 49 | + - id: requirements-txt-fixer |
| 50 | + |
| 51 | + # ============================================================================= |
| 52 | + # Python Linting & Formatting (Ruff - Fast, All-in-One) |
| 53 | + # ============================================================================= |
| 54 | + - repo: https://github.com/astral-sh/ruff-pre-commit |
| 55 | + rev: v0.9.4 |
| 56 | + hooks: |
| 57 | + # Linter with auto-fix |
| 58 | + - id: ruff |
| 59 | + name: ruff (lint + fix) |
| 60 | + args: [--fix, --exit-non-zero-on-fix] |
| 61 | + types_or: [python, pyi] |
| 62 | + # Formatter |
| 63 | + - id: ruff-format |
| 64 | + name: ruff (format) |
| 65 | + types_or: [python, pyi] |
| 66 | + |
| 67 | + # ============================================================================= |
| 68 | + # Python Type Checking |
| 69 | + # ============================================================================= |
| 70 | + - repo: https://github.com/pre-commit/mirrors-mypy |
| 71 | + rev: v1.14.1 |
| 72 | + hooks: |
| 73 | + - id: mypy |
| 74 | + name: mypy (type check) |
| 75 | + additional_dependencies: |
| 76 | + - types-requests>=2.32.0 |
| 77 | + - types-PyYAML>=6.0.0 |
| 78 | + args: |
| 79 | + - --ignore-missing-imports |
| 80 | + - --no-error-summary |
| 81 | + - --disable-error-code=no-any-return |
| 82 | + - --disable-error-code=assignment |
| 83 | + - --disable-error-code=attr-defined |
| 84 | + - --disable-error-code=arg-type |
| 85 | + - --disable-error-code=return-value |
| 86 | + - --disable-error-code=misc |
| 87 | + - --disable-error-code=index |
| 88 | + exclude: ^tests/ |
| 89 | + |
| 90 | + # ============================================================================= |
| 91 | + # Python Security Scanning |
| 92 | + # ============================================================================= |
| 93 | + - repo: https://github.com/PyCQA/bandit |
| 94 | + rev: 1.8.2 |
| 95 | + hooks: |
| 96 | + - id: bandit |
| 97 | + name: bandit (security scan) |
| 98 | + args: [-c, pyproject.toml, -r, scripts/] |
| 99 | + additional_dependencies: ["bandit[toml]"] |
| 100 | + |
| 101 | + # ============================================================================= |
| 102 | + # Secret Detection (Gitleaks) |
| 103 | + # ============================================================================= |
| 104 | + - repo: https://github.com/gitleaks/gitleaks |
| 105 | + rev: v8.22.1 |
| 106 | + hooks: |
| 107 | + - id: gitleaks |
| 108 | + name: gitleaks (secret detection) |
| 109 | + |
| 110 | + # ============================================================================= |
| 111 | + # Shell Script Analysis |
| 112 | + # ============================================================================= |
| 113 | + - repo: https://github.com/shellcheck-py/shellcheck-py |
| 114 | + rev: v0.10.0.1 |
| 115 | + hooks: |
| 116 | + - id: shellcheck |
| 117 | + name: shellcheck (shell lint) |
| 118 | + args: [--severity=warning] |
| 119 | + |
| 120 | + # ============================================================================= |
| 121 | + # YAML Linting |
| 122 | + # ============================================================================= |
| 123 | + - repo: https://github.com/adrienverge/yamllint |
| 124 | + rev: v1.35.1 |
| 125 | + hooks: |
| 126 | + - id: yamllint |
| 127 | + name: yamllint (YAML lint) |
| 128 | + args: [-c, .yamllint.yaml] |
| 129 | + |
| 130 | + # ============================================================================= |
| 131 | + # Markdown Linting |
| 132 | + # ============================================================================= |
| 133 | + - repo: https://github.com/DavidAnson/markdownlint-cli2 |
| 134 | + rev: v0.17.2 |
| 135 | + hooks: |
| 136 | + - id: markdownlint-cli2 |
| 137 | + name: markdownlint (Markdown lint) |
| 138 | + |
| 139 | + # ============================================================================= |
| 140 | + # GitHub Actions Linting |
| 141 | + # ============================================================================= |
| 142 | + - repo: https://github.com/rhysd/actionlint |
| 143 | + rev: v1.7.6 |
| 144 | + hooks: |
| 145 | + - id: actionlint |
| 146 | + name: actionlint (GitHub Actions lint) |
| 147 | + args: [-shellcheck=] # Disable shellcheck integration (too noisy) |
| 148 | + |
| 149 | + # ============================================================================= |
| 150 | + # JSON Formatting |
| 151 | + # ============================================================================= |
| 152 | + - repo: https://github.com/pre-commit/pre-commit-hooks |
| 153 | + rev: v5.0.0 |
| 154 | + hooks: |
| 155 | + - id: pretty-format-json |
| 156 | + name: pretty-format-json |
| 157 | + args: [--autofix, --no-sort-keys, --indent=2] |
| 158 | + exclude: | |
| 159 | + (?x)^( |
| 160 | + specs/.*| |
| 161 | + release/.* |
| 162 | + )$ |
| 163 | +
|
| 164 | + # ============================================================================= |
| 165 | + # Pyproject.toml Validation |
| 166 | + # ============================================================================= |
| 167 | + - repo: https://github.com/abravalheri/validate-pyproject |
| 168 | + rev: v0.23 |
| 169 | + hooks: |
| 170 | + - id: validate-pyproject |
| 171 | + name: validate-pyproject |
| 172 | + |
| 173 | + # ============================================================================= |
| 174 | + # Typo Detection |
| 175 | + # ============================================================================= |
| 176 | + - repo: https://github.com/crate-ci/typos |
| 177 | + rev: v1.29.4 |
| 178 | + hooks: |
| 179 | + - id: typos |
| 180 | + name: typos (spell check) |
| 181 | + args: [--force-exclude] |
| 182 | + exclude: | |
| 183 | + (?x)^( |
| 184 | + \.git/.*| |
| 185 | + specs/.*| |
| 186 | + release/.* |
| 187 | + )$ |
| 188 | +
|
| 189 | + # ============================================================================= |
| 190 | + # Commit Message Linting |
| 191 | + # ============================================================================= |
| 192 | + - repo: https://github.com/commitizen-tools/commitizen |
| 193 | + rev: v4.2.2 |
| 194 | + hooks: |
| 195 | + - id: commitizen |
| 196 | + name: commitizen (commit message lint) |
| 197 | + stages: [commit-msg] |
| 198 | + |
| 199 | +# CI Configuration |
| 200 | +ci: |
| 201 | + autofix_commit_msg: | |
| 202 | + [pre-commit.ci] auto fixes from pre-commit.com hooks |
| 203 | +
|
| 204 | + for more information, see https://pre-commit.ci |
| 205 | + autofix_prs: true |
| 206 | + autoupdate_branch: '' |
| 207 | + autoupdate_commit_msg: '[pre-commit.ci] pre-commit autoupdate' |
| 208 | + autoupdate_schedule: weekly |
| 209 | + skip: [mypy, actionlint] # Skip hooks that need additional setup in CI |
| 210 | + submodules: false |
0 commit comments