]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
ci: Add basic clang-tidy check to linter workflow 37226/head
authorDaan De Meyer <daan.j.demeyer@gmail.com>
Wed, 23 Apr 2025 13:21:11 +0000 (15:21 +0200)
committerDaan De Meyer <daan.j.demeyer@gmail.com>
Wed, 23 Apr 2025 14:13:58 +0000 (16:13 +0200)
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.

.clang-tidy [new file with mode: 0644]
.clang-tidy-ignore [new file with mode: 0644]
.github/workflows/linter.yml

diff --git a/.clang-tidy b/.clang-tidy
new file mode 100644 (file)
index 0000000..f716a66
--- /dev/null
@@ -0,0 +1,12 @@
+# SPDX-License-Identifier: LGPL-2.1-or-later
+---
+Checks: '
+    -*,
+    misc-header-include-cycle
+'
+WarningsAsErrors: '*'
+HeaderFileExtensions:
+  - h
+ImplementationFileExtensions:
+  - c
+...
diff --git a/.clang-tidy-ignore b/.clang-tidy-ignore
new file mode 100644 (file)
index 0000000..6e0889f
--- /dev/null
@@ -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
index 032c010b7d0c7f25906a11174f0348401410a156..65a121306a5329474fef2c514342c8b13d91b9a5 100644 (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