diff --git a/.github/workflows/cpp.yml b/.github/workflows/cpp.yml index cf6e26e23..871b22c13 100644 --- a/.github/workflows/cpp.yml +++ b/.github/workflows/cpp.yml @@ -80,3 +80,32 @@ jobs: echo "Not all tests passed!" exit 1 fi + + clang-tidy: + name: Clang tidy + needs: [ build ] + runs-on: ubuntu-20.04 + steps: + - name: Fetch the package's repository + uses: actions/checkout@v4 + + - name: Setup CMake + uses: jwlawson/actions-setup-cmake@v2 + with: + cmake-version: '3.18' + + - name: Setup clang-tidy + run: | + sudo apt-get update + sudo apt-get install -q -y --no-install-recommends clang-tidy + + - name: Configure CMake + working-directory: ${{github.workspace}} + run: cmake -B build -DCMAKE_BUILD_TYPE=Release library/cpp + + - name: Run clang-tidy + working-directory: ${{github.workspace}}/build + run: | + echo "::add-matcher::./.github/problem-matchers/clang-tidy.json" + run-clang-tidy -header-filter="*include/wavemap/*" -quiet + echo "::remove-matcher owner=problem-matcher-clang-tidy::" diff --git a/interfaces/ros1/wavemap_ros/CMakeLists.txt b/interfaces/ros1/wavemap_ros/CMakeLists.txt index 34d6a9568..e90bc7449 100644 --- a/interfaces/ros1/wavemap_ros/CMakeLists.txt +++ b/interfaces/ros1/wavemap_ros/CMakeLists.txt @@ -27,9 +27,6 @@ if (livox_ros_driver2_FOUND) add_compile_definitions(LIVOX_AVAILABLE) endif () -# Enable general wavemap tooling (e.g. to run clang-tidy CI) -enable_wavemap_general_tooling() - # Libraries add_library(${PROJECT_NAME} src/inputs/depth_image_topic_input.cc diff --git a/interfaces/ros1/wavemap_ros_conversions/CMakeLists.txt b/interfaces/ros1/wavemap_ros_conversions/CMakeLists.txt index 6a2e2f381..2c505017e 100644 --- a/interfaces/ros1/wavemap_ros_conversions/CMakeLists.txt +++ b/interfaces/ros1/wavemap_ros_conversions/CMakeLists.txt @@ -11,9 +11,6 @@ catkin_package( LIBRARIES ${PROJECT_NAME} CATKIN_DEPENDS roscpp eigen_conversions wavemap wavemap_msgs) -# Enable general wavemap tooling (e.g. to run clang-tidy CI) -enable_wavemap_general_tooling() - # Libraries add_library(${PROJECT_NAME} src/config_conversions.cc diff --git a/library/cpp/CMakeLists.txt b/library/cpp/CMakeLists.txt index e917d9efe..b4a50fba4 100644 --- a/library/cpp/CMakeLists.txt +++ b/library/cpp/CMakeLists.txt @@ -15,7 +15,9 @@ option(USE_SYSTEM_BOOST "Use system pre-installed Boost" ON) # CMake helpers and general wavemap tooling (e.g. to run clang-tidy CI) include(GNUInstallDirs) include(cmake/wavemap-extras.cmake) -enable_wavemap_general_tooling() + +# Export compilation database for compatibility with clang-tidy +set(CMAKE_EXPORT_COMPILE_COMMANDS ON) # Dependencies include(cmake/find-wavemap-deps.cmake) diff --git a/library/cpp/cmake/wavemap-extras.cmake b/library/cpp/cmake/wavemap-extras.cmake index ecd761aa7..aa7a2a48b 100644 --- a/library/cpp/cmake/wavemap-extras.cmake +++ b/library/cpp/cmake/wavemap-extras.cmake @@ -8,14 +8,6 @@ option(ENABLE_COVERAGE_TESTING "Compile with necessary flags for coverage testing" OFF) option(USE_CLANG_TIDY "Generate necessary files to run clang-tidy" OFF) -# Enable general wavemap tooling for the calling CMake project -function(enable_wavemap_general_tooling) - # Export compilation database for compatibility with clang-tidy - if (USE_CLANG_TIDY) - set(CMAKE_EXPORT_COMPILE_COMMANDS ON PARENT_SCOPE) - endif () -endfunction() - # Adds the include paths of the wavemap library to the given target. function(add_wavemap_include_directories target) # Configure the include dirs