diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index ea8d9db..bb53996 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -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 \ No newline at end of file diff --git a/.gitignore b/.gitignore index eacbeaf..696d757 100644 --- a/.gitignore +++ b/.gitignore @@ -34,4 +34,8 @@ # ROS specific build/ install/ -log/ \ No newline at end of file +log/ + +# other +.vscode/ +.venv/ \ No newline at end of file diff --git a/.vscode/settings.json b/.vscode/settings.json index 8e0ba0f..ae04379 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -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" + ] } \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt index e74dc16..5a1ea82 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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( REQUIRED) # Add executable add_executable(test_node src/test_node.cpp) @@ -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 - $ - $ - ) - # 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() diff --git a/README.md b/README.md index cd77c68..3ef8258 100644 --- a/README.md +++ b/README.md @@ -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 \ No newline at end of file +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 \ No newline at end of file diff --git a/requirements/requirements.txt b/requirements/requirements.txt new file mode 100644 index 0000000..469c334 --- /dev/null +++ b/requirements/requirements.txt @@ -0,0 +1,9 @@ +# colcon build deps +catkin_pkg +empy==3.3.4 +lark +catkin-pkg +PyYAML +setuptools +jinja2 +typeguard \ No newline at end of file diff --git a/src/test_node.cpp b/src/test_node.cpp index 0b6a6fe..4bb128b 100644 --- a/src/test_node.cpp +++ b/src/test_node.cpp @@ -1,6 +1,6 @@ #include -// hi +// hi 2 int main(int argc, char ** argv) { (void)argc;