Skip to content

Commit

Permalink
Add ClangFormat and pre-commit support files (#854)
Browse files Browse the repository at this point in the history
* add '.clang-format', '.pre-commit-config.yaml' and '.git-blame-ignore-revs* files
* CI: add ClangFormat Check
  • Loading branch information
nilason committed Jan 30, 2023
1 parent cac8d9d commit 86e66db
Show file tree
Hide file tree
Showing 4 changed files with 93 additions and 0 deletions.
30 changes: 30 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
---
BasedOnStyle: LLVM
IndentWidth: 4
---
Language: Cpp
AccessModifierOffset: -4
AlignConsecutiveMacros:
Enabled: true
AcrossEmptyLines: true
AcrossComments: true
PadOperators: true
AlignEscapedNewlines: Left
AllowShortFunctionsOnASingleLine: InlineOnly
AlwaysBreakTemplateDeclarations: Yes
BreakBeforeBraces: Stroustrup
ForEachMacros:
- DGL_FOREACH_NODE
- DGL_FOREACH_EDGE
- BOOST_FOREACH
IfMacros:
- SORT_DEBUG
MacroBlockBegin: GNO_BEGIN
MacroBlockEnd: GNO_END
SortIncludes: Never
---
Language: ObjC
---
Language: JavaScript
---
Language: Json
2 changes: 2 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
5fb6b1a969e72db28df78483d3360b15a17f0c68
cac8d9d848299297977d1315b7e90cc3f7698730
19 changes: 19 additions & 0 deletions .github/workflows/clang-format-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
name: ClangFormat Check

on:
push:
branches:
- grass*
pull_request:
jobs:
formatting-check:
name: Formatting Check
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Run clang-format style check for C/C++/Protobuf programs.
uses: jidicula/clang-format-action@v4.10.1
with:
clang-format-version: '15'
check-path: .
42 changes: 42 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
---
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
- id: trailing-whitespace
exclude: |
(?x)^(
.*\.ascii$|
.*\.ref$|
.*\.diff$|
.*\.rtf$|
.*\.kate-swp$|
.*\.svg$
)
- id: end-of-file-fixer
exclude: |
(?x)^(
.*\.ascii$|
.*\.ref$|
.*\.diff$|
.*\.rtf$|
.*\.kate-swp$|
.*\.svg$
)
- repo: https://github.com/igorshubovych/markdownlint-cli
rev: v0.33.0
hooks:
- id: markdownlint
- repo: https://github.com/psf/black
rev: 22.3.0
hooks:
- id: black
- repo: https://github.com/pycqa/flake8
rev: 3.9.2
hooks:
- id: flake8
- repo: https://github.com/pre-commit/mirrors-clang-format
rev: v15.0.6
hooks:
- id: clang-format
types_or: [c, c++, javascript, json, objective-c]

0 comments on commit 86e66db

Please sign in to comment.