Theme
Tier 4 · lesson 6 of 10 · 40 min

CI that runs what you run

You will: Make CI execute exactly what you run locally, and make it check decisions as well as tests.

Builds on A simulator that runs in CI and Keeping the suite fast is a feature you maintain.

The principle is one sentence: CI runs what you run. It builds the same Dockerfile, to the ci stage, and executes the same commands your machine does. A green tick means the thing you ran passed — not that a parallel pipeline happens to agree with it.

Two architectures, deliberately. Development happens on Apple Silicon and most servers are x86. Running both is the only way to catch divergence in either direction.

Beyond "the tests pass", CI asserts three decisions, because decisions rot silently:

  1. No mixed Gazebo installation — fail if any Gazebo package resolves from the second apt repository, because the failure otherwise appears much later as a segfault.
  2. xacro.load_yaml still exists — the single-source design rests on it, and if a future release removed it, this fails with a clear message rather than a confusing expansion error.
  3. The seam is intact — checked on the expanded descriptions as files, not only as a unit test.

And it uploads the expanded robot descriptions as an artefact, so a reviewer can diff the actual robot a pull request produces rather than reasoning about macros.

What CI caught here was mostly habits, not code. A lint failure was missed locally because the output was searched for text instead of the exit status being checked. A release workflow raced the image it was meant to publish. A version tag was pushed without the version file being bumped — and the release refused.

One honest caveat, true of this repository as you read it: CI runs on pushes to main and on pull requests. Work on a branch that has never been opened as a pull request has never been through CI, however green it is locally.

In the simulation

CI's promise is that the same input gives the same result wherever it runs. Record and replay is the arm-sized version: the same setpoints, played again, put the arm in the same place. The page runs on one machine; it cannot show you two architectures, or any CI.

Kinematic: joints move at their real speed limit, but there is no gravity, no load and no physics. That is what the steps below are for.

The SO-101 loads as you reach it.

In this lesson

  1. Press Record, move two or three joints, and press it again to stop.
  2. Press h to home the arm. Note where the recording ended.
  3. Press Replay, and watch the arm end exactly where the recording did.

Do it

  1. Read the workflow. Find the three decision checks.

    less .github/workflows/ci.yml
    
  2. Run CI's seam check yourself, exactly as CI does, inside the container. CI runs it on the profiles this project generates itself; the SO-101's is not in CI yet, because CI does not fetch its description. That is a gap, and a good first contribution.

    make shell
    S=/ws/install/threevn_robot_description/share/threevn_robot_description
    for t in mock gz esp32; do
      ros2 run xacro xacro "$S/urdf/threevn_arm.urdf.xacro" params_file:="$S/config/threevn_arm_v1.yaml" target:=$t > /tmp/$t.urdf
    done
    ! grep -q "gz_ros2_control\|<gazebo" /tmp/mock.urdf && echo "mock is clean"
    
  3. Push the repository to your own GitHub copy, open a pull request with a deliberately failing test, and watch both architectures go red. Then fix it and watch them go green.

You will know it worked when: You have seen CI fail and pass on your own copy, on both architectures, for a change you made.

When it goes wrong

Lint "passed" locally and failed in CI.

Why: The local check searched the output for a word rather than checking the exit status.

Fix: Exit codes are the contract. echo $?, or set -e in scripts.

A failure appears only on one architecture.

Why: A binary dependency, a floating-point difference, or an image layer that differs by platform.

Fix: That is the reason both run. Reproduce on the failing architecture before guessing.

Terms

CI parity
CI running the same image and the same commands as a developer's machine, so local green and CI green mean the same thing.
Build matrix
One job run across several configurations — here amd64 and arm64.
Decision check
A CI step that asserts an architectural decision still holds, not just that tests pass.

Every term in the course: glossary.

Check yourself

Answer in your head first, then open it.

Why check in CI that xacro.load_yaml exists, when every test would fail without it anyway?

Every test would fail with a confusing expansion error. The direct check fails with the actual cause, in one line, the first time it happens.

Why upload the expanded descriptions as an artefact?

So a reviewer can diff the robot a pull request actually produces, rather than reasoning about what a macro change does.

Stretch

Pick a decision from docs/decisions/ that CI does not yet check. Add a step to your copy of ci.yml that fails when the decision is violated, and prove it on a pull request that violates it.

Hint

A good decision check fails in one line with the actual cause. The course curriculum is checked this way: python3 scripts/build_site.py --check fails a pull request whose lessons point at a Make target or a document that does not exist.

Going deeper