-
Notifications
You must be signed in to change notification settings - Fork 527
93 lines (83 loc) · 2.2 KB
/
clang_tidy.yml
File metadata and controls
93 lines (83 loc) · 2.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
name: Clang-Tidy
on:
push:
branches: ["main"]
paths:
- "**/*.c"
- "**/*.cc"
- "**/*.cpp"
- "**/*.cxx"
- "**/*.h"
- "**/*.hpp"
- "CMakeLists.txt"
- "**/CMakeLists.txt"
- "cmake/**"
- ".clang-tidy"
pull_request:
branches: ["main"]
paths:
- "**/*.c"
- "**/*.cc"
- "**/*.cpp"
- "**/*.cxx"
- "**/*.h"
- "**/*.hpp"
- "CMakeLists.txt"
- "**/CMakeLists.txt"
- "cmake/**"
- ".clang-tidy"
workflow_dispatch:
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
permissions:
contents: read
jobs:
clang_tidy:
name: Clang-Tidy Checks
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
submodules: recursive
- name: Install dependencies
run: |
sudo apt-get update
sudo apt-get install -y clang-tidy cmake ninja-build
- name: Configure CMake and export compile commands
run: |
cmake -S . -B build -G Ninja \
-DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
-DENABLE_HASWELL=ON \
-DBUILD_TOOLS=OFF
- name: Collect changed C/C++ files
id: changed_files
uses: tj-actions/changed-files@v46
with:
files: |
**/*.c
**/*.cc
**/*.cpp
**/*.cxx
**/*.h
**/*.hpp
!thirdparty/**
!build/**
separator: "\n"
- name: Run clang-tidy
if: steps.changed_files.outputs.any_changed == 'true'
run: |
mapfile -t changed_files <<'EOF'
${{ steps.changed_files.outputs.all_changed_files }}
EOF
for file in "${changed_files[@]}"; do
if [ -f "$file" ]; then
echo "Running clang-tidy on $file"
clang-tidy -p build --warnings-as-errors='*' "$file"
fi
done
- name: No changed C/C++ files
if: steps.changed_files.outputs.any_changed != 'true'
run: |
echo "No changed C/C++ files matched clang-tidy patterns."