From 9f230f5b28f8e753a199118e9bb16f4c864d3d2c Mon Sep 17 00:00:00 2001 From: matlabbe Date: Sat, 16 Mar 2024 20:26:56 -0700 Subject: [PATCH] Adding pre-commit checks --- .github/workflows/pre-commit.yml | 25 +++++++++++++++++++++++++ .pre-commit-config.yaml | 31 +++++++++++++++++++++++++++++++ 2 files changed, 56 insertions(+) create mode 100644 .github/workflows/pre-commit.yml create mode 100644 .pre-commit-config.yaml diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml new file mode 100644 index 00000000..e2ecaf5c --- /dev/null +++ b/.github/workflows/pre-commit.yml @@ -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 diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 00000000..15ee089b --- /dev/null +++ b/.pre-commit-config.yaml @@ -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"] +