Skip to content

Commit

Permalink
Adding pre-commit checks
Browse files Browse the repository at this point in the history
  • Loading branch information
matlabbe committed Mar 17, 2024
1 parent 264c560 commit 9f230f5
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 0 deletions.
25 changes: 25 additions & 0 deletions .github/workflows/pre-commit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
name: pre-commit

on:
pull_request:
push:
branches: [main]

jobs:
pre-commit:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v3
- name: Install pre-commit
run: pip install pre-commit
- name: Run pre-commit
run: pre-commit run --all-files
- name: Check for modified files
run: |
if [[ `git diff --exit-code` ]]; then
echo "Files were changed by cmake-format and/or clang-format:"
git diff
echo "Please run 'pre-commit run --all-files' locally to fix these issues."
exit 1
fi
31 changes: 31 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks

exclude: '^build/|^data/|^app/|^archive/|^cmake_modules/|^\..*'

repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v3.2.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
- id: check-added-large-files

- repo: https://github.com/cheshirekow/cmake-format-precommit
rev: v0.6.10
hooks:
- id: cmake-format
- id: cmake-lint

- repo: https://github.com/pryorda/dockerfilelint-precommit-hooks
rev: v0.1.0
hooks:
- id: dockerfilelint

- repo: https://github.com/pre-commit/mirrors-clang-format
rev: v18.1.1
hooks:
- id: clang-format
args: ["-style=Google", "-i"]

0 comments on commit 9f230f5

Please sign in to comment.