Skip to content

Commit

Permalink
test
Browse files Browse the repository at this point in the history
  • Loading branch information
kluge7 committed Oct 10, 2024
1 parent 48bcbc8 commit 4ac0d46
Show file tree
Hide file tree
Showing 11 changed files with 133 additions and 26 deletions.
Empty file added .clang-tidy
Empty file.
77 changes: 77 additions & 0 deletions .github/workflows/clang-tidy.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
name: clang-tidy and Test

on: [push]

jobs:
build:
runs-on: ubuntu-22.04

steps:
- name: Checkout Repository
uses: actions/checkout@v4

- name: Install ROS 2 Humble
run: |
sudo apt update
sudo apt install -y curl gnupg lsb-release
# Add the ROS 2 GPG key
sudo curl -sSL https://raw.githubusercontent.com/ros/rosdistro/master/ros.key -o /usr/share/keyrings/ros-archive-keyring.gpg
# Add the ROS 2 repository
echo "deb [arch=$(dpkg --print-architecture) signed-by=/usr/share/keyrings/ros-archive-keyring.gpg] http://packages.ros.org/ros2/ubuntu $(lsb_release -cs) main" | sudo tee /etc/apt/sources.list.d/ros2.list > /dev/null
sudo apt update
# Install ROS 2 Humble desktop version
sudo apt install -y ros-humble-desktop
- name: Install Build Tools and Dependencies
run: |
sudo apt install -y python3-colcon-common-extensions python3-rosdep
# Initialize rosdep
sudo rosdep init
rosdep update
- name: Set up ROS 2 Workspace
run: |
mkdir -p ~/ros2_ws/src
cd ~/ros2_ws/src
# Copy the repository code to the workspace src folder
mkdir vortex-auv
cd vortex-auv
cp -r $GITHUB_WORKSPACE/* .
cd ..
# Clone vortex-msgs repository
git clone https://github.com/vortexntnu/vortex-msgs.git
# Go back to workspace root
cd ~/ros2_ws
- name: Install Package Dependencies with rosdep
run: |
source /opt/ros/humble/setup.bash
cd ~/ros2_ws
rosdep install --from-paths src --ignore-src -r -y
- name: Build ROS 2 Workspace
run: |
source /opt/ros/humble/setup.bash
cd ~/ros2_ws
colcon build --cmake-args -DCMAKE_EXPORT_COMPILE_COMMANDS=ON
- name: Make Clang-Tidy Script Executable
run: |
chmod +x ~/ros2_ws/src/vortex-auv/scripts/run_clang_tidy.sh
- name: Run Clang-Tidy
run: |
cd ~/ros2_ws
./src/vortex-auv/scripts/run_clang_tidy.sh
- name: Final status
if: success()
run: echo "Pipeline completed successfully!"
5 changes: 0 additions & 5 deletions acoustics/acoustics_data_record/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,6 @@ set(CMAKE_CXX_EXTENSIONS OFF)

project(acoustics_data_record)

# Default to C++14
if(NOT CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 14)
endif()

if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_compile_options(-Wall -Wextra -Wpedantic)
endif()
Expand Down
4 changes: 1 addition & 3 deletions acoustics/acoustics_interface/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
cmake_minimum_required(VERSION 3.8)

# Enable export of compile_commands.json for clang-tidy and other tools
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)

project(acoustics_interface)

Expand Down
8 changes: 5 additions & 3 deletions auv_setup/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
cmake_minimum_required(VERSION 3.8)

# Enable export of compile_commands.json for clang-tidy and other tools
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)

project(auv_setup)

if(NOT CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 14)
endif()

if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_compile_options(-Wall -Wextra -Wpedantic)
endif()
Expand Down
8 changes: 5 additions & 3 deletions mission/blackbox/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
cmake_minimum_required(VERSION 3.8)

# Enable export of compile_commands.json for clang-tidy and other tools
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)

project(blackbox)

if(NOT CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 14)
endif()

if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_compile_options(-Wall -Wextra -Wpedantic)
endif()
Expand Down
8 changes: 5 additions & 3 deletions mission/internal_status_auv/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
cmake_minimum_required(VERSION 3.8)

# Enable export of compile_commands.json for clang-tidy and other tools
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)

project(internal_status_auv)

if(NOT CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 14)
endif()

if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_compile_options(-Wall -Wextra -Wpedantic)
endif()
Expand Down
8 changes: 5 additions & 3 deletions mission/joystick_interface_auv/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
cmake_minimum_required(VERSION 3.8)

# Enable export of compile_commands.json for clang-tidy and other tools
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)

project(joystick_interface_auv)

if(NOT CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 14)
endif()

if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_compile_options(-Wall -Wextra -Wpedantic)
endif()
Expand Down
4 changes: 1 addition & 3 deletions motion/thrust_allocator_auv/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
cmake_minimum_required(VERSION 3.8)

# Enable export of compile_commands.json for clang-tidy and other tools
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)

project(thrust_allocator_auv)

Expand Down
8 changes: 5 additions & 3 deletions motion/thruster_interface_auv/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
cmake_minimum_required(VERSION 3.8)

# Enable export of compile_commands.json for clang-tidy and other tools
set(CMAKE_EXPORT_COMPILE_COMMANDS ON)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)

project(thruster_interface_auv)

if(NOT CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 14)
endif()

if(CMAKE_COMPILER_IS_GNUCXX OR CMAKE_CXX_COMPILER_ID MATCHES "Clang")
add_compile_options(-Wall -Wextra -Wpedantic)
endif()
Expand Down
29 changes: 29 additions & 0 deletions scripts/run_clang_tidy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
#!/bin/bash

# Paths
compile_commands_json="build/compile_commands.json"

# Function to run clang-tidy on each file
run_clang_tidy() {
local file=$1
echo "Running clang-tidy on $file with $compile_commands_json"

# Add -warnings-as-errors=* to treat all warnings as errors
clang-tidy "$file" \
--export-fixes=- \
-p "$compile_commands_json" \
--warnings-as-errors="*" \
--header-filter=".*" \
--quiet

# Check if clang-tidy returned a non-zero exit code, meaning it found an issue
if [ $? -ne 0 ]; then
echo "clang-tidy found issues in $file. Treating warnings as errors."
exit 1
fi
}

# Find all .cpp, .hpp, .c, and .h files recursively in the src directory
find src -name '*.cpp' -o -name '*.c' | while read -r file; do
run_clang_tidy "$file"
done

0 comments on commit 4ac0d46

Please sign in to comment.