Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#132 Add Clang-Format and Clang-Tidy checks #137

Merged
merged 5 commits into from
Jul 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 26 additions & 3 deletions .github/workflows/cmake.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,18 +17,32 @@ jobs:
strategy:
matrix:
cmake_build_type: [Asan, Release]
runs-on: ubuntu-latest
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v3
- name: Checkout
uses: actions/checkout@v3

- name: Install dependencies
run: |
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add -
sudo add-apt-repository "deb http://apt.llvm.org/noble/ llvm-toolchain-noble-18 main"
sudo apt update
sudo apt install build-essential
sudo apt install clang-format-18 clang-tidy-18

- name: Setup ccache
uses: hendrikmuhs/[email protected]
with:
create-symlink: true
key: ${{ github.job }}-${{ matrix.os }}
key: ${{ github.job }}-${{ matrix.cmake_build_type }}

- name: Clang-Format
working-directory: ${{github.workspace}}/ports/cpp
run: |
find source test -iname '*.hpp' -o -iname '*.cpp' \
| xargs clang-format-18 -Werror --dry-run \
--fallback-style=Google --verbose

- name: Configure
working-directory: ${{github.workspace}}/ports/cpp
run: |
Expand All @@ -38,11 +52,20 @@ jobs:
-DANTLR4C3_DEVELOPER=ON \
-DCMAKE_BUILD_TYPE=${{ matrix.cmake_build_type }} \
..

- name: Build
working-directory: ${{github.workspace}}/ports/cpp/build
run: make

- name: Unit Test
working-directory: ${{github.workspace}}/ports/cpp/build/test
run: |
ctest
cat Testing/Temporary/LastTest.log

- name: Clang-Tidy on sources
if: matrix.cmake_build_type == 'Release'
working-directory: ${{github.workspace}}/ports/cpp
run: |
find source -iname '*.hpp' -o -iname '*.cpp' \
| xargs clang-tidy-18 -p build/compile_commands.json
17 changes: 17 additions & 0 deletions ports/cpp/.clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
Language: Cpp
BasedOnStyle: Google

ColumnLimit: 100
AccessModifierOffset: -2

AllowShortFunctionsOnASingleLine: None
AllowShortIfStatementsOnASingleLine: false
AllowShortLoopsOnASingleLine: false

DerivePointerAlignment: false
BreakConstructorInitializers: BeforeComma
AlignAfterOpenBracket: BlockIndent

BinPackArguments: false
BinPackParameters: false
22 changes: 22 additions & 0 deletions ports/cpp/.clang-tidy
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
---
Checks: '-*,
bugprone-*,
cert-*,
concurrency-*,
cppcoreguidelines-*,
google-*,
hicpp-*,
misc-*,
-misc-no-recursion,
modernize-*,
-modernize-use-trailing-return-type,
performance-*,
readability-*'
WarningsAsErrors: '*'
HeaderFileExtensions:
- hpp
ImplementationFileExtensions:
- cpp
HeaderFilterRegex: ''
FormatStyle: '.clang-format'
SystemHeaders: false
Loading
Loading