From 68e55cfc2a1dc7b459b78e96beac4567511975bc Mon Sep 17 00:00:00 2001 From: Ramon Roche Date: Wed, 8 Apr 2026 00:18:08 -0700 Subject: [PATCH] ci(ros): use matching branch for px4-ros2-interface-lib (1.17) Backport of #26781 with the follow-up fix from #27000 folded in. On release branches, the ROS integration test now clones a matching branch from Auterion/px4-ros2-interface-lib instead of always using main, preventing build failures from uORB message divergence between main and release branches. Branch resolution uses GITHUB_BASE_REF on pull requests (the branch the code is merging into) and falls back to GITHUB_REF_NAME for direct pushes, so backport PRs resolve to their target release branch instead of the PR author's branch. Fixes https://github.com/Auterion/px4-ros2-interface-lib/issues/184 Signed-off-by: Ramon Roche --- .github/workflows/ros_integration_tests.yml | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ros_integration_tests.yml b/.github/workflows/ros_integration_tests.yml index 022b46fb10..d45c6cd36c 100644 --- a/.github/workflows/ros_integration_tests.yml +++ b/.github/workflows/ros_integration_tests.yml @@ -89,7 +89,17 @@ jobs: . /opt/ros/galactic/setup.bash mkdir -p /opt/px4_ws/src cd /opt/px4_ws/src - git clone --recursive https://github.com/Auterion/px4-ros2-interface-lib.git + # On a PR, target the branch we're merging into (main or release/X.Y). + # On a direct push, fall back to the branch we're running on. + BRANCH="${GITHUB_BASE_REF:-$GITHUB_REF_NAME}" + REPO_URL="https://github.com/Auterion/px4-ros2-interface-lib.git" + if git ls-remote --heads "$REPO_URL" "$BRANCH" | grep -q "$BRANCH"; then + echo "Cloning px4-ros2-interface-lib with matching branch: $BRANCH" + git clone --recursive --branch "$BRANCH" "$REPO_URL" + else + echo "Branch '$BRANCH' not found in px4-ros2-interface-lib, using default (main)" + git clone --recursive "$REPO_URL" + fi cd .. # Copy messages to ROS workspace "${PX4_DIR}/Tools/copy_to_ros_ws.sh" "$(pwd)"