Skip to content

Commit

Permalink
ci: Create clang-tidy to CI
Browse files Browse the repository at this point in the history
  • Loading branch information
wow2006 committed Jan 30, 2025
1 parent fe05b35 commit d2e4333
Show file tree
Hide file tree
Showing 2 changed files with 58 additions and 2 deletions.
56 changes: 56 additions & 0 deletions .github/workflows/clang-tidy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: clang-tidy

on:
push:
branches: ["main"]
pull_request:
branches: ["main"]

jobs:
clang-tidy:
runs-on: ubuntu-24.04
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
submodules: "true"

- name: Get tags
run: git fetch --tags origin

- name: Install dependencies
run: sudo apt install -y build-essential cmake qtbase5-dev libqt5svg5-dev python3-pip grep make

- name: Install conan2
run: |
python3 -m venv venv
source venv/bin/activate
pip install conan
- name: Cache Conan packages (Ubuntu)
if: runner.os == 'Linux'
uses: actions/cache@v2
with:
path: ~/.conan2
key: conan-ubuntu-24.04-gnu-${{ hashFiles('**/conanfile.txt') }}

- name: Cache Conan packages
uses: actions/cache@v2
with:
path: ~/.conan2
key: conan-ubuntu-24.04-gnu-${{ hashFiles('**/conanfile.txt') }}

- name: Configure CMake
run: cmake -B build -DCMAKE_C_COMPILER=gcc -DCMAKE_CXX_COMPILER=g++ -DCMAKE_BUILD_TYPE=Release -DCMAKE_TOOLCHAIN_FILE=".conan/gcc/build/Release/generators/conan_toolchain.cmake" .

- name: Run clang-tidy
run: |
FILES=$(git diff --name-only origin/main | grep -E '\.(cpp|h|hpp)$')
if [ -n "$FILES" ]; then
clang-tidy \
-p ${{ github.workspace }}/build/compile_commands.json \
--config-file=.clang-tidy \
--quiet \
--format-style=file \
"$FILES"
fi
4 changes: 2 additions & 2 deletions CMakePresets.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"version": 5,
"version": 4,
"cmakeMinimumRequired": {
"major": 3,
"minor": 23,
Expand Down Expand Up @@ -126,4 +126,4 @@
]
}
]
}
}

0 comments on commit d2e4333

Please sign in to comment.