diff --git a/.github/workflows/precommit.yml b/.github/workflows/precommit.yml new file mode 100644 index 000000000..bf2c1a7f1 --- /dev/null +++ b/.github/workflows/precommit.yml @@ -0,0 +1,15 @@ +name: pre-commit +on: [pull_request] +jobs: + precommit: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + - uses: actions/setup-python@v4 + with: + python-version: 3.x + - uses: pre-commit/action@v3.0.1 + with: + extra_args: "--from-ref ${{ github.event.pull_request.base.sha }} --to-ref ${{ github.event.pull_request.head.sha }}" diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 000000000..83bd08ade --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,34 @@ +exclude: 'clip/.*|third_party/.*' + +repos: + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v5.0.0 + hooks: + - id: end-of-file-fixer + - id: trailing-whitespace + - id: mixed-line-ending + + - repo: https://github.com/Lucas-C/pre-commit-hooks + rev: v1.5.5 + hooks: + - id: remove-tabs + args: [--whitespaces-count, '8'] + exclude: '\.gitmodules' + + - repo: https://github.com/pre-commit/mirrors-clang-format + rev: v19.1.5 + hooks: + - id: clang-format + files: \.(c|h|cpp|hpp|cc|hh|cxx|hxx)$ + types_or: [text] + + - repo: https://github.com/pocc/pre-commit-hooks + rev: v1.3.5 + hooks: + - id: clang-tidy + files: \.(c|h|cpp|hpp|cc|hh|cxx|hxx)$ + args: [--fix, --quiet, --use-color] + types_or: [text] + additional_dependencies: [clang-tidy==19.1.0] + require_serial: true + stages: [manual]