From 67ffc023cbe5dff0e044a5bc51b73f19475c6dfb Mon Sep 17 00:00:00 2001 From: Chris Iverach-Brereton <59611394+civerachb-cpr@users.noreply.github.com> Date: Mon, 9 Sep 2024 15:36:24 -0400 Subject: [PATCH] Make tests pass on ROS 2 (#124) * Install the test assets to the share directory; otherwise the tests cannot locate the files to install * Check for the systemd config file, not upstart. Upstart check left but commented-out for legacy & reference * Add github workflows * Modify CI to make sure tests are run * Specify container * Roll back to official template (https://github.com/marketplace/actions/ros-2-ci-action), explicitly set skip-tests to false * Add CI for other supported ROS distros * Remove Foxy * Improve workspace fallback * Fix build status in the README * Set branches for CI (this repo also has ROS 1 branches we don't care about testing with the new CI) --- .github/workflows/ci.yml | 42 ++++++++++++++++++++++++++++++++++++++++ README.md | 3 +-- robot_upstart/job.py | 13 +++++++++---- setup.py | 2 ++ test/test_basics.py | 7 ++++++- 5 files changed, 60 insertions(+), 7 deletions(-) create mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..bce5d79 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,42 @@ +name: robot_upstart_ci + +on: + push: + branches: [foxy-devel] + pull_request: + branches: [foxy-devel] + +jobs: + jazzy_ci: + name: Jazzy + runs-on: ubuntu-24.04 + steps: + - uses: actions/checkout@v2.3.4 + - uses: ros-tooling/setup-ros@v0.7 + with: + required-ros-distributions: jazzy + - uses: ros-tooling/action-ros-ci@v0.3 + id: action_ros_ci_step + with: + target-ros2-distro: jazzy + import-token: ${{ secrets.GITHUB_TOKEN }} + skip-tests: false + package-name: + robot_upstart + + humble_ci: + name: Humble + runs-on: ubuntu-22.04 + steps: + - uses: actions/checkout@v2.3.4 + - uses: ros-tooling/setup-ros@v0.7 + with: + required-ros-distributions: humble + - uses: ros-tooling/action-ros-ci@v0.3 + id: action_ros_ci_step + with: + target-ros2-distro: humble + import-token: ${{ secrets.GITHUB_TOKEN }} + skip-tests: false + package-name: + robot_upstart \ No newline at end of file diff --git a/README.md b/README.md index 4e2c290..08f74b8 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,3 @@ -robot_upstart [![Build Status](https://travis-ci.org/clearpathrobotics/robot_upstart.svg?branch=jade-devel)](https://travis-ci.org/clearpathrobotics/robot_upstart) -============= +# robot_upstart [![robot_upstart_ci](https://github.com/clearpathrobotics/robot_upstart/actions/workflows/ci.yml/badge.svg?branch=foxy-devel)](https://github.com/clearpathrobotics/robot_upstart/actions/workflows/ci.yml) Clearpath Robotics presents a suite of scripts to assist with launching background ROS processes on Ubuntu Linux PCs. Please see the [generated documentation](http://docs.ros.org/latest-available/api/robot_upstart/html/) and [ROS Wiki](http://wiki.ros.org/robot_upstart). diff --git a/robot_upstart/job.py b/robot_upstart/job.py index 73b1e16..790aad2 100644 --- a/robot_upstart/job.py +++ b/robot_upstart/job.py @@ -82,13 +82,18 @@ def __init__(self, name="ros", rmw=None, rmw_config=None, interface=None, # Fall back on current user as the user to run ROS as. self.user = user or getpass.getuser() - # Fall back on current workspace setup file if not explicitly specified. - self.workspace_setup = workspace_setup or \ - os.environ['CMAKE_PREFIX_PATH'].split(':')[0] + '/../setup.bash' - # Fall back on current distro if not otherwise specified. self.rosdistro = rosdistro or os.environ['ROS_DISTRO'] + # Prioritize specified workspace, falling back to current workspace if possible, or + # system workspace as a last-resort + if workspace_setup: + self.workspace_setup = workspace_setup + elif 'CMAKE_PREFIX_PATH' in os.environ.keys(): + self.workspace_setup = os.environ['CMAKE_PREFIX_PATH'].split(':')[0] + '/../setup.bash' + else: + self.workspace_setup = f'/opt/ros/{self.rosdistro}/setup.bash' + self.rmw = rmw or "rmw_fastrtps_cpp" self.rmw_config = rmw_config or "" diff --git a/setup.py b/setup.py index 8d2278f..e859748 100644 --- a/setup.py +++ b/setup.py @@ -15,6 +15,8 @@ (os.path.join('lib', PACKAGE_NAME, 'scripts'), glob('scripts/*')), (os.path.join('share', PACKAGE_NAME, 'scripts'), glob('scripts/*')), (os.path.join('share', PACKAGE_NAME, 'templates'), glob('templates/*')), + (os.path.join('share', PACKAGE_NAME, 'test'), glob('test/*.py')), + (os.path.join('share', PACKAGE_NAME, 'test/launch'), glob('test/launch/*.launch')), ], install_requires=['setuptools'], zip_safe=True, diff --git a/test/test_basics.py b/test/test_basics.py index 6c89723..21fcc69 100644 --- a/test/test_basics.py +++ b/test/test_basics.py @@ -32,7 +32,12 @@ def test_install(self): self.assertTrue(os.path.exists(self.pjoin("usr/sbin/foo-start")), "Start script not created.") self.assertTrue(os.path.exists(self.pjoin("usr/sbin/foo-stop")), "Stop script not created.") - self.assertTrue(os.path.exists(self.pjoin("etc/init/foo.conf")), "Upstart configuration file not created.") + + # Systemd config + self.assertTrue(os.path.exists(self.pjoin("etc/systemd/system/multi-user.target.wants/foo.service")), "Systemd service file not created.") + + # Upstart config + #self.assertTrue(os.path.exists(self.pjoin("etc/init/foo.conf")), "Upstart configuration file not created.") self.assertEqual(0, subprocess.call(["bash", "-n", self.pjoin("usr/sbin/foo-start")]), "Start script not valid bash syntax.")