diff --git a/.clang-format b/.clang-format new file mode 100644 index 00000000..7d2809d7 --- /dev/null +++ b/.clang-format @@ -0,0 +1,11 @@ +BasedOnStyle: llvm +IndentWidth: 4 +UseTab: Never +BreakBeforeBraces: Linux +SortIncludes: false +IndentCaseLabels: false +AlwaysBreakTemplateDeclarations: true +AllowShortFunctionsOnASingleLine: false +AllowShortCaseLabelsOnASingleLine: true +AllowShortIfStatementsOnASingleLine: true +PointerAlignment: Left diff --git a/.github/workflows/format-checker.yml b/.github/workflows/format-checker.yml new file mode 100644 index 00000000..5705eaf6 --- /dev/null +++ b/.github/workflows/format-checker.yml @@ -0,0 +1,19 @@ +name: clang-format Check +on: [push, pull_request] +jobs: + formatting-check: + name: Formatting Check + runs-on: ubuntu-latest + strategy: + matrix: + path: + - 'src' + - 'libs' + steps: + - uses: actions/checkout@v3 + - name: Run clang-format style check for C/C++/Protobuf programs. + uses: jidicula/clang-format-action@v4.11.0 + with: + clang-format-version: '13' + check-path: ${{ matrix.path }} + fallback-style: 'Mozilla' # optional diff --git a/format.sh b/format.sh new file mode 100644 index 00000000..1dc19c7a --- /dev/null +++ b/format.sh @@ -0,0 +1 @@ +find . -regex '.*\.\(cpp\|hpp\|cc\|cxx\)' -exec clang-format -style=file -i {} \;