Skip to content
Closed
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
25 changes: 13 additions & 12 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM ros:jazzy AS dev
FROM ros@sha256:9749355a0760334fa5ea3c660f2de1ecc5e8a5af8047e4bbaa9afa8a7843da80 AS dev

# ********************************************************
# * Install Dependencies *
Expand All @@ -20,11 +20,6 @@ RUN apt-get update -q && \
apt-get install -y gnupg2 iputils-ping usbutils \
python3-argcomplete python3-colcon-common-extensions python3-networkx python3-pip python3-rosdep python3-vcstool

# Set up the ROS 2 environment
# This ensures that ROS 2 commands are available in the shell
RUN grep -F "source /opt/ros/jazzy/setup.bash" /root/.bashrc || echo "source /opt/ros/jazzy/setup.bash" >> /root/.bashrc && \
grep -F "source /usr/share/colcon_argcomplete/hook/colcon-argcomplete.bash" /root/.bashrc || echo "source /usr/share/colcon_argcomplete/hook/colcon-argcomplete.bash" >> /root/.bashrc

# Install Linux packages
# xterm: to use teleop_twist_keyboard
RUN apt-get update && apt-get install -y \
Expand Down Expand Up @@ -56,8 +51,11 @@ RUN apt-get update && apt-get install -y \
ros-jazzy-teleop-twist-joy \
ros-jazzy-fuse

# Install cyclonedds rmw and set up the configuration
RUN apt-get update && apt-get install -y \
ros-jazzy-rmw-cyclonedds-cpp
ENV RMW_IMPLEMENTATION=rmw_cyclonedds_cpp
ENV RMW_CYCLONEDDS_URI=file:///home/ws/config/cyclonedds.xml

# ********************************************************
# * Set up the user *
Expand All @@ -82,9 +80,15 @@ RUN apt-get update && apt-get upgrade -y
RUN apt-get install -y python3-pip
ENV SHELL=/bin/bash

# Define entrypoint
RUN mkdir -p /home/ws
COPY .devcontainer/entrypoint.sh /home/ws
RUN chmod +x /home/ws/entrypoint.sh
ENTRYPOINT [ "/home/ws/entrypoint.sh" ]
CMD ["/bin/bash"]

# [Optional] Set the default user. Omit if you want to keep the default as root.
USER $USERNAME
CMD ["/bin/bash"]

# ********************************************************
# * Production *
Expand All @@ -93,11 +97,8 @@ FROM dev AS prod

# Copy our packages into the image and build them
USER root
RUN mkdir -p /ws/src
WORKDIR /ws
WORKDIR /home/ws
COPY config config
COPY src src
RUN source /opt/ros/jazzy/setup.bash \
&& colcon build --symlink-install --cmake-args -DCMAKE_BUILD_TYPE=Release

ENTRYPOINT ["python3", "/ws/config/append_to_bashrc.py"]
&& colcon build --symlink-install --cmake-args -DCMAKE_BUILD_TYPE=Release
3 changes: 2 additions & 1 deletion .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"remoteUser": "htkz",
"build": {
"dockerfile": "Dockerfile",
"context": "..",
"target": "dev",
"args": {
"USERNAME": "htkz"
Expand Down Expand Up @@ -44,5 +45,5 @@
"source=/dev/dri,target=/dev/dri,type=bind,consistency=cached",
"source=/dev/input,target=/dev/input,type=bind,consistency=delegated"
],
"postCreateCommand": "sudo apt-get update && sudo rosdep update && sudo rosdep install --from-paths src --ignore-src -y && sudo chown -R $(whoami) /home/ws/ && python3 /home/ws/config/append_to_bashrc.py"
"postCreateCommand": "sudo chown -R $(whoami) /home/ws/ && python3 /home/ws/config/append_to_bashrc.py"
}
10 changes: 10 additions & 0 deletions .devcontainer/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#!/bin/bash
set +e

# Source environment variables
source /opt/ros/jazzy/setup.bash
source /home/ws/install/setup.bash
source /usr/share/colcon_argcomplete/hook/colcon-argcomplete.bash

# Execute the provided command
exec "$@"
53 changes: 32 additions & 21 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -1,15 +1,14 @@
name: docker build & colcon-test
name: Build Image and Run Tests

on:
push:
branches:
- microservices
pull_request:
branches:
- microservices
- '**'
- '!humble'
- '!jazzy'

jobs:
docker-build:
Build-image:
runs-on: ubuntu-latest

steps:
Expand All @@ -31,26 +30,38 @@ jobs:
with:
context: .
file: .devcontainer/Dockerfile
tags: ghcr.io/helbling-technik/github_actions:latest
cache-from: type=gha
cache-to: type=gha,mode=max
tags: ghcr.io/helbling-technik/helmoro-software-ros2:${{ github.ref_name }}-latest
push: true
cache-from: |
type=gha
type=registry,ref=ghcr.io/helbling-technik/helmoro-software-ros2:${{ github.ref_name }}-buildcache
cache-to: |
type=gha,mode=max
type=registry,ref=ghcr.io/helbling-technik/helmoro-software-ros2:${{ github.ref_name }}-buildcache,mode=max


colcon-test:
needs: docker-build
Run-tests:
needs: Build-image
runs-on: ubuntu-latest
defaults:
run:
working-directory: /home/ws
container:
image: ghcr.io/helbling-technik/github_actions:latest
image: ghcr.io/helbling-technik/helmoro-software-ros2:${{ github.ref_name }}-latest

steps:
- uses: ros-tooling/action-ros-ci@v0.4
id: action_ros_ci_step
with:
package-name: helmoro_description
target-ros2-distro: jazzy
coverage-result: false
- name: Run tests
shell: bash
run: |
set -e
source entrypoint.sh
colcon test
colcon test-result --all --verbose

- uses: actions/upload-artifact@v4
- name: Upload logs
uses: actions/upload-artifact@v4
with:
name: colcon-logs
path: ${{ steps.action_ros_ci_step.outputs.ros-workspace-directory-name }}/log
if: always() # upload the logs even when the build fails
path: /home/ws/log
if-no-files-found: error
if: always() # upload the logs even when the test fails
34 changes: 34 additions & 0 deletions .github/workflows/debug.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Run Tests

on:
push:
branches:
- '**'
- '!humble'
- '!jazzy'

jobs:
colcon-test:
runs-on: ubuntu-latest
defaults:
run:
working-directory: /home/ws
container:
image: ghcr.io/helbling-technik/helmoro-software-ros2:${{ github.ref_name }}-latest

steps:
- name: Run tests
shell: bash
run: |
set -e
source entrypoint.sh
colcon test
colcon test-result --all --verbose

- name: Upload logs
uses: actions/upload-artifact@v4
with:
name: colcon-logs
path: /home/ws/log
if-no-files-found: error
if: always() # upload the logs even when the test fails
3 changes: 1 addition & 2 deletions config/append_to_bashrc.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,7 @@ def append_unique_lines_to_bashrc(source_file):
print("ℹ️ No new lines were added. All lines already exist.")

if __name__ == "__main__":
append_unique_lines_to_bashrc(os.path.expanduser("/ws/config/append_to_bashrc.txt"))

append_unique_lines_to_bashrc(os.path.abspath("/home/ws/config/append_to_bashrc.txt"))

# If there are arguments passed to this container (i.e., CMD), run them
if len(sys.argv) > 1:
Expand Down
9 changes: 2 additions & 7 deletions config/append_to_bashrc.txt
Original file line number Diff line number Diff line change
@@ -1,10 +1,5 @@
# Custom Alias
alias src='source /opt/ros/jazzy/setub.bash && source /home/ws/install/setup.bash'

# Environment Setup
source /opt/ros/jazzy/setup.bash
source /home/ws/install/setup.bash
export RMW_IMPLEMENTATION=rmw_cyclonedds_cpp
export CYCLONEDDS_URI=file:///home/ws/config/cyclonedds.xml


# Integrate entrypoint.sh
source /home/ws/.devcontainer/entrypoint.sh
25 changes: 6 additions & 19 deletions src/helmoro_description/test/launch_description.test.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def generate_test_description():
ld.add_action(ready_to_test)
return ld

class TestRobotStatePublisher(unittest.TestCase):
class TestCollection(unittest.TestCase):
"""Test suite for checking the robot_state_publisher functionality."""

def setUp(self):
Expand All @@ -61,7 +61,7 @@ def tearDown(self):
self.node.destroy_node()
rclpy.shutdown()

def test_node_start(self, proc_output: ActiveIoHandler):
def test_robot_state_publisher_node_start(self, proc_output: ActiveIoHandler):
"""Test if the robot_state_publisher node has started."""
found = False
print('Waiting for node...')
Expand All @@ -75,7 +75,7 @@ def test_node_start(self, proc_output: ActiveIoHandler):
# Assert that the node was found
assert found, 'Node not found!'

def test_advertise_topic(self, proc_output: ActiveIoHandler):
def test_robot_state_publisher_advertise_topic(self, proc_output: ActiveIoHandler):
"""Test if the robot_description topic is advertised by the node."""
received = False
print("Listening for topics...")
Expand All @@ -94,7 +94,7 @@ def test_advertise_topic(self, proc_output: ActiveIoHandler):
# Assert that the topic was advertised
assert received, 'Topic not advertised!'

def test_publish_msgs(self, proc_output: ActiveIoHandler):
def test_robot_state_publisher_publish_msgs(self, proc_output: ActiveIoHandler):
"""Test if messages are published to the correct topic."""
msgs_rx = [] # List to store received messages

Expand Down Expand Up @@ -128,20 +128,7 @@ def test_publish_msgs(self, proc_output: ActiveIoHandler):
# Ensure that the subscription is destroyed after the test
self.node.destroy_subscription(sub)

class TestJointStatePublisher(unittest.TestCase):
"""Test suite for checking the joint_state_publisher functionality."""

def setUp(self):
"""Initialize the ROS node before each test."""
rclpy.init()
self.node = rclpy.create_node('test_node')

def tearDown(self):
"""Shut down the ROS node after each test."""
self.node.destroy_node()
rclpy.shutdown()

def test_node_start(self, proc_output: ActiveIoHandler):
def test_joint_state_publisher_node_start(self, proc_output: ActiveIoHandler):
"""Test if the joint_state_publisher node has started."""
found = False
print('Waiting for node...')
Expand All @@ -155,7 +142,7 @@ def test_node_start(self, proc_output: ActiveIoHandler):
# Assert that the node was found
assert found, 'Node not found!'

def test_advertise_topic(self, proc_output: ActiveIoHandler):
def test_joint_state_publisher_advertise_topic(self, proc_output: ActiveIoHandler):
"""Test if the joint_state topic is advertised by the node."""
received = False
print("Listening for topics...")
Expand Down
Loading