Skip to content

Commit

Permalink
Add clang-tidy to C++ API CI workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
victorreijgwart committed Sep 5, 2024
1 parent 525f48c commit bdf2e8a
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 15 deletions.
29 changes: 29 additions & 0 deletions .github/workflows/cpp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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::"
3 changes: 0 additions & 3 deletions interfaces/ros1/wavemap_ros/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
3 changes: 0 additions & 3 deletions interfaces/ros1/wavemap_ros_conversions/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion library/cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
8 changes: 0 additions & 8 deletions library/cpp/cmake/wavemap-extras.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit bdf2e8a

Please sign in to comment.