Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 50 additions & 5 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,55 @@ jobs:
build_and_test_ros2:
runs-on: ubuntu-22.04
container:
image: rostooling/setup-ros-docker:ubuntu-jammy-ros-humble-ros-base-latest
image: ros:humble-ros-base

steps:
- name: Build and run tests
uses: ros-tooling/action-ros-ci@v0.4
- name: Checkout code
uses: actions/checkout@v3
with:
package-name: build_test
target-ros2-distro: humble
submodules: recursive

- name: Set up Python virtual environment
shell: bash
run: |
# Install python3-venv if not available
apt-get update
apt-get install -y python3-venv python3-pip

# Create virtual environment
python3 -m venv .venv

# Activate and install dependencies
source .venv/bin/activate
pip install --upgrade pip
pip install -r requirements/requirements.txt

- name: Install rosdep dependencies
run: |
# Update rosdep
apt-get update
rosdep update

# Install dependencies from all packages in src/
rosdep install --from-paths src --ignore-src -r -y

- name: Build with colcon
shell: bash
run: |
# Activate venv and source ROS2 environment
source .venv/bin/activate
source /opt/ros/humble/setup.bash

# Build the workspace
colcon build --symlink-install

- name: Run tests
shell: bash
run: |
# Activate venv and source ROS2 and workspace environment
source .venv/bin/activate
source /opt/ros/humble/setup.bash
source install/setup.bash

# Make sure build works
colcon build --packages-select utils aiming_node ballistics_node classical_cv
6 changes: 5 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,8 @@
# ROS specific
build/
install/
log/
log/

# other
.vscode/
.venv/
8 changes: 7 additions & 1 deletion .vscode/settings.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
{
"ros.distro": "jazzy"
"ros.distro": "jazzy",
"python.autoComplete.extraPaths": [
"/opt/ros/jazzy/lib/python3.12/site-packages"
],
"python.analysis.extraPaths": [
"/opt/ros/jazzy/lib/python3.12/site-packages"
]
}
37 changes: 15 additions & 22 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,6 @@ endif()

# find dependencies
find_package(ament_cmake REQUIRED)
# uncomment the following section in order to fill in
# further dependencies manually.
# find_package(<dependency> REQUIRED)

# Add executable
add_executable(test_node src/test_node.cpp)
Expand All @@ -20,25 +17,21 @@ install(TARGETS
DESTINATION lib/${PROJECT_NAME})

if(BUILD_TESTING)
# find_package(ament_lint_auto REQUIRED)
# the following line skips the linter which checks for copyrights
# comment the line when a copyright and license is added to all source files
# set(ament_cmake_copyright_FOUND TRUE)
# the following line skips cpplint (only works in a git repo)
# comment the line when this package is in a git repo and when
# a copyright and license is added to all source files
# set(ament_cmake_cpplint_FOUND TRUE)
# ament_lint_auto_find_test_dependencies()


# simple gtest
find_package(ament_cmake_gtest REQUIRED)
ament_add_gtest(${PROJECT_NAME}_tutorial_test test/tutorial_test.cpp)
target_include_directories(${PROJECT_NAME}_tutorial_test PUBLIC
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:include>
)
# target_link_libraries(${PROJECT_NAME}_tutorial_test name_of_local_library)
# Manually specify only the linters we want to use
find_package(ament_cmake_cppcheck REQUIRED)
find_package(ament_cmake_lint_cmake REQUIRED)
find_package(ament_cmake_flake8 REQUIRED)
find_package(ament_cmake_pep257 REQUIRED)
find_package(ament_cmake_uncrustify REQUIRED)
find_package(ament_cmake_xmllint REQUIRED)

ament_cppcheck()
ament_lint_cmake()
ament_flake8()
ament_pep257()
ament_uncrustify()
ament_xmllint()

endif()

ament_package()
29 changes: 27 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,34 @@ https://www.blacksmith.sh/blog/cache-is-king-a-guide-for-docker-layer-caching-in
If I want to cache python deps:
https://docs.github.com/en/actions/reference/workflows-and-actions/dependency-caching


What I'm using:
https://github.com/marketplace/actions/ros-2-ci-action

To share the workflow across other repos:
https://docs.github.com/en/actions/how-tos/reuse-automations/reuse-workflows
https://docs.github.com/en/actions/how-tos/reuse-automations/reuse-workflows

Commands
colcon test
colcon test-result --verbose --all

find_package(ament_cmake_cppcheck REQUIRED)
find_package(ament_cmake_lint_cmake REQUIRED)
find_package(ament_cmake_flake8 REQUIRED)
find_package(ament_cmake_pep257 REQUIRED)
find_package(ament_cmake_uncrustify REQUIRED)
find_package(ament_cmake_xmllint REQUIRED)

ament_cppcheck()
ament_lint_cmake()
ament_flake8()
ament_pep257()
ament_uncrustify()
ament_xmllint()


The issue:
I need to run colcon build in order to run colcon test, which makes it hard to test submodules individually.

If I separate and directly use linters or formatters, they might not have the same configs as what ROS will use. Not too huge an issue

Just make sure colcon build works I guess
9 changes: 9 additions & 0 deletions requirements/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# colcon build deps
catkin_pkg
empy==3.3.4
lark
catkin-pkg
PyYAML
setuptools
jinja2
typeguard
2 changes: 1 addition & 1 deletion src/test_node.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include <iostream>

// hi
// hi 2
int main(int argc, char ** argv)
{
(void)argc;
Expand Down