Skip to content

Commit 79ac02b

Browse files
committed
feat: introduce pre-commit framework
This replaces the custom clang-format script with the pre-commit framework, making it easier to add checks in the future and simplifying GitHub integration. The GH workflow is adapted to run checks now as well. To use it locally, all you need to do is install pre-commit locally, typically via: ``` pip3 install --user pre-commit ``` You can then run `pre-commit run --all` to run it locally. Note that this does _not_ install a Git hook. If you want that as well, run `pre-commit install`. For more details on pre-commit and other installation options, see https://pre-commit.com and https://pre-commit.com/#install
1 parent a179545 commit 79ac02b

File tree

4 files changed

+35
-91
lines changed

4 files changed

+35
-91
lines changed

.github/workflows/pre-commit.yml

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: Pre-commit checks
2+
3+
on:
4+
# Run workflow for PRs.
5+
pull_request:
6+
7+
# Whenever we have a new commit on main, run the workflow for that.
8+
push:
9+
branches: [main]
10+
11+
jobs:
12+
pre-commit:
13+
name: Pre-commit checks
14+
runs-on: ubuntu-22.04
15+
steps:
16+
- name: Checkout code
17+
uses: actions/checkout@v4
18+
with:
19+
ref: ${{github.event.pull_request.head.sha}}
20+
repository: ${{github.event.pull_request.head.repo.full_name}}
21+
- name: Set up Python
22+
uses: actions/setup-python@v5
23+
with:
24+
python-version: "3.10"
25+
- name: Run pre-commit checks on PR
26+
uses: pre-commit/[email protected]

.github/workflows/verify-code-formatting.yml

-38
This file was deleted.

.pre-commit-config.yaml

+9
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
exclude: 'test/(catch.hpp|tests-main.cpp)'
2+
3+
repos:
4+
- repo: https://github.com/pre-commit/mirrors-clang-format
5+
rev: v18.1.2
6+
hooks:
7+
- id: clang-format
8+
exclude_types: [json]
9+

bin/check-formatting.sh

-53
This file was deleted.

0 commit comments

Comments
 (0)