Skip to content

Commit

Permalink
Fixes #660 - Add pre-commit hooks and clang-format check (#663)
Browse files Browse the repository at this point in the history
  • Loading branch information
jiridanek authored Aug 5, 2022
1 parent ed76bea commit efc9bbd
Show file tree
Hide file tree
Showing 7 changed files with 769 additions and 1 deletion.
32 changes: 32 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -588,6 +588,38 @@ 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:
name: clang-format_patch
path: clang-format.patch

python:
name: 'Python Checker (${{ matrix.os }})'
runs-on: '${{ matrix.os }}'
Expand Down
32 changes: 32 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
#
# 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]
18 changes: 17 additions & 1 deletion README.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,23 @@ python3 -m pip install --user --upgrade pip
python3 -m pip install --user -r ./requirements-dev.txt
----

==== Description of the individual dependencies

== Development

=== git pre-commit hook

This project uses the https://github.com/pre-commit/pre-commit[pre-commit] git hook management framework.

.Install and activate pre-commit (Fedora)
[source, shell script]
----
$ dnf install pre-commit
$ pre-commit install
----

Read this https://www.redhat.com/sysadmin/git-hooks[git hooks article] on redhat.com (as well as documentation for pre-commit) to learn more.

=== Description of the individual test-only dependencies

The HTTP2 system tests (`tests/system_tests_http2.py`) use the Python Quart and hyper-h2 frameworks to start a HTTP2 server.
The HTTP2 system tests only runs if
Expand Down
1 change: 1 addition & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,7 @@
<exclude>**/cpp-stub/*</exclude>
<exclude>**/*_pb2*</exclude>
<exclude>share/index.html</exclude>
<exclude>scripts/git-clang-format</exclude>
</excludes>
</configuration>
</plugin>
Expand Down
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 efc9bbd

Please sign in to comment.