Skip to content

Commit 6d74e9e

Browse files
committed
[CI] Add clang-tidy check
1 parent d9dd029 commit 6d74e9e

File tree

2 files changed

+77
-1
lines changed

2 files changed

+77
-1
lines changed

.clang-tidy

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
---
2+
Checks: >
3+
# It follows https://github.com/googleapis/google-cloud-cpp/blob/main/.clang-tidy
4+
-*,
5+
abseil-*,
6+
bugprone-*,
7+
google-*,
8+
misc-*,
9+
modernize-*,
10+
performance-*,
11+
portability-*,
12+
readability-*,
13+
-google-readability-braces-around-statements,
14+
-google-readability-namespace-comments,
15+
-google-runtime-references,
16+
-misc-non-private-member-variables-in-classes,
17+
-misc-const-correctness,
18+
-misc-include-cleaner,
19+
-modernize-return-braced-init-list,
20+
-modernize-use-trailing-return-type,
21+
-modernize-concat-nested-namespaces,
22+
-modernize-use-nodiscard,
23+
-modernize-avoid-c-arrays,
24+
-modernize-type-traits,
25+
-modernize-unary-static-assert,
26+
-performance-move-const-arg,
27+
-performance-avoid-endl,
28+
-performance-enum-size,
29+
-readability-braces-around-statements,
30+
-readability-identifier-length,
31+
-readability-magic-numbers,
32+
-readability-named-parameter,
33+
-readability-redundant-declaration,
34+
-readability-avoid-return-with-void-value,
35+
-readability-function-cognitive-complexity,
36+
-bugprone-narrowing-conversions,
37+
-bugprone-easily-swappable-parameters,
38+
-bugprone-inc-dec-in-conditions,
39+
-bugprone-implicit-widening-of-multiplication-result,
40+
-bugprone-unchecked-optional-access,
41+
-bugprone-unused-local-non-trivial-variable,
42+
-bugprone-unused-return-value
43+
WarningsAsErrors: '*'
44+
HeaderFileExtensions:
45+
- ''
46+
- h
47+
ImplementationFileExtensions:
48+
- cc
49+
HeaderFilterRegex: '.*'
50+
FormatStyle: none
51+
User: xuyunze
52+
CheckOptions:
53+
cert-err33-c.CheckedFunctions: '^::aligned_alloc;^::asctime_s;^::at_quick_exit;^::atexit;^::bsearch;^::bsearch_s;^::btowc;^::c16rtomb;^::c32rtomb;^::calloc;^::clock;^::cnd_broadcast;^::cnd_init;^::cnd_signal;^::cnd_timedwait;^::cnd_wait;^::ctime_s;^::fclose;^::fflush;^::fgetc;^::fgetpos;^::fgets;^::fgetwc;^::fopen;^::fopen_s;^::fprintf;^::fprintf_s;^::fputc;^::fputs;^::fputwc;^::fputws;^::fread;^::freopen;^::freopen_s;^::fscanf;^::fscanf_s;^::fseek;^::fsetpos;^::ftell;^::fwprintf;^::fwprintf_s;^::fwrite;^::fwscanf;^::fwscanf_s;^::getc;^::getchar;^::getenv;^::getenv_s;^::gets_s;^::getwc;^::getwchar;^::gmtime;^::gmtime_s;^::localtime;^::localtime_s;^::malloc;^::mbrtoc16;^::mbrtoc32;^::mbsrtowcs;^::mbsrtowcs_s;^::mbstowcs;^::mbstowcs_s;^::memchr;^::mktime;^::mtx_init;^::mtx_lock;^::mtx_timedlock;^::mtx_trylock;^::mtx_unlock;^::printf_s;^::putc;^::putwc;^::raise;^::realloc;^::remove;^::rename;^::scanf;^::scanf_s;^::setlocale;^::setvbuf;^::signal;^::snprintf;^::snprintf_s;^::sprintf;^::sprintf_s;^::sscanf;^::sscanf_s;^::strchr;^::strerror_s;^::strftime;^::strpbrk;^::strrchr;^::strstr;^::strtod;^::strtof;^::strtoimax;^::strtok;^::strtok_s;^::strtol;^::strtold;^::strtoll;^::strtoul;^::strtoull;^::strtoumax;^::strxfrm;^::swprintf;^::swprintf_s;^::swscanf;^::swscanf_s;^::thrd_create;^::thrd_detach;^::thrd_join;^::thrd_sleep;^::time;^::timespec_get;^::tmpfile;^::tmpfile_s;^::tmpnam;^::tmpnam_s;^::tss_create;^::tss_get;^::tss_set;^::ungetc;^::ungetwc;^::vfprintf;^::vfprintf_s;^::vfscanf;^::vfscanf_s;^::vfwprintf;^::vfwprintf_s;^::vfwscanf;^::vfwscanf_s;^::vprintf_s;^::vscanf;^::vscanf_s;^::vsnprintf;^::vsnprintf_s;^::vsprintf;^::vsprintf_s;^::vsscanf;^::vsscanf_s;^::vswprintf;^::vswprintf_s;^::vswscanf;^::vswscanf_s;^::vwprintf_s;^::vwscanf;^::vwscanf_s;^::wcrtomb;^::wcschr;^::wcsftime;^::wcspbrk;^::wcsrchr;^::wcsrtombs;^::wcsrtombs_s;^::wcsstr;^::wcstod;^::wcstof;^::wcstoimax;^::wcstok;^::wcstok_s;^::wcstol;^::wcstold;^::wcstoll;^::wcstombs;^::wcstombs_s;^::wcstoul;^::wcstoull;^::wcstoumax;^::wcsxfrm;^::wctob;^::wctrans;^::wctype;^::wmemchr;^::wprintf_s;^::wscanf;^::wscanf_s;'
54+
cppcoreguidelines-special-member-functions.AllowSoleDefaultDtor: 'true'
55+
cppcoreguidelines-special-member-functions.AllowMissingMoveFunctionsWhenCopyIsDeleted: 'true'
56+
performance-move-const-arg.CheckTriviallyCopyableMove: 'false'
57+
readability-identifier-naming.LocalVariableCase: 'camelBack'
58+
readability-identifier-naming.LocalConstantCase: 'camelBack'
59+
readability-identifier-naming.StructCase: 'CamelCase'
60+
readability-identifier-naming.ClassCase: 'CamelCase'
61+
readability-identifier-naming.ParameterCase: 'camelBack'
62+
readability-identifier-naming.MethodCase: 'camelBack'
63+
readability-identifier-naming.FunctionCase: 'camelBack'
64+
readability-identifier-naming.MemberCase: 'camelBack'
65+
readability-identifier-naming.PrivateMemberSuffix: '_'
66+
readability-identifier-naming.PublicMemberSuffix: ''
67+
SystemHeaders: false

.github/workflows/ci-pr-validation.yaml

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -105,13 +105,22 @@ jobs:
105105
106106
- name: Build tests
107107
run: |
108-
cmake . -DINTEGRATE_VCPKG=ON -DBUILD_TESTS=ON
108+
cmake . -DINTEGRATE_VCPKG=ON -DBUILD_TESTS=ON -DCMAKE_EXPORT_COMPILE_COMMANDS=ON
109109
cmake --build . -j8
110110
111111
- name: Install gtest-parallel
112112
run: |
113113
sudo curl -o /gtest-parallel https://raw.githubusercontent.com/google/gtest-parallel/master/gtest_parallel.py
114114
115+
- name: Tidy check
116+
run: |
117+
sudo apt-get install -y clang-tidy
118+
run-clang-tidy -p build
119+
if [[ $? -ne 0 ]]; then
120+
echo "clang-tidy failed"
121+
exit 1
122+
fi
123+
115124
- name: Run unit tests
116125
run: RETRY_FAILED=3 ./run-unit-tests.sh
117126

0 commit comments

Comments
 (0)