ci: add GitHub action for clang-tidy #10
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: cpp-linter | |
on: | |
pull_request: | |
paths: ['.github/workflows/cpp-linter.yml', '**.c', '**.cpp', '**.h', '**.inl', '**CMakeLists.txt', '**.cmake'] | |
push: | |
branches: [main] | |
paths: ['.github/workflows/cpp-linter.yml', '**.c', '**.cpp', '**.h', '**.inl', '**CMakeLists.txt', '**.cmake'] | |
jobs: | |
cpp-linter: | |
runs-on: ubuntu-24.04 | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4 | |
with: | |
submodules: 'recursive' | |
- name: Install dependencies | |
run: | | |
wget -qO- 'https://apt.llvm.org/llvm-snapshot.gpg.key' | sudo tee /etc/apt/trusted.gpg.d/apt.llvm.org.asc >/dev/null | |
sudo add-apt-repository -y 'deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-18 main' | |
packages=( | |
clang-18 clang-format-18 clang-tidy-18 cmake libopengl-dev libxkbcommon-dev libx11-6 libx11-xcb1 libxcb-glx0 | |
libxcb-icccm4 libxcb-image0 libxcb-keysyms1 libxcb-randr0 libxcb-render-util0 libxcb-render0 libxcb-shape0 | |
libxcb-shm0 libxcb-sync1 libxcb-xfixes0 libxcb-xinput0 libxcb-xkb1 libxcb1 libxkbcommon-x11-0 libxkbcommon0 | |
) | |
sudo apt-get update | |
sudo apt-get install -y "${packages[@]}" | |
- name: Install Qt | |
env: | |
QT_EMAIL: ${{ secrets.QT_EMAIL }} | |
QT_PASSWORD: ${{ secrets.QT_PASSWORD }} | |
run: | | |
wget 'https://qt.mirror.constant.com/archive/online_installers/4.8/qt-online-installer-linux-x64-4.8.0.run' | |
chmod +x qt-online-installer-linux-x64-4.8.0.run | |
./qt-online-installer-linux-x64-4.8.0.run --no-force-installations --no-default-installations \ | |
--no-size-checking --default-answer --accept-licenses --confirm-command --accept-obligations \ | |
--email "$QT_EMAIL" --password "$QT_PASSWORD" install \ | |
qt.qt6.680.linux_gcc_64 extensions.qtpdf.680.linux_gcc_64 qt.qt6.680.addons.qthttpserver | |
- name: Configure | |
run: | | |
sed -i '/file(DOWNLOAD/,+4 s/^/#/' CMakeLists.txt | |
cmake -S gpt4all-chat -B gpt4all-chat/build \ | |
-DCMAKE_C_COMPILER=clang-18 \ | |
-DCMAKE_CXX_COMPILER=clang++-18 \ | |
-DLLMODEL_CUDA=OFF \ | |
-DLLMODEL_KOMPUTE=OFF | |
- uses: cpp-linter/cpp-linter-action@v2 | |
id: linter | |
with: | |
style: '' # no clang-format | |
extensions: 'c,cpp,h,inl' | |
tidy-checks: '' # use .clang-tidy config | |
database: gpt4all-chat/build | |
version: 18 | |
- name: Fail Fast | |
if: steps.linter.outputs.clang-tidy-checks-failed > 0 | |
run: exit 1 |