Skip to content

Commit

Permalink
Make tests pass on ROS 2 (#124)
Browse files Browse the repository at this point in the history
* 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)
  • Loading branch information
civerachb-cpr authored Sep 9, 2024
1 parent 12340f4 commit 67ffc02
Show file tree
Hide file tree
Showing 5 changed files with 60 additions and 7 deletions.
42 changes: 42 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -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
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -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).
13 changes: 9 additions & 4 deletions robot_upstart/job.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 ""
Expand Down
2 changes: 2 additions & 0 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
7 changes: 6 additions & 1 deletion test/test_basics.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.")
Expand Down

0 comments on commit 67ffc02

Please sign in to comment.