Skip to content

Commit edab682

Browse files
authored
Enable clang tidy in CI (#314)
* add clang tidy check * test * check * check * test * check * test * header filter * fix header filter * check * check * check * recheck * re-check * undo removing ci
1 parent ea845ee commit edab682

File tree

4 files changed

+34
-24
lines changed

4 files changed

+34
-24
lines changed

.clang-tidy

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
Checks: >
2-
-*,
3-
bugprone-*,
4-
google-*,
5-
misc-*,
6-
modernize-*,
7-
performance-*,
8-
portability-*,
9-
readability-*,
10-
-google-readability-namespace-comments,
11-
-google-runtime-int,
12-
-google-runtime-references,
2+
*,
3+
-abseil-*,
4+
-altera-*,
5+
-cppcoreguidelines-avoid-goto,
6+
-cppcoreguidelines-non-private-member-variables-in-classes,
7+
-fuchsia-*,
8+
-hicpp-*,
9+
-llvm-*,
10+
-llvmlibc-*,
1311
-misc-non-private-member-variables-in-classes,
14-
-readability-named-parameter,
15-
-readability-braces-around-statements,
16-
-readability-magic-numbers
12+
-modernize-*,
13+
-readability-function-cognitive-complexity,
14+
-readability-identifier-length
1715
1816
# Turn all the warnings from the checks above into errors.
19-
WarningsAsErrors: ""
17+
HeaderFilterRegex: '.*/include/inja/.*\.hpp$'
18+
UseColor: true
19+
WarningsAsErrors: ''

.github/workflows/ci.yml

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,11 @@ jobs:
1919
os: ubuntu-22.04
2020
compiler: clang
2121

22+
- name: ubuntu-22.04-clang-tidy
23+
os: ubuntu-22.04
24+
compiler: clang
25+
cmake_vars: "-DINJA_ENABLE_CLANG_TIDY=ON"
26+
2227
- name: ubuntu-22.04-clang-15-no-exceptions
2328
os: ubuntu-22.04
2429
compiler: clang-15
@@ -56,7 +61,7 @@ jobs:
5661
- uses: actions/checkout@v4
5762

5863
- name: Setup Cpp
59-
uses: aminya/setup-cpp@v0.44.0
64+
uses: aminya/setup-cpp@v0.46.1
6065
with:
6166
compiler: ${{ matrix.compiler }}
6267

CMakeLists.txt

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,14 @@ cmake_policy(SET CMP0077 NEW)
88
project(inja LANGUAGES CXX VERSION 3.4.0)
99

1010

11-
option(INJA_USE_EMBEDDED_JSON "Use the shipped json header if not available on the system" ON)
12-
option(INJA_INSTALL "Generate install targets for inja" ON)
13-
option(INJA_INSTALL_SINGLE_HEADER "Install the single header instead" OFF)
14-
option(INJA_EXPORT "Export the current build tree to the package registry" ON)
1511
option(BUILD_TESTING "Build unit tests" ON)
16-
option(INJA_BUILD_TESTS "Build unit tests when BUILD_TESTING is enabled." ON)
1712
option(COVERALLS "Generate coveralls data" OFF)
13+
option(INJA_BUILD_TESTS "Build unit tests when BUILD_TESTING is enabled." ON)
14+
option(INJA_ENABLE_CLANG_TIDY "Enable clang-tidy" OFF)
15+
option(INJA_EXPORT "Export the current build tree to the package registry" ON)
16+
option(INJA_INSTALL "Generate install targets for inja" ON)
17+
option(INJA_INSTALL_SINGLE_HEADER "Install the single header instead" OFF)
18+
option(INJA_USE_EMBEDDED_JSON "Use the shipped json header if not available on the system" ON)
1819

1920

2021
set(INJA_INSTALL_INCLUDE_DIR "include")
@@ -94,6 +95,12 @@ if(BUILD_TESTING AND INJA_BUILD_TESTS)
9495
target_compile_options(inja_test PRIVATE -Wall -Wextra -Werror)
9596
endif()
9697

98+
if(INJA_ENABLE_CLANG_TIDY)
99+
find_program(CLANG_TIDY_EXE NAMES "clang-tidy" REQUIRED)
100+
set(CLANG_TIDY_COMMAND "${CLANG_TIDY_EXE}" "-config-file=${CMAKE_CURRENT_SOURCE_DIR}/.clang-tidy")
101+
set_target_properties(inja_test PROPERTIES CXX_CLANG_TIDY "${CLANG_TIDY_COMMAND}")
102+
endif()
103+
97104

98105
add_library(single_inja INTERFACE)
99106
target_compile_features(single_inja INTERFACE cxx_std_17)
@@ -106,8 +113,7 @@ if(BUILD_TESTING AND INJA_BUILD_TESTS)
106113
add_test(single_inja_test ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/single_inja_test)
107114

108115

109-
add_executable(inja_benchmark test/benchmark.cpp
110-
test/test-common.hpp)
116+
add_executable(inja_benchmark test/benchmark.cpp test/test-common.hpp)
111117
target_link_libraries(inja_benchmark PRIVATE inja)
112118
target_include_directories(inja_benchmark PRIVATE third_party/include)
113119
endif()

scripts/clang_tidy.sh

Lines changed: 0 additions & 1 deletion
This file was deleted.

0 commit comments

Comments
 (0)