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
This commit is contained in:
Berscheid
2025-10-18 06:33:11 -07:00
committed by GitHub
parent ea845eee91
commit edab682601
4 changed files with 34 additions and 24 deletions

View File

@@ -1,19 +1,19 @@
Checks: > Checks: >
-*, *,
bugprone-*, -abseil-*,
google-*, -altera-*,
misc-*, -cppcoreguidelines-avoid-goto,
modernize-*, -cppcoreguidelines-non-private-member-variables-in-classes,
performance-*, -fuchsia-*,
portability-*, -hicpp-*,
readability-*, -llvm-*,
-google-readability-namespace-comments, -llvmlibc-*,
-google-runtime-int,
-google-runtime-references,
-misc-non-private-member-variables-in-classes, -misc-non-private-member-variables-in-classes,
-readability-named-parameter, -modernize-*,
-readability-braces-around-statements, -readability-function-cognitive-complexity,
-readability-magic-numbers -readability-identifier-length
# Turn all the warnings from the checks above into errors. # Turn all the warnings from the checks above into errors.
WarningsAsErrors: "" HeaderFilterRegex: '.*/include/inja/.*\.hpp$'
UseColor: true
WarningsAsErrors: ''

View File

@@ -19,6 +19,11 @@ jobs:
os: ubuntu-22.04 os: ubuntu-22.04
compiler: clang compiler: clang
- name: ubuntu-22.04-clang-tidy
os: ubuntu-22.04
compiler: clang
cmake_vars: "-DINJA_ENABLE_CLANG_TIDY=ON"
- name: ubuntu-22.04-clang-15-no-exceptions - name: ubuntu-22.04-clang-15-no-exceptions
os: ubuntu-22.04 os: ubuntu-22.04
compiler: clang-15 compiler: clang-15
@@ -56,7 +61,7 @@ jobs:
- uses: actions/checkout@v4 - uses: actions/checkout@v4
- name: Setup Cpp - name: Setup Cpp
uses: aminya/setup-cpp@v0.44.0 uses: aminya/setup-cpp@v0.46.1
with: with:
compiler: ${{ matrix.compiler }} compiler: ${{ matrix.compiler }}

View File

@@ -8,13 +8,14 @@ cmake_policy(SET CMP0077 NEW)
project(inja LANGUAGES CXX VERSION 3.4.0) project(inja LANGUAGES CXX VERSION 3.4.0)
option(INJA_USE_EMBEDDED_JSON "Use the shipped json header if not available on the system" ON) option(BUILD_TESTING "Build unit tests" ON)
option(COVERALLS "Generate coveralls data" OFF)
option(INJA_BUILD_TESTS "Build unit tests when BUILD_TESTING is enabled." ON)
option(INJA_ENABLE_CLANG_TIDY "Enable clang-tidy" OFF)
option(INJA_EXPORT "Export the current build tree to the package registry" ON)
option(INJA_INSTALL "Generate install targets for inja" ON) option(INJA_INSTALL "Generate install targets for inja" ON)
option(INJA_INSTALL_SINGLE_HEADER "Install the single header instead" OFF) option(INJA_INSTALL_SINGLE_HEADER "Install the single header instead" OFF)
option(INJA_EXPORT "Export the current build tree to the package registry" ON) option(INJA_USE_EMBEDDED_JSON "Use the shipped json header if not available on the system" ON)
option(BUILD_TESTING "Build unit tests" ON)
option(INJA_BUILD_TESTS "Build unit tests when BUILD_TESTING is enabled." ON)
option(COVERALLS "Generate coveralls data" OFF)
set(INJA_INSTALL_INCLUDE_DIR "include") set(INJA_INSTALL_INCLUDE_DIR "include")
@@ -94,6 +95,12 @@ if(BUILD_TESTING AND INJA_BUILD_TESTS)
target_compile_options(inja_test PRIVATE -Wall -Wextra -Werror) target_compile_options(inja_test PRIVATE -Wall -Wextra -Werror)
endif() endif()
if(INJA_ENABLE_CLANG_TIDY)
find_program(CLANG_TIDY_EXE NAMES "clang-tidy" REQUIRED)
set(CLANG_TIDY_COMMAND "${CLANG_TIDY_EXE}" "-config-file=${CMAKE_CURRENT_SOURCE_DIR}/.clang-tidy")
set_target_properties(inja_test PROPERTIES CXX_CLANG_TIDY "${CLANG_TIDY_COMMAND}")
endif()
add_library(single_inja INTERFACE) add_library(single_inja INTERFACE)
target_compile_features(single_inja INTERFACE cxx_std_17) target_compile_features(single_inja INTERFACE cxx_std_17)
@@ -106,8 +113,7 @@ if(BUILD_TESTING AND INJA_BUILD_TESTS)
add_test(single_inja_test ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/single_inja_test) add_test(single_inja_test ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/single_inja_test)
add_executable(inja_benchmark test/benchmark.cpp add_executable(inja_benchmark test/benchmark.cpp test/test-common.hpp)
test/test-common.hpp)
target_link_libraries(inja_benchmark PRIVATE inja) target_link_libraries(inja_benchmark PRIVATE inja)
target_include_directories(inja_benchmark PRIVATE third_party/include) target_include_directories(inja_benchmark PRIVATE third_party/include)
endif() endif()

View File

@@ -1 +0,0 @@
clang-tidy test/test.cpp -- -Iinclude -Ithird_party/include