Skip to content

Commit

Permalink
Fixes # 660 - Add pre-commit hooks and clang-format check
Browse files Browse the repository at this point in the history
  • Loading branch information
jiridanek committed Aug 5, 2022
1 parent ed76bea commit 59c6921
Show file tree
Hide file tree
Showing 5 changed files with 774 additions and 0 deletions.
31 changes: 31 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -588,6 +588,37 @@ jobs:
path: |
**/coredump*
clang-format:
name: 'clang-format (${{ matrix.os }})'
runs-on: '${{ matrix.os }}'
strategy:
matrix:
os: [ 'ubuntu-20.04' ]

env:
FORCE_COLOR: 1
COLUMNS: 160

steps:

- uses: actions/checkout@v3
with:
fetch-depth: 0

- name: Install clang-format
run: python3 -m pip install clang-format

- name: Perform clang-format check
run: |
set -o pipefail
scripts/git-clang-format origin/main --diff | tee clang-format.patch
- name: Upload the proposed patch to Artifacts
if: ${{ failure() }}
uses: actions/upload-artifact@v3
with:
path: clang-format.patch

python:
name: 'Python Checker (${{ matrix.os }})'
runs-on: '${{ matrix.os }}'
Expand Down
33 changes: 33 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#
# Licensed to the Apache Software Foundation (ASF) under one
# or more contributor license agreements. See the NOTICE file
# distributed with this work for additional information
# regarding copyright ownership. The ASF licenses this file
# to you under the Apache License, Version 2.0 (the
# "License"); you may not use this file except in compliance
# with the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing,
# software distributed under the License is distributed on an
# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
# KIND, either express or implied. See the License for the
# specific language governing permissions and limitations
# under the License.
#

# See https://pre-commit.com for more information
# See https://pre-commit.com/hooks.html for more hooks
repos:
# https://betterprogramming.pub/2-use-cases-of-python-pre-commit-hooks-to-tidy-up-your-git-repositories-8d86c9c4f06b
- repo: local
hooks:
- id: git_clang-format
name: git clang-format
types_or: [c, c++]
stages: [commit]
language: python
entry: scripts/git_clang-format_hook.sh
additional_dependencies: [clang-format]

2 changes: 2 additions & 0 deletions requirements-dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@

--prefer-binary

pre-commit

setuptools
virtualenv
wheel
Expand Down
Loading

0 comments on commit 59c6921

Please sign in to comment.