|
| 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 |
0 commit comments