1
0
mirror of https://github.com/systemd/systemd synced 2025-10-06 00:13:24 +02:00

ci: Add basic clang-tidy check to linter workflow

Let's add a basic clang-tidy check to the linter workflow. This
gives us the following:
- A check so that we don't introduce any new cyclic header dependencies
- A check to make sure all of our header files are standalone, as clang-tidy
  will fail to parse header files that don't include all their dependencies.
This commit is contained in:
Daan De Meyer
2025-04-23 15:21:11 +02:00
parent 9e3d048bd0
commit 9b5895be12
3 changed files with 34 additions and 0 deletions

12
.clang-tidy Normal file
View File

@@ -0,0 +1,12 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
---
Checks: '
-*,
misc-header-include-cycle
'
WarningsAsErrors: '*'
HeaderFileExtensions:
- h
ImplementationFileExtensions:
- c
...

12
.clang-tidy-ignore Normal file
View File

@@ -0,0 +1,12 @@
# SPDX-License-Identifier: LGPL-2.1-or-later
man/*
# These contain external headers that we don't want to check.
src/basic/include/*
# clang-tidy can't parse BPF source files.
src/core/bpf/*
src/network/bpf/*
src/nsresourced/bpf/*
# The glib headers contain cyclic dependencies and clang-tidy
# can't distinguish between our code and glib headers so we
# exclude this test.
src/libsystemd/sd-bus/test-bus-marshal.c

View File

@@ -69,3 +69,13 @@ jobs:
echo "Please run 'ruff format' on the above files or apply the diffs below manually"
mkosi sandbox -- ruff format --check --quiet --diff src/boot/generate-hwids-section.py src/test/generate-sym-test.py src/ukify/ukify.py test/integration-tests/integration-test-wrapper.py
fi
- name: Configure meson
run: mkosi sandbox -- env CC=clang CXX=clang++ meson setup build
# Make sure all generated source files are actually generated by doing a full build.
- name: Build systemd
run: mkosi sandbox -- ninja -C build
- name: Run clang-tidy
run: mkosi sandbox -- ninja -C build clang-tidy