Skip to content

Commit cc5d34a

Browse files
Update build and CI (backport #329) (#333)
* Update build and CI (#329) * Update build and CI Signed-off-by: David Laseca Perez <davidlaseca@eprosima.com> * Change base image Signed-off-by: David Laseca Perez <davidlaseca@eprosima.com> * Fix build in CI Signed-off-by: David Laseca Perez <davidlaseca@eprosima.com> * Fix build visibility Signed-off-by: David Laseca Perez <davidlaseca@eprosima.com> * Fix agent build Signed-off-by: David Laseca Perez <davidlaseca@eprosima.com> * Fix agent build 2 Signed-off-by: David Laseca Perez <davidlaseca@eprosima.com> * Update 'general-issue.md' Signed-off-by: David Laseca Perez <davidlaseca@eprosima.com> * Fix agent build 3 Signed-off-by: David Laseca Perez <davidlaseca@eprosima.com> * Fix agent build 4 Signed-off-by: David Laseca Perez <davidlaseca@eprosima.com> * Use agent test branch to test fix Signed-off-by: David Laseca Perez <davidlaseca@eprosima.com> * Use updated agent branch Signed-off-by: David Laseca Perez <davidlaseca@eprosima.com> * Add humble and jazzy to the CI Signed-off-by: David Laseca Perez <davidlaseca@eprosima.com> * Address suggestions Signed-off-by: David Laseca Perez <davidlaseca@eprosima.com> --------- Signed-off-by: David Laseca Perez <davidlaseca@eprosima.com> (cherry picked from commit fdd4c91) # Conflicts: # .github/ISSUE_TEMPLATE/general-issue.md # .github/workflows/ci.yml * Fix conflict Signed-off-by: David Laseca Perez <davidlaseca@eprosima.com> * Fix conflict 2 Signed-off-by: David Laseca Perez <davidlaseca@eprosima.com> --------- Signed-off-by: David Laseca Perez <davidlaseca@eprosima.com> Co-authored-by: David Laseca Perez <davidlaseca@eprosima.com>
1 parent 6b10d6e commit cc5d34a

6 files changed

Lines changed: 236 additions & 68 deletions

File tree

‎.github/ISSUE_TEMPLATE/general-issue.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ assignees: ''
1212
- Hardware description: <!-- hardware where you are using micro-ROS -->
1313
- RTOS: <!-- RTOS where you are using micro-ROS -->
1414
- Installation type: <!-- micro_ros_setup, modules, etc -->
15-
- Version or commit hash: <!-- version of micro-ROS used: humble, jazzy, kilted, rolling -->
15+
- Version or commit hash: <!-- version of micro-ROS used: humble, jazzy, kilted, lyrical, rolling -->
1616

1717
#### Steps to reproduce the issue
1818
<!-- Detailed instructions on how to reliably reproduce this issue http://sscce.org/-->

‎.github/workflows/ci.yml‎

Lines changed: 0 additions & 63 deletions
This file was deleted.

‎.github/workflows/ubuntu-ci.yml‎

Lines changed: 194 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,194 @@
1+
name: ubuntu CI micro-ROS rmw_microxrcedds
2+
3+
# The container image is derived from the branch under test, which works because the
4+
# branch names are the distro names:
5+
# - humble -> ros:humble-ros-base
6+
# - jazzy -> ros:jazzy-ros-base
7+
# - kilted -> ros:kilted-ros-base
8+
# - lyrical -> ros:lyrical-ros-base
9+
# - rolling -> ros:rolling-ros-base
10+
#
11+
# The plain distro image is used rather than microros/micro-ROS-Agent:<distro> so that
12+
# nothing depends on those Agent tags existing per distro, and so that the whole
13+
# workspace is built from one consistent set of sources. The tests need a live Agent on
14+
# udp4:8888, so microxrcedds_agent and micro-ROS-Agent are built here: neither is
15+
# released into any ROS distro, so there is no binary to install.
16+
#
17+
# Besides push and pull_request, this is callable via workflow_call so a scheduled
18+
# workflow on the default branch can run it once per distro branch. Note that
19+
# `uses: ./.github/workflows/ubuntu-ci.yml` always resolves to the *caller's* copy of
20+
# this file, so the default branch's copy is what runs for every branch it tests; only
21+
# the container image and the checked-out sources follow `inputs.branch`.
22+
23+
on:
24+
push:
25+
branches:
26+
- humble
27+
- jazzy
28+
- kilted
29+
- lyrical
30+
- rolling
31+
pull_request:
32+
branches:
33+
- humble
34+
- jazzy
35+
- kilted
36+
- lyrical
37+
- rolling
38+
workflow_call:
39+
inputs:
40+
branch:
41+
description: >
42+
Distro branch to check out and test. Leave unset for push and
43+
pull_request, where the triggering ref is used instead.
44+
type: string
45+
required: false
46+
default: ''
47+
# To enable manual trigger
48+
workflow_dispatch:
49+
50+
concurrency:
51+
group: ${{ github.workflow }}-${{ github.ref }}-${{ inputs.branch }}
52+
cancel-in-progress: true
53+
54+
env:
55+
# Single source of truth for what gets tested.
56+
TESTED_PACKAGES: rmw_microxrcedds
57+
# Coverage instrumentation: --coverage/-ftest-coverage emit the .gcno and .gcda files
58+
# gcovr reads, and the -fno-inline flags keep the counts mapped onto the original
59+
# source lines instead of onto inlined copies.
60+
COVERAGE_FLAGS: >-
61+
-ftest-coverage --coverage -fno-inline -fno-inline-small-functions -fno-default-inline
62+
63+
defaults:
64+
run:
65+
shell: bash
66+
67+
jobs:
68+
rmw_microxrcedds_ci:
69+
runs-on: ubuntu-latest
70+
# inputs.branch is used when this workflow is called
71+
# github.base_ref covers pull requests
72+
# github.ref_name is the branch on a push
73+
container: ros:${{ inputs.branch || github.base_ref || github.ref_name }}-ros-base
74+
timeout-minutes: 90
75+
76+
steps:
77+
- uses: actions/checkout@v5
78+
with:
79+
# Empty on push and pull_request, which leaves checkout's own behaviour
80+
# intact — importantly the PR merge ref, so PRs keep testing the merge
81+
# result rather than the base branch.
82+
ref: ${{ inputs.branch }}
83+
path: src/rmw-microxrcedds
84+
85+
- name: Download dependencies
86+
run: |
87+
. /opt/ros/$ROS_DISTRO/setup.bash
88+
89+
# The image ships no apt lists
90+
apt-get update
91+
apt-get install -y \
92+
build-essential \
93+
git \
94+
gcovr \
95+
python3-colcon-common-extensions \
96+
python3-rosdep \
97+
ros-$ROS_DISTRO-performance-test-fixture
98+
99+
# Micro-CDR and the XRCE Client are distro independent and pinned;
100+
# the type support and the Agent wrapper track the distro under test.
101+
git clone -b v2.0.2 https://github.com/eProsima/Micro-CDR src/Micro-CDR
102+
git clone -b v3.0.2 https://github.com/eProsima/Micro-XRCE-DDS-Client src/Micro-XRCE-DDS-Client
103+
git clone -b $ROS_DISTRO https://github.com/micro-ROS/micro-ROS-Agent src/micro-ROS-Agent
104+
git clone -b $ROS_DISTRO https://github.com/micro-ROS/rosidl_typesupport_microxrcedds src/rosidl_typesupport_microxrcedds
105+
touch src/rosidl_typesupport_microxrcedds/test/COLCON_IGNORE
106+
107+
# rmw is taken from the image rather than built from source
108+
109+
# in case rosdep is not yet initialised
110+
rosdep init 2>/dev/null || true
111+
rosdep update --rosdistro $ROS_DISTRO
112+
113+
# micro-ROS-Agent declares a dependency on microxrcedds_agent, but it, together
114+
# with microxrcedds_client and microcdr, are built from source in this workflow,
115+
# so skip those keys here
116+
rosdep install --from-paths src --ignore-src --rosdistro $ROS_DISTRO -y \
117+
--skip-keys "microcdr microxrcedds_client microxrcedds_agent"
118+
119+
- name: Build
120+
id: build
121+
# GitHub replaces the image's entrypoint for container jobs, so
122+
# /ros_entrypoint.sh never runs and each step must source ROS itself.
123+
run: |
124+
. /opt/ros/$ROS_DISTRO/setup.bash
125+
126+
# The package under test first, so a failure here is reported before the several
127+
# minutes the Agent takes to build.
128+
colcon build \
129+
--symlink-install \
130+
--event-handlers console_direct+ \
131+
--packages-up-to $TESTED_PACKAGES \
132+
--cmake-args \
133+
-DBUILD_SHARED_LIBS=ON \
134+
-DCMAKE_C_FLAGS="$COVERAGE_FLAGS" \
135+
-DCMAKE_CXX_FLAGS="$COVERAGE_FLAGS" \
136+
-DCMAKE_C_OUTPUT_EXTENSION_REPLACE=ON \
137+
-DCMAKE_CXX_OUTPUT_EXTENSION_REPLACE=ON
138+
139+
# The Agent is only test infrastructure, so it is built optimised and without
140+
# coverage instrumentation. micro-ROS-Agent's superbuild clones and builds the XRCE
141+
# Agent itself, taking fastcdr and fastdds from the image (UAGENT_USE_SYSTEM_FASTDDS/
142+
# FASTCDR are forced ON by that superbuild); the logger keeps its default of building
143+
# spdlog from source, since UAGENT_USE_SYSTEM_LOGGER=ON pulls in a newer system
144+
# spdlog/fmt that the Agent's logging calls aren't compatible with.
145+
colcon build \
146+
--symlink-install \
147+
--event-handlers console_direct+ \
148+
--packages-up-to micro_ros_agent \
149+
--cmake-args -DCMAKE_BUILD_TYPE=Release
150+
151+
- name: Test
152+
run: |
153+
. /opt/ros/$ROS_DISTRO/setup.bash
154+
. install/local_setup.bash
155+
156+
# The tests establish real XRCE sessions, so an Agent has to be running before colcon test starts
157+
# The Agent must not pick up the implementation under test as its own middleware
158+
RMW_IMPLEMENTATION=rmw_fastrtps_cpp ros2 run micro_ros_agent micro_ros_agent udp4 --port 8888 -d -v4 &
159+
sleep 1
160+
161+
colcon test \
162+
--event-handlers console_direct+ \
163+
--return-code-on-test-failure \
164+
--packages-select $TESTED_PACKAGES
165+
166+
- name: Static memory report
167+
# Kept separate from the test step so it still runs when a test fails,
168+
# but needs the build to succeed
169+
if: ${{ !cancelled() && steps.build.outcome == 'success' }}
170+
run: |
171+
. /opt/ros/$ROS_DISTRO/setup.bash
172+
./build/rmw_microxrcedds/test/test-sizes 2> memanalisys_out
173+
174+
- name: Test results
175+
if: ${{ !cancelled() }}
176+
run: |
177+
. /opt/ros/$ROS_DISTRO/setup.bash
178+
colcon test-result --verbose
179+
180+
- name: Coverage report
181+
# gcovr has no .gcda files to read if the build never produced any
182+
if: ${{ !cancelled() && steps.build.outcome == 'success' }}
183+
run: |
184+
cd src/rmw-microxrcedds
185+
gcovr -x -r . -o coverage.xml ../../build \
186+
--exclude-unreachable-branches \
187+
--exclude rmw_microxrcedds_c/test
188+
189+
- name: Upload coverage
190+
uses: codecov/codecov-action@v5
191+
with:
192+
token: ${{ secrets.CODECOV_TOKEN }}
193+
files: src/rmw-microxrcedds/coverage.xml
194+
fail_ci_if_error: false
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: Weekly ubuntu CI micro-ROS rmw_microxrcedds
2+
3+
on:
4+
schedule:
5+
# Mondays at 02:00 UTC
6+
- cron: '0 2 * * 1'
7+
# To enable manual trigger
8+
workflow_dispatch:
9+
10+
jobs:
11+
ubuntu_ci:
12+
name: ${{ matrix.branch }}
13+
strategy:
14+
# Without this, one distro failing would cancel the others and
15+
# hide if they are fine
16+
fail-fast: false
17+
matrix:
18+
branch:
19+
- humble
20+
- jazzy
21+
- kilted
22+
- lyrical
23+
- rolling
24+
uses: ./.github/workflows/ubuntu-ci.yml
25+
with:
26+
branch: ${{ matrix.branch }}
27+
# Reusable workflows do not receive the caller's secrets automatically, and the
28+
# called workflow needs CODECOV_TOKEN for the coverage upload.
29+
secrets: inherit

‎rmw_microxrcedds_c/CMakeLists.txt‎

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,15 +12,15 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
cmake_minimum_required(VERSION 3.5)
15+
cmake_minimum_required(VERSION 3.10)
1616
cmake_policy(SET CMP0057 NEW)
1717

1818
set(PACKAGE_VERSION "1.0.0")
1919
project(rmw_microxrcedds
2020
VERSION
2121
${PACKAGE_VERSION}
2222
LANGUAGES
23-
C
23+
C CXX
2424
)
2525

2626
find_package(ament_cmake_ros REQUIRED)
@@ -286,7 +286,15 @@ target_link_libraries(${PROJECT_NAME}
286286
microxrcedds_client
287287
)
288288

289-
configure_rmw_library(${PROJECT_NAME})
289+
# LANGUAGE C is required: the default (CXX) adds -fvisibility-inlines-hidden, which gcc rejects
290+
# for the C sources this library is built from.
291+
configure_rmw_library(${PROJECT_NAME} LANGUAGE C)
292+
293+
# configure_rmw_library() adds -fvisibility=hidden, this must stay *after* configure_rmw_library()
294+
target_compile_options(${PROJECT_NAME}
295+
PRIVATE
296+
-fvisibility=default
297+
)
290298

291299
target_include_directories(${PROJECT_NAME}
292300
PUBLIC

‎rmw_microxrcedds_c/test/CMakeLists.txt‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
1414

15-
cmake_minimum_required(VERSION 3.5)
15+
cmake_minimum_required(VERSION 3.10)
1616

1717
find_package(ament_cmake_gtest REQUIRED)
1818

0 commit comments

Comments
 (0)