Skip to content

Commit

Permalink
feat: introduce pre-commit framework
Browse files Browse the repository at this point in the history
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
  • Loading branch information
ahans committed Apr 9, 2024
1 parent 38eaa89 commit d38c023
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 91 deletions.
26 changes: 26 additions & 0 deletions .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Pre-commit checks

on:
# Run workflow for PRs.
pull_request:

# Whenever we have a new commit on main, run the workflow for that.
push:
branches: [main]

jobs:
pre-commit:
name: Pre-commit checks
runs-on: ubuntu-22.04
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: ${{github.event.pull_request.head.sha}}
repository: ${{github.event.pull_request.head.repo.full_name}}
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: "3.10"
- name: Run pre-commit checks on PR
uses: pre-commit/[email protected]
38 changes: 0 additions & 38 deletions .github/workflows/verify-code-formatting.yml

This file was deleted.

9 changes: 9 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
exclude: 'test/(catch.hpp|tests-main.cpp)'

repos:
- repo: https://github.com/pre-commit/mirrors-clang-format
rev: v18.1.2
hooks:
- id: clang-format
exclude_types: [json]

53 changes: 0 additions & 53 deletions bin/check-formatting.sh

This file was deleted.

0 comments on commit d38c023

Please sign in to comment.