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
62 changes: 0 additions & 62 deletions .github/workflows/ci.yml

This file was deleted.

204 changes: 204 additions & 0 deletions .github/workflows/ubuntu-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,204 @@
name: ubuntu CI micro-ROS rmw_microxrcedds

# The container image is derived from the branch under test, which works because the
# branch names are the distro names:
# - kilted -> ros:kilted-ros-base
# - lyrical -> ros:lyrical-ros-base
# - rolling -> ros:rolling-ros-base
#
# The plain distro image is used rather than microros/micro-ROS-Agent:<distro> so that
# nothing depends on those Agent tags existing per distro, and so that the whole
# workspace is built from one consistent set of sources. The tests need a live Agent on
# udp4:8888, so microxrcedds_agent and micro-ROS-Agent are built here: neither is
# released into any ROS distro, so there is no binary to install.
#
# Besides push and pull_request, this is callable via workflow_call so a scheduled
# workflow on the default branch can run it once per distro branch. Note that
# `uses: ./.github/workflows/ubuntu-ci.yml` always resolves to the *caller's* copy of
# this file, so the default branch's copy is what runs for every branch it tests; only
# the container image and the checked-out sources follow `inputs.branch`.

on:
push:
branches:
- kilted
- lyrical
- rolling
pull_request:
branches:
- kilted
- lyrical
- rolling
workflow_call:
inputs:
branch:
description: >
Distro branch to check out and test. Leave unset for push and
pull_request, where the triggering ref is used instead.
type: string
required: false
default: ''
# To enable manual trigger
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-${{ inputs.branch }}
cancel-in-progress: true

env:
# Single source of truth for what gets tested.
TESTED_PACKAGES: rmw_microxrcedds
# Coverage instrumentation: --coverage/-ftest-coverage emit the .gcno and .gcda files
# gcovr reads, and the -fno-inline flags keep the counts mapped onto the original
# source lines instead of onto inlined copies.
COVERAGE_FLAGS: >-
-ftest-coverage --coverage -fno-inline -fno-inline-small-functions -fno-default-inline

defaults:
run:
shell: bash

jobs:
rmw_microxrcedds_ci:
runs-on: ubuntu-latest
# inputs.branch is used when this workflow is called
# github.base_ref covers pull requests
# github.ref_name is the branch on a push
container: ros:${{ inputs.branch || github.base_ref || github.ref_name }}-ros-base
timeout-minutes: 90

steps:
- uses: actions/checkout@v5
with:
# Empty on push and pull_request, which leaves checkout's own behaviour
# intact — importantly the PR merge ref, so PRs keep testing the merge
# result rather than the base branch.
ref: ${{ inputs.branch }}
path: src/rmw-microxrcedds

- name: Download dependencies
run: |
. /opt/ros/$ROS_DISTRO/setup.bash

# The image ships no apt lists
apt-get update
apt-get install -y \
build-essential \
git \
gcovr \
python3-colcon-common-extensions \
python3-rosdep \
ros-$ROS_DISTRO-performance-test-fixture

# Micro-CDR and the XRCE Client are distro independent and pinned;
# the type support and the Agent wrapper track the distro under test.
git clone -b v2.0.2 https://github.com/eProsima/Micro-CDR src/Micro-CDR
git clone -b v3.0.1 https://github.com/eProsima/Micro-XRCE-DDS-Client src/Micro-XRCE-DDS-Client
git clone -b $ROS_DISTRO https://github.com/micro-ROS/micro-ROS-Agent src/micro-ROS-Agent
git clone -b $ROS_DISTRO https://github.com/micro-ROS/rosidl_typesupport_microxrcedds src/rosidl_typesupport_microxrcedds
touch src/rosidl_typesupport_microxrcedds/test/COLCON_IGNORE

# rmw is taken from the image rather than built from source

# micro-ROS-Agent runs its own superbuild
# The logger has to be disabled because it causes build issues and is not needed for the tests,
# the superbuild is patched here for that reason
agent_superbuild=src/micro-ROS-Agent/micro_ros_agent/cmake/SuperBuild.cmake
grep -q 'UAGENT_USE_SYSTEM_LOGGER:BOOL' "$agent_superbuild"
sed -i 's|\(-DUAGENT_USE_SYSTEM_LOGGER:BOOL=.*\)|\1\n -DUAGENT_LOGGER_PROFILE:BOOL=OFF|' \
"$agent_superbuild"
grep -q 'UAGENT_LOGGER_PROFILE:BOOL=OFF' "$agent_superbuild"

# in case rosdep is not yet initialised
rosdep init 2>/dev/null || true
rosdep update --rosdistro $ROS_DISTRO

# micro-ROS-Agent declares a dependency on microxrcedds_agent, but it, together
# with microxrcedds_client and microcdr, are built from source in this workflow,
# so skip those keys here
rosdep install --from-paths src --ignore-src --rosdistro $ROS_DISTRO -y \
--skip-keys "microcdr microxrcedds_client microxrcedds_agent"

- name: Build
id: build
# GitHub replaces the image's entrypoint for container jobs, so
# /ros_entrypoint.sh never runs and each step must source ROS itself.
run: |
. /opt/ros/$ROS_DISTRO/setup.bash

# The package under test first, so a failure here is reported before the several
# minutes the Agent takes to build.
colcon build \
--symlink-install \
--event-handlers console_direct+ \
--packages-up-to $TESTED_PACKAGES \
--cmake-args \
-DBUILD_SHARED_LIBS=ON \
-DCMAKE_C_FLAGS="$COVERAGE_FLAGS" \
-DCMAKE_CXX_FLAGS="$COVERAGE_FLAGS" \
-DCMAKE_C_OUTPUT_EXTENSION_REPLACE=ON \
-DCMAKE_CXX_OUTPUT_EXTENSION_REPLACE=ON

# The Agent is only test infrastructure, so it is built optimised and without
# coverage instrumentation. micro-ROS-Agent's superbuild clones and builds the XRCE
# Agent itself, taking fastcdr and fastdds from the image; the logger is disabled by
# the patch applied in the previous step.
colcon build \
--symlink-install \
--event-handlers console_direct+ \
--packages-up-to micro_ros_agent \
--cmake-args -DCMAKE_BUILD_TYPE=Release #-DUAGENT_LOGGER_PROFILE=OFF

- name: Test
run: |
. /opt/ros/$ROS_DISTRO/setup.bash
. install/local_setup.bash

# The tests establish real XRCE sessions, so an Agent has to be running before colcon test starts
# The Agent must not pick up the implementation under test as its own middleware
RMW_IMPLEMENTATION=rmw_fastrtps_cpp ros2 run micro_ros_agent micro_ros_agent udp4 --port 8888 -d -v4 &
sleep 1

colcon test \
--event-handlers console_direct+ \
--return-code-on-test-failure \
--packages-select $TESTED_PACKAGES

- name: Static memory report
# Kept separate from the test step so it still runs when a test fails,
# but needs the build to succeed
if: ${{ !cancelled() && steps.build.outcome == 'success' }}
run: |
. /opt/ros/$ROS_DISTRO/setup.bash
./build/rmw_microxrcedds/test/test-sizes 2> memanalisys_out

# - name: Static memory
# continue-on-error: true
# if: github.event_name == 'pull_request'
# uses: machine-learning-apps/pr-comment@master
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
# with:
# path: memanalisys_out

- name: Test results
if: ${{ !cancelled() }}
run: |
. /opt/ros/$ROS_DISTRO/setup.bash
colcon test-result --verbose

- name: Coverage report
# gcovr has no .gcda files to read if the build never produced any
if: ${{ !cancelled() && steps.build.outcome == 'success' }}
run: |
cd src/rmw-microxrcedds
gcovr -x -r . -o coverage.xml ../../build \
--exclude-unreachable-branches \
--exclude rmw_microxrcedds_c/test

- name: Upload coverage
uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
files: src/rmw-microxrcedds/coverage.xml
fail_ci_if_error: false
27 changes: 27 additions & 0 deletions .github/workflows/weekly-ubuntu-ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Weekly ubuntu CI micro-ROS rmw_microxrcedds

on:
schedule:
# Mondays at 02:00 UTC
- cron: '0 2 * * 1'
# To enable manual trigger
workflow_dispatch:

jobs:
ubuntu_ci:
name: ${{ matrix.branch }}
strategy:
# Without this, one distro failing would cancel the others and
# hide if they are fine
fail-fast: false
matrix:
branch:
- kilted
- lyrical
- rolling
uses: ./.github/workflows/ubuntu-ci.yml
with:
branch: ${{ matrix.branch }}
# Reusable workflows do not receive the caller's secrets automatically, and the
# called workflow needs CODECOV_TOKEN for the coverage upload.
secrets: inherit
14 changes: 11 additions & 3 deletions rmw_microxrcedds_c/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,15 +12,15 @@
# See the License for the specific language governing permissions and
# limitations under the License.

cmake_minimum_required(VERSION 3.5)
cmake_minimum_required(VERSION 3.10)
cmake_policy(SET CMP0057 NEW)

set(PACKAGE_VERSION "1.0.0")
project(rmw_microxrcedds
VERSION
${PACKAGE_VERSION}
LANGUAGES
C
C CXX
)

find_package(ament_cmake_ros REQUIRED)
Expand Down Expand Up @@ -286,7 +286,15 @@ target_link_libraries(${PROJECT_NAME}
microxrcedds_client
)

configure_rmw_library(${PROJECT_NAME})
# LANGUAGE C is required: the default (CXX) adds -fvisibility-inlines-hidden, which gcc rejects
# for the C sources this library is built from.
configure_rmw_library(${PROJECT_NAME} LANGUAGE C)

# configure_rmw_library() adds -fvisibility=hidden, this must stay *after* configure_rmw_library()
target_compile_options(${PROJECT_NAME}
PRIVATE
-fvisibility=default
)

target_include_directories(${PROJECT_NAME}
PUBLIC
Expand Down
2 changes: 1 addition & 1 deletion rmw_microxrcedds_c/test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# See the License for the specific language governing permissions and
# limitations under the License.

cmake_minimum_required(VERSION 3.5)
cmake_minimum_required(VERSION 3.10)

find_package(ament_cmake_gtest REQUIRED)

Expand Down
Loading