Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions .github/scripts/check_exported_deps.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/bin/bash
# Check that a package using cv_bridge finds it with only the dependencies that cv_bridge exports to it
# (build_export_depend, buildtool_export_depend and exec_depend, as the build farm installs for the packages
# depending on cv_bridge), and not the build only ones of cv_bridge.
# usage: check_exported_deps.sh <stage> where <stage> is
# build: build and install cv_bridge into /ws/install with all its dependencies
# use: install only its exported dependencies, and configure a package using cv_bridge
set -exo pipefail
STAGE=$1

export DEBIAN_FRONTEND=noninteractive
apt-get update -qq
apt-get install -y -qq --no-install-recommends curl ca-certificates gnupg lsb-release python3-pip > /dev/null
curl -sSL https://raw.githubusercontent.com/ros/rosdistro/master/ros.key -o /usr/share/keyrings/ros-archive-keyring.gpg
echo "deb [signed-by=/usr/share/keyrings/ros-archive-keyring.gpg] http://packages.ros.org/ros2-testing/ubuntu $(lsb_release -cs) main" \
> /etc/apt/sources.list.d/ros2.list
apt-get update -qq
apt-get install -y -qq --no-install-recommends python3-rosdep python3-colcon-common-extensions \
ros-${ROS_DISTRO}-ament-cmake build-essential cmake > /dev/null
rosdep init > /dev/null || true
rosdep update --rosdistro "${ROS_DISTRO}" > /dev/null

if [ "${STAGE}" = build ]; then
rosdep install -y -q --rosdistro "${ROS_DISTRO}" --from-paths /src/cv_bridge --ignore-src
. /opt/ros/${ROS_DISTRO}/setup.sh
cd /ws
colcon build --base-paths /src/cv_bridge --install-base /ws/install --cmake-args -DBUILD_TESTING=OFF
else
rosdep install -y -q --rosdistro "${ROS_DISTRO}" --from-paths /src/cv_bridge --ignore-src \
--dependency-types build_export --dependency-types buildtool_export --dependency-types exec
mkdir -p /tmp/user/build
cat > /tmp/user/CMakeLists.txt <<'EOS'
cmake_minimum_required(VERSION 3.20)
project(cv_bridge_user)
find_package(ament_cmake REQUIRED)
find_package(cv_bridge REQUIRED)
EOS
. /opt/ros/${ROS_DISTRO}/setup.sh
. /ws/install/setup.sh
cmake -S /tmp/user -B /tmp/user/build
fi
46 changes: 46 additions & 0 deletions .github/workflows/exported_deps.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
# A package using cv_bridge finds it with only the dependencies that cv_bridge exports (e.g. libopencv-dev for the
# OpenCV of its CMake config), as on the build farm, which installs only them for the packages depending on cv_bridge.
name: Exported dependencies

on:
pull_request:
paths:
- 'cv_bridge/package.xml'
- 'cv_bridge/CMakeLists.txt'
- 'cv_bridge/cmake/**'
- '.github/scripts/check_exported_deps.sh'
- '.github/workflows/exported_deps.yaml'
push:
branches: [rolling, lyrical, jazzy, humble]
workflow_dispatch:

concurrency:
group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.ref || github.run_id }}
cancel-in-progress: true

permissions:
contents: read

jobs:
cv_bridge:
runs-on: ubuntu-latest
env:
ROS_DISTRO: ${{ github.base_ref || github.ref_name }}
steps:
- uses: actions/checkout@v7
- name: Ubuntu of the distro
run: |
case "${ROS_DISTRO}" in
humble) echo "UBUNTU=jammy" >> "$GITHUB_ENV" ;;
jazzy) echo "UBUNTU=noble" >> "$GITHUB_ENV" ;;
*) echo "UBUNTU=resolute" >> "$GITHUB_ENV" ;;
esac
- name: Build cv_bridge with all its dependencies
run: |
mkdir -p ws
docker run --rm -e ROS_DISTRO -v "$PWD:/src:ro" -v "$PWD/ws:/ws" "ubuntu:${UBUNTU}" \
bash /src/.github/scripts/check_exported_deps.sh build
- name: Find cv_bridge with only its exported dependencies
run: |
docker run --rm -e ROS_DISTRO -v "$PWD:/src:ro" -v "$PWD/ws:/ws:ro" "ubuntu:${UBUNTU}" \
bash /src/.github/scripts/check_exported_deps.sh use
2 changes: 2 additions & 0 deletions cv_bridge/package.xml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@
<buildtool_export_depend>ament_cmake_ros_core</buildtool_export_depend>

<build_depend>libopencv-dev</build_depend>
<!-- the CMake config of cv_bridge finds OpenCV for the packages using it (ament_export_dependencies) -->
<build_export_depend>libopencv-dev</build_export_depend>
<build_depend>nanobind-dev</build_depend>

<depend>python3-numpy</depend>
Expand Down