From 2a4d473ba40303c26ecc7fca7300b4fbb3e66686 Mon Sep 17 00:00:00 2001 From: Ramon Roche Date: Wed, 18 Mar 2026 07:49:36 -0700 Subject: [PATCH] ci(ros): use matching branch for px4-ros2-interface-lib (#26781) * ci(ros): use matching branch for px4-ros2-interface-lib When running on release branches, the ROS integration tests now check if a matching branch exists in px4-ros2-interface-lib and clone it instead of always using main. This prevents build failures caused by uORB message divergence between main and release branches. Fixes https://github.com/Auterion/px4-ros2-interface-lib/issues/184 Signed-off-by: Ramon Roche * ci(ros): dispatch release branch creation to px4-ros2-interface-lib Add a standalone workflow triggered by the create event that fires a repository_dispatch to Auterion/px4-ros2-interface-lib when a release/X.Y branch is created. Also supports manual workflow_dispatch. Signed-off-by: Ramon Roche * ci(ros): add empty permissions block to dispatch workflow Fixes code scanning alert about missing GITHUB_TOKEN permissions. This workflow only uses a PAT secret, not GITHUB_TOKEN, so no permissions are needed. Signed-off-by: Ramon Roche --------- Signed-off-by: Ramon Roche --- .github/workflows/ros_integration_tests.yml | 10 ++++- .../sync_release_to_ros2_interface_lib.yml | 43 +++++++++++++++++++ 2 files changed, 52 insertions(+), 1 deletion(-) create mode 100644 .github/workflows/sync_release_to_ros2_interface_lib.yml diff --git a/.github/workflows/ros_integration_tests.yml b/.github/workflows/ros_integration_tests.yml index bbcce560d8..4549aa086f 100644 --- a/.github/workflows/ros_integration_tests.yml +++ b/.github/workflows/ros_integration_tests.yml @@ -89,7 +89,15 @@ 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 + BRANCH="${GITHUB_HEAD_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 # Ignore python packages due to compilation issue (can be enabled when updating ROS) touch px4-ros2-interface-lib/px4_ros2_py/COLCON_IGNORE || true touch px4-ros2-interface-lib/examples/python/COLCON_IGNORE || true diff --git a/.github/workflows/sync_release_to_ros2_interface_lib.yml b/.github/workflows/sync_release_to_ros2_interface_lib.yml new file mode 100644 index 0000000000..6ac613a017 --- /dev/null +++ b/.github/workflows/sync_release_to_ros2_interface_lib.yml @@ -0,0 +1,43 @@ +name: Sync release branch to px4-ros2-interface-lib + +on: + create: + workflow_dispatch: + inputs: + branch: + description: 'Release branch name (e.g. release/1.18)' + required: true + type: string + +permissions: {} + +jobs: + notify-interface-lib: + if: >- + github.repository == 'PX4/PX4-Autopilot' && + ( + (github.event_name == 'create' && github.ref_type == 'branch' && startsWith(github.ref_name, 'release/')) || + github.event_name == 'workflow_dispatch' + ) + runs-on: ubuntu-latest + steps: + - name: Determine branch name + id: params + run: | + if [ "${{ github.event_name }}" = "workflow_dispatch" ]; then + BRANCH="${{ inputs.branch }}" + else + BRANCH="${{ github.ref_name }}" + fi + echo "branch=$BRANCH" >> "$GITHUB_OUTPUT" + echo "Dispatching for branch: $BRANCH" + + - name: Dispatch release branch creation + run: | + BRANCH="${{ steps.params.outputs.branch }}" + curl -s -f -X POST \ + -H "Authorization: token ${{ secrets.PX4BUILTBOT_PERSONAL_ACCESS_TOKEN }}" \ + -H "Accept: application/vnd.github.v3+json" \ + https://api.github.com/repos/Auterion/px4-ros2-interface-lib/dispatches \ + -d "{\"event_type\":\"px4_release_branch\",\"client_payload\":{\"branch\":\"$BRANCH\"}}" + echo "Dispatched px4_release_branch event for $BRANCH"