Skip to content

[pre-commit.ci] pre-commit autoupdate #48

[pre-commit.ci] pre-commit autoupdate

[pre-commit.ci] pre-commit autoupdate #48

Workflow file for this run

# SPDX-FileCopyrightText: 2024 Klarälvdalens Datakonsult AB, a KDAB Group company <info@kdab.com>
#
# SPDX-License-Identifier: MIT
name: Linters
on:
workflow_dispatch:
pull_request:
env:
CC: "clang"
CXX: "clang++"
jobs:
clang-tidy:
runs-on: ${{ matrix.os }}
strategy:
matrix:
include:
- name: Ubuntu
os: ubuntu-24.04
# Specify executable name on Linux to have control over the version.
# Sadly, on Linux these per-version executables aren't there.
tidy-executable: clang-tidy-18
- name: Windows
os: windows-2022
tidy-executable: clang-tidy
fail-fast: false
steps:
- name: Checkout sources
uses: actions/checkout@v4
- name: Install ninja-build tool
if: runner.os == 'Windows'
uses: turtlesec-no/get-ninja@main
- name: Install linux dependencies
if: runner.os == 'Linux'
run: |
sudo apt update -qq
sudo apt install -y libxkbcommon-dev libxcb-xkb-dev \
libxkbcommon-x11-dev wayland-scanner++ wayland-protocols \
libwayland-dev xvfb ninja-build cppcheck
- name: Configure project
run: >
cmake -S . -B build -G Ninja -DKDUTILS_BUILD_TESTS=True
-DCMAKE_CXX_CLANG_TIDY="${{matrix.tidy-executable}}"
-DCMAKE_BUILD_TYPE=Release -DKDUTILS_BUILD_TESTS=ON
- name: Build Project
shell: pwsh
run: |
cmake --build build | Tee-Object -File log.txt
$numWarnings = (Get-Content log.txt | Select-String "warning:").Length
if($numWarnings -gt 0) {
echo "::error title=clang-tidy failed::See job log for details"
exit 1
}
cppcheck:
runs-on: ubuntu-24.04
steps:
- name: Checkout sources
uses: actions/checkout@v4
- name: Install Cppcheck
run: sudo apt update -qq && sudo apt install -y cppcheck
- name: Run Cppcheck
if: runner.os == 'Linux'
shell: pwsh
run: >
cppcheck --quiet --language=c++ --force --inline-suppr
--enable=warning,performance,portability,information
--disable=missingInclude --check-level=exhaustive
--suppress="ctuOneDefinitionRuleViolation:tests/*"
-i build --library=std.cfg --error-exitcode=42 .
if($LASTEXITCODE -eq 42) {
echo "::error title=Cppcheck failed::See job log for details"
exit 1
}