Skip to content

Commit b95fded

Browse files
committed
ci: add clang-tidy to static analysis workflow.
The check for GITHUB_HEAD_REF is used so the same workflow works for PRs and for branches. The issue causing git-config(1) to be necessary is tracked in [1]. Meson supports a clang-tidy target of its own, but it's not really usable for our purposes [2]. [1] actions/checkout#1169 [2] mesonbuild/meson#2383
1 parent 1583dc7 commit b95fded

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

.github/workflows/static-analysis.yml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,19 @@ jobs:
1919
fail-fast: false
2020
matrix:
2121
tool:
22+
# clang-tidy is more extensive and the list of checks isn't final, so fixing all of them at once isn't tractable;
23+
# therefore, the job doesn't fail due to clang-tidy, it's simply informative
24+
- packages: "clang-tidy"
25+
command: "clang-tidy '--warnings-as-errors=-*' -p build/ $(git ls-files | grep '\\.c\\+$')"
26+
# however, we should check that the changed lines of code don't have any tidy warnings
27+
- packages: "clang-tidy"
28+
command: |
29+
if [ -n \"$GITHUB_BASE_REF\" ]; then
30+
git diff -U0 origin/$GITHUB_BASE_REF > diff
31+
clang-tidy-diff -p1 -config-file .clang-tidy -path build/ < diff > result && exitcode=0 || exitcode=$?
32+
cat result
33+
exit $exitcode
34+
fi
2235
# cppcheck doesn't check as much, so we can make the job fail because of it;
2336
# tests are skipped due to issues with Catch2 headers
2437
- packages: "cppcheck"

0 commit comments

Comments
 (0)