|
| 1 | +name: ubuntu CI micro-ROS rcl |
| 2 | + |
| 3 | +# The container image is derived from the branch under test, which works |
| 4 | +# because the branch names are the distro names: |
| 5 | +# - kilted -> ros:kilted-ros-base (Ubuntu 24.04 noble) |
| 6 | +# - lyrical -> ros:lyrical-ros-base (Ubuntu 26.04 resolute) |
| 7 | +# - rolling -> ros:rolling-ros-base (Ubuntu 26.04 resolute) |
| 8 | +# |
| 9 | +# Besides push and pull_request, this is callable via workflow_call so a scheduled |
| 10 | +# workflow on the default branch can run it once per distro branch. Note that |
| 11 | +# `uses: ./.github/workflows/ci.yml` always resolves to the *caller's* copy of this |
| 12 | +# file, so the default branch's copy is what runs for every branch it tests; only |
| 13 | +# the checked-out source and the container image follow `inputs.branch`. |
| 14 | + |
| 15 | +on: |
| 16 | + push: |
| 17 | + branches: |
| 18 | + - kilted |
| 19 | + - lyrical |
| 20 | + - rolling |
| 21 | + pull_request: |
| 22 | + branches: |
| 23 | + - kilted |
| 24 | + - lyrical |
| 25 | + - rolling |
| 26 | + workflow_call: |
| 27 | + inputs: |
| 28 | + branch: |
| 29 | + description: > |
| 30 | + Distro branch to check out and test. Leave unset for push and |
| 31 | + pull_request, where the triggering ref is used instead. |
| 32 | + type: string |
| 33 | + required: false |
| 34 | + default: '' |
| 35 | + # To enable manual trigger |
| 36 | + workflow_dispatch: |
| 37 | + |
| 38 | +concurrency: |
| 39 | + group: ${{ github.workflow }}-${{ github.ref }}-${{ inputs.branch }} |
| 40 | + cancel-in-progress: true |
| 41 | + |
| 42 | +env: |
| 43 | + # Single source of truth for what gets built and tested. |
| 44 | + TESTED_PACKAGES: rcl rcl_action rcl_lifecycle |
| 45 | + |
| 46 | +defaults: |
| 47 | + run: |
| 48 | + shell: bash |
| 49 | + |
| 50 | +jobs: |
| 51 | + rcl_microros_ci: |
| 52 | + runs-on: ubuntu-latest |
| 53 | + # inputs.branch is used when this workflow is called |
| 54 | + # github.base_ref covers pull requests |
| 55 | + # github.ref_name is the branch on a push |
| 56 | + container: ros:${{ inputs.branch || github.base_ref || github.ref_name }}-ros-base |
| 57 | + timeout-minutes: 90 |
| 58 | + |
| 59 | + steps: |
| 60 | + - uses: actions/checkout@v5 |
| 61 | + with: |
| 62 | + # Empty on push and pull_request, which leaves checkout's own behaviour |
| 63 | + # intact — importantly the PR merge ref, so PRs keep testing the merge |
| 64 | + # result rather than the base branch. |
| 65 | + ref: ${{ inputs.branch }} |
| 66 | + path: src/rcl |
| 67 | + |
| 68 | + - name: Download dependencies |
| 69 | + run: | |
| 70 | + : "${ROS_DISTRO:?not set — is the container a ros:<distro>-ros-base image?}" |
| 71 | + . /opt/ros/$ROS_DISTRO/setup.bash |
| 72 | +
|
| 73 | + # The image ships no apt lists (every layer of its Dockerfile ends in |
| 74 | + # `rm -rf /var/lib/apt/lists/*`) and rosdep does not refresh them itself, |
| 75 | + # so this is required before rosdep can install anything. |
| 76 | + apt-get update |
| 77 | +
|
| 78 | + # Every rcl test dependency (mimick_vendor, osrf_testing_tools_cpp, |
| 79 | + # test_msgs, launch_testing_ament_cmake, ...) is a released binary. |
| 80 | + # rosdep is already initialised in the image; only its cache is stale. |
| 81 | + rosdep update --rosdistro $ROS_DISTRO |
| 82 | + rosdep install --from-paths src --ignore-src --rosdistro $ROS_DISTRO -r -y |
| 83 | +
|
| 84 | + - name: Build |
| 85 | + # GitHub replaces the image's entrypoint for container jobs, so |
| 86 | + # /ros_entrypoint.sh never runs and each step must source ROS itself. |
| 87 | + run: | |
| 88 | + . /opt/ros/$ROS_DISTRO/setup.bash |
| 89 | + colcon --log-base /dev/null build \ |
| 90 | + --event-handlers console_direct+ \ |
| 91 | + --packages-up-to $TESTED_PACKAGES \ |
| 92 | + --cmake-args -DCMAKE_BUILD_TYPE=Release -DRCL_MICROROS=ON |
| 93 | +
|
| 94 | + - name: Test |
| 95 | + run: | |
| 96 | + . /opt/ros/$ROS_DISTRO/setup.bash |
| 97 | + colcon --log-base /dev/null test \ |
| 98 | + --event-handlers console_direct+ \ |
| 99 | + --return-code-on-test-failure \ |
| 100 | + --packages-select $TESTED_PACKAGES |
| 101 | +
|
| 102 | + - name: Test results |
| 103 | + # The per-package tallies colcon prints are not a cross-package summary; |
| 104 | + # this step is. It runs even when the test step failed. |
| 105 | + if: ${{ !cancelled() }} |
| 106 | + run: | |
| 107 | + . /opt/ros/$ROS_DISTRO/setup.bash |
| 108 | + colcon test-result --verbose |
0 commit comments