Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move clang-format checks to pre-commit #787

Merged
merged 1 commit into from
Nov 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 0 additions & 21 deletions .githooks/README.md

This file was deleted.

79 changes: 0 additions & 79 deletions .githooks/pre-commit

This file was deleted.

46 changes: 0 additions & 46 deletions .github/check_format.sh

This file was deleted.

21 changes: 17 additions & 4 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,21 @@ on:
jobs:
format:
runs-on: ubuntu-latest
container: ghcr.io/acts-project/format10:v11
env:
PRE_COMMIT_HOME: '/tmp/pre-commit'

steps:
- uses: actions/checkout@v3
- name: Check
run: .github/check_format.sh .
- name: Checkout
uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.12'
- uses: actions/cache@v4
with:
path: |
${{ env.PRE_COMMIT_HOME }}
key: ${{ runner.os }}-${{ hashFiles('.pre-commit-config.yaml') }}
- name: Install pre-commit
run: pip install pre-commit
- name: Run pre-commit
run: pre-commit run --all-files --show-diff-on-failure
7 changes: 7 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
repos:
- repo: https://github.com/pre-commit/mirrors-clang-format
rev: v10.0.1
hooks:
- id: clang-format
types_or: [file]
files: \.(cpp|hpp|ipp|cu|cuh|sycl|hip)$
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,25 @@ Attaching file performance_track_finding.root as _file0...
root [1] finding_trackeff_vs_eta->Draw()
```

## Contributing

### Code formatting

The traccc code is formatted using clang-format; the recommended way to ensure that your code is properly formatted is to use [pre-commit](https://pre-commit.com/). The pre-commit webpage has a useful guide for using the tool, but the simplest way of using it (without installing it as a pre-commit hook) is as follows. First, install the tool with your favourite Python package manager:

```console
# With pip
$ pip install pre-commit
# With pipx
$ pip install pre-commit
```

The install step needs to be executed only once. After that, the code can be easily formatted as follows:

```console
$ pre-commit run --all-files
```
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be good to mention that pre-commit can made to run as a pre-commit hook but does not by default (despite the name). And that you can enable that for your local git checkout with

$ pre-commit install


## Continuous benchmark

Monitoring the event throughput of track reconstruction with the toy geometry
Expand Down
Loading