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

chore: Add pre-commit config #878

Open
wants to merge 4 commits into
base: main
Choose a base branch
from
Open
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
2 changes: 1 addition & 1 deletion .clang-format
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ AllowShortLoopsOnASingleLine: false
PointerAlignment: Left
ColumnLimit: 80
AccessModifierOffset: 0
KeepEmptyLinesAtTheStartOfBlocks: true
KeepEmptyLinesAtTheStartOfBlocks: true
4 changes: 2 additions & 2 deletions .github/check_format.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ if ! [ -z $CI ] || ! [ -z $GITHUB_ACTIONS ]; then
cp --parents $f changed
done
fi

echo "clang-format done"

set +e
git diff --exit-code --stat -- ${INCLUDE_DIRS[@]/#/:/}
result=$?
Expand Down
36 changes: 20 additions & 16 deletions .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,23 +12,27 @@ on:
- main

jobs:
clang-format:
lint:
runs-on: ubuntu-latest
container: ghcr.io/acts-project/format10:v11
env:
PRE_COMMIT_HOME: '/tmp/pre-commit'

steps:
- uses: actions/checkout@v4
- name: Check
run: .github/check_format.sh .
- uses: actions/upload-artifact@v4
niermann999 marked this conversation as resolved.
Show resolved Hide resolved
if: failure()
- name: Checkout
uses: actions/checkout@v4

- uses: actions/setup-python@v5
with:
name: changed
path: changed
black:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: psf/black@stable
python-version: '3.12'

- uses: actions/cache@v4
with:
options: "--check --verbose"
src: "${{ github.workspace }}/tests/tools/python"
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
37 changes: 37 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
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)$

- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.2.0
hooks:
- id: trailing-whitespace
exclude: \.(diff|patch)$
- id: end-of-file-fixer
exclude: \.(diff|patch)$
- id: check-yaml
- id: check-added-large-files


# Using this mirror lets us use mypyc-compiled black, which is about 2x faster
- repo: https://github.com/psf/black-pre-commit-mirror
rev: 24.4.2
hooks:
- id: black-jupyter

- repo: https://github.com/BlankSpruce/gersemi
rev: 0.15.0
hooks:
- id: gersemi
args: ["-i", "--no-warn-about-unknown-commands"]

- repo: local
hooks:
- id: leftover_conflict_markers
name: Leftover conflict markers
language: system
entry: git diff --staged --check
Loading
Loading