Skip to content

Commit 8d1ffd2

Browse files
committed
ci: run clang-tidy and attach lints to PR
1 parent 7e778d1 commit 8d1ffd2

File tree

2 files changed

+53
-1
lines changed

2 files changed

+53
-1
lines changed

.clang-tidy

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
---
2+
Checks: >
3+
-*,
4+
bugprone-*,
5+
clang-analyzer-*,
6+
misc-*,
7+
modernize-*,
8+
performance-*,
9+
portability-*,
10+
readability-*,
11+
-bugprone-assignment-in-if-condition,
12+
-modernize-use-trailing-return-type,
13+
-readability-braces-around-statements,
14+
-readability-function-cognitive-complexity,
15+
-readability-function-size,
16+
17+
HeaderFilterRegex: '^.*\.cpp$'
18+
19+
CheckOptions:
20+
readability-identifier-length.IgnoredParameterNames: "i|x|y|z"
21+
readability-identifier-length.IgnoredVariableNames: "i|x|y|z"
22+
readability-identifier-naming.ClassCase: "CamelCase"
23+
readability-identifier-naming.ConstexprVariableCase: "UPPER_CASE"
24+
readability-identifier-naming.EnumCase: "UPPER_CASE"
25+
readability-identifier-naming.FunctionCase: "lower_case"
26+
readability-identifier-naming.GlobalConstexprVariableCase: "UPPER_CASE"
27+
readability-identifier-naming.MemberCase: "lower_case"
28+
readability-identifier-naming.MethodCase: "lower_case"
29+
readability-identifier-naming.ParameterCase: "lower_case"
30+
readability-identifier-naming.StructCase: "CamelCase"
31+
readability-identifier-naming.VariableCase: "lower_case"

.github/workflows/cmake-linux.yml

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,9 @@ jobs:
3737
version: 20
3838
- compiler: clang
3939
version: 21
40+
- compiler: clang
41+
version: 22
42+
lint: true
4043
- compiler: gcc
4144
version: 14
4245
steps:
@@ -46,6 +49,12 @@ jobs:
4649
if: ${{ matrix.compiler == 'clang' }}
4750
run: wget -qO - https://apt.llvm.org/llvm.sh | sudo bash -s -- ${{ matrix.version }} all
4851

52+
- name: Install clang-tidy-sarif
53+
if: ${{ matrix.lint }}
54+
uses: taiki-e/install-action@v2
55+
with:
56+
tool: clang-tidy-sarif
57+
4958
- name: Configure
5059
run: |
5160
if [[ "${{ matrix.compiler }}" == "clang" ]]; then
@@ -57,10 +66,22 @@ jobs:
5766
export CC=gcc-${{ matrix.version }}
5867
export CXX=g++-${{ matrix.version }}
5968
fi
60-
cmake -B build -G Ninja -DCMAKE_BUILD_TYPE=Debug
69+
cmake -B build -G Ninja -DCMAKE_BUILD_TYPE=Debug -DCMAKE_EXPORT_COMPILE_COMMANDS=ON
6170
6271
- name: Compile
72+
if: ${{ !matrix.lint }}
6373
run: cmake --build build --verbose
6474

75+
- name: Lint
76+
if: ${{ matrix.lint }}
77+
run: run-clang-tidy-${{ matrix.version }} -quiet -p build -hide-progress | clang-tidy-sarif > result.sarif
78+
79+
- name: Upload lints
80+
if: ${{ matrix.lint }}
81+
uses: github/codeql-action/upload-sarif@v4
82+
with:
83+
sarif_file: result.sarif
84+
6585
- name: Test
86+
if: ${{ !matrix.lint }}
6687
run: ctest --test-dir build

0 commit comments

Comments
 (0)