Skip to content

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

#132 Add Clang-Format and Clang-Tidy checks

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

Workflow file for this run

name: CMake
on:
push:
branches: ["main"]
paths:
- "ports/cpp/**"
- ".github/workflows/*"
pull_request:
branches: ["main"]
paths:
- "ports/cpp/**"
- ".github/workflows/*"
jobs:
build:
strategy:
matrix:
cmake_build_type: [Asan, Release]
runs-on: ubuntu-24.04
steps:
- uses: actions/checkout@v3
- name: Get changed sources
id: changed-sources
uses: tj-actions/changed-files@v44
with:
files: |
ports/cpp/**.cpp
ports/cpp/**.hpp
- name: Install dependencies
run: |
sudo apt update
wget -O - https://apt.llvm.org/llvm-snapshot.gpg.key | apt-key add -
add-apt-repository -y "deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-17 main"
sudo apt install build-essential
sudo apt install clang-format-17 clang-tidy-17
- name: Setup ccache
uses: hendrikmuhs/ccache-action@v1.2
with:
create-symlink: true
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-17 -Werror --dry-run \
--fallback-style=Google --verbose
- name: Configure
working-directory: ${{github.workspace}}/ports/cpp
run: |
mkdir build
cd build
cmake \
-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
if: steps.changed-sources.outputs.any_changed == 'true'
env:
CHANGED_SOURCES: ${{ steps.changed-sources.outputs.all_changed_files }}
working-directory: ${{github.workspace}}/ports/cpp
run: |
for file in ${CHANGED_SOURCES}; do
echo "Running Clang-Tidy on file $file..."
time clang-tidy-17 -p build/compile_commands.json $file
done