Skip to content

Commit af07567

Browse files
AlexeySachkovvladimirlaz
authored andcommitted
Improve clang-tidy CI check
Enabled warnings as errors to clarify that most of enabled checks are required. New feature: warnings and errors found by clang-tidy are now being reported as annotations at "Files changed" page.
1 parent c922f75 commit af07567

File tree

2 files changed

+24
-1
lines changed

2 files changed

+24
-1
lines changed

llvm-spirv/.clang-tidy

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
Checks: '-*,clang-diagnostic-*,llvm-*,misc-*,-misc-unused-parameters,readability-identifier-naming,-llvm-header-guard'
2+
WarningsAsErrors: 'llvm-*,misc-*,-misc-unused-parameters,readability-identifier-naming,-llvm-header-guard'
23
CheckOptions:
34
- key: readability-identifier-naming.ClassCase
45
value: CamelCase

llvm-spirv/.github/workflows/check-code-style.yml

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ env:
2525

2626
jobs:
2727
clang-format-and-tidy:
28-
name: Run clang-format & clang-tidy
28+
name: clang-format & clang-tidy
2929
runs-on: ubuntu-latest
3030
steps:
3131
- name: Checkout sources
@@ -96,6 +96,28 @@ jobs:
9696
sed -i '/^$/d' clang-tidy.log
9797
if [ -s clang-tidy.log ]; then
9898
if ! grep -q "No relevant changes found." clang-tidy.log; then
99+
# Emit annotations
100+
while read -r line; do
101+
type="error"
102+
if [[ $line == *"warning:"* ]]; then
103+
type="warning"
104+
elif [[ $line == *"error:"* ]]; then
105+
type="error"
106+
else
107+
continue
108+
fi
109+
110+
absolute_path=$(echo $line | grep -Po "^[\w\d-./]+(?=:)")
111+
relative_path=${absolute_path##"${{ github.workspace }}"}
112+
113+
line_number=$(echo $line | grep -Po "(?<=:)\d+(?=:\d)")
114+
115+
message=$(echo $line | grep -Po "(?<=${type}: ).*$")
116+
117+
# see [workflow-commands] for documentation
118+
echo "::${type} file=${relative_path},line=${line_number}::${message}"
119+
done < clang-tidy.log
120+
99121
echo "clang-tidy found incorrectly written code:"
100122
cat clang-tidy.log
101123
exit 1

0 commit comments

Comments
 (0)