diff --git a/.clang-tidy b/.clang-tidy new file mode 100644 index 0000000000..f716a6650b --- /dev/null +++ b/.clang-tidy @@ -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 index 0000000000..6e0889f080 --- /dev/null +++ b/.clang-tidy-ignore @@ -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 diff --git a/.github/workflows/linter.yml b/.github/workflows/linter.yml index 032c010b7d..65a121306a 100644 --- a/.github/workflows/linter.yml +++ b/.github/workflows/linter.yml @@ -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