Skip to content

Fix package unlinking in ros2_mac_build.zsh #5

Fix package unlinking in ros2_mac_build.zsh

Fix package unlinking in ros2_mac_build.zsh #5

name: macOS ROS 2 jazzy CI (Apple Silicon)
on:
push:
branches: [jazzy]
pull_request:
workflow_dispatch:
jobs:
build:
runs-on: macos-15
env:
CI_BUILD: TRUE
timeout-minutes: 360
steps:
# --------------------------------------------------
# Checkout repository
# --------------------------------------------------
- name: Checkout repository
uses: actions/checkout@v4
with:
submodules: false
fetch-depth: 0
- name: Cache git submodules
uses: actions/cache@v4
with:
path: .git/modules
key: ${{ runner.os }}-git-submodules-${{ github.ref }}
restore-keys: |
${{ runner.os }}-git-submodules-
- name: Update submodules
run: |
git submodule sync --recursive
git submodule update --init --recursive --jobs 8
- name: Sync submodule branches
run: |
chmod +x scripts/sync-submodules-branches.sh
./scripts/sync-submodules-branches.sh
# --------------------------------------------------
# Homebrew cache
# --------------------------------------------------
- name: Cache Homebrew directories
uses: actions/cache@v4
id: cache-brew
with:
path: /opt/homebrew
key: ${{ runner.os }}-brew-v2-${{ hashFiles('brew-packages/install_brew_packages.sh') }}
restore-keys: |
${{ runner.os }}-brew-v2-
- name: Configure Homebrew parallelism
run: |
echo "HOMEBREW_MAKE_JOBS=$(sysctl -n hw.ncpu)" >> $GITHUB_ENV
echo "HOMEBREW_CMAKE_BUILD_PARALLEL_LEVEL=$(sysctl -n hw.ncpu)" >> $GITHUB_ENV
# --------------------------------------------------
# Homebrew install
# --------------------------------------------------
- name: Update Homebrew and install base packages
run: |
brew install \
graphviz \
eigen@3 \
eigen \
GeographicLib
# Symlink eigen3 for standard discovery
sudo ln -sfn /opt/homebrew/opt/eigen@3/include/eigen3 /opt/homebrew/include/eigen3
- name: Install Homebrew packages via script
run: |
chmod +x brew-packages/install_brew_packages.sh
./brew-packages/install_brew_packages.sh
# --------------------------------------------------
# Python 3.11
# --------------------------------------------------
- name: Python 3.11
run: |
export PATH="/Library/Frameworks/Python.framework/Versions/3.11/bin:$PATH"
which python3
python3 --version
echo "/Library/Frameworks/Python.framework/Versions/3.11/bin" >> $GITHUB_PATH
python3 -m pip install --upgrade pip --break-system-packages
python3 -m pip install -U \
--break-system-packages \
--config-settings="--global-option=build_ext" \
--config-settings="--global-option=-I$(brew --prefix graphviz)/include/" \
--config-settings="--global-option=-L$(brew --prefix graphviz)/lib/" \
argcomplete catkin_pkg colcon-common-extensions coverage \
cryptography empy==3.3.4 flake8 flake8-blind-except==0.1.1 flake8-builtins \
flake8-class-newline flake8-comprehensions flake8-deprecated \
flake8-docstrings flake8-import-order flake8-quotes \
importlib-metadata lark==1.1.1 lxml matplotlib mock mypy==0.931 netifaces \
nose pep8 psutil pydocstyle pydot pygraphviz pyparsing==2.4.7 \
pytest-mock rosdep rosdistro setuptools==59.6.0 vcstool typeguard jinja2
# --------------------------------------------------
# Environment
# --------------------------------------------------
- name: Setup build environment
run: |
echo "CMAKE_POLICY_VERSION_MINIMUM=3.5" >> $GITHUB_ENV
echo "OPENSSL_ROOT_DIR=$(brew --prefix openssl@3)" >> $GITHUB_ENV
echo "CMAKE_PREFIX_PATH=$(brew --prefix qt@5):$CMAKE_PREFIX_PATH" >> $GITHUB_ENV
echo "GZ_VERSION=ionic" >> $GITHUB_ENV
echo "GZ_SIM_SYSTEM_PLUGIN_PATH=${GITHUB_WORKSPACE}/install/gz_ros2_control/lib/" >> $GITHUB_ENV
# --------------------------------------------------
# Build External Gazebo Workspace
# --------------------------------------------------
- name: Build External Gazebo
shell: bash
run: |
# Create the specific directory structure you requested
mkdir -p gz-ionic/src
cd gz-ionic/src
git clone --recurse-submodules https://github.com/idesign0/gz-macOS.git -b ionic .
cd ..
brew unlink protobuf || true
colcon build \
--packages-select protobuf \
--executor parallel \
--parallel-workers $(sysctl -n hw.ncpu) \
--cmake-args -DBUILD_TESTING=OFF \
-DCMAKE_BUILD_TYPE=Release \
-DBOOST_ROOT=$(pwd)/src/dependencies/boost-1.89 \
--merge-install \
--continue-on-error
colcon build \
--packages-ignore protobuf \
--executor parallel \
--parallel-workers $(sysctl -n hw.ncpu) \
--cmake-args \
-DBUILD_TESTING=OFF \
-DCMAKE_BUILD_TYPE=Release \
-DBOOST_ROOT=$(pwd)/src/dependencies/boost-1.89 \
-DCMAKE_MACOSX_RPATH=FALSE \
-DCMAKE_INSTALL_NAME_DIR=$(pwd)/install/lib \
--merge-install \
--continue-on-error
# EXPORT TO GITHUB_ENV: This replaces "sourcing" for future steps
touch src/COLCON_IGNORE
echo "GZ_INSTALL_DIR=${{ github.workspace }}/gz-ionic/install" >> $GITHUB_ENV
echo "CMAKE_PREFIX_PATH=${{ github.workspace }}/gz-ionic/install:$CMAKE_PREFIX_PATH" >> $GITHUB_ENV
echo "DYLD_LIBRARY_PATH=${{ github.workspace }}/gz-ionic/install/lib:$DYLD_LIBRARY_PATH" >> $GITHUB_ENV
echo "PATH=${{ github.workspace }}/gz-ionic/install/bin:$PATH" >> $GITHUB_ENV
# --------------------------------------------------
# Homebrew: Unlink packages (ALWAYS run)
# --------------------------------------------------
- name: Unlink unwanted Homebrew packages
run: |
set +e
echo "Cleaning conflicting Homebrew packages..."
# Unlink (headers/libs stay but are not active)
brew unlink boost || true
brew unlink boost-python3 || true
brew unlink xtensor || true
brew unlink xdm || true
brew unlink xtl || true
brew unlink qt || true
brew unlink asio || true
brew unlink orocos-kdl || true
brew unlink protobuf || true
brew unlink ceres-solver || true
brew unlink osqp || true
echo "Homebrew clean-up completed."
# --------------------------------------------------
# Build full workspace
# --------------------------------------------------
- name: Build full workspace
shell: bash
continue-on-error: true
run: |
export CMAKE_PREFIX_PATH="${GZ_INSTALL_DIR}:${CMAKE_PREFIX_PATH}"
export CMAKE_TOOLCHAIN_FILE="${GITHUB_WORKSPACE}/cmake/toolchain.cmake"
colcon build \
--executor parallel \
--parallel-workers $(sysctl -n hw.ncpu) \
--cmake-clean-cache \
--continue-on-error \
--packages-ignore qt_gui_cpp rqt_gui_cpp pal_carbon_collector \
--cmake-args \
-DCMAKE_TOOLCHAIN_FILE="${CMAKE_TOOLCHAIN_FILE}" \
-DCI_BUILD=TRUE
# --------------------------------------------------
# Sanity check
# --------------------------------------------------
- name: Source workspace & sanity check
shell: bash
run: |
source install/setup.bash
ros2 --help
timeout 5s ros2 run demo_nodes_cpp talker || true