From d840da70b62847cd862a9185e978155cd628ec32 Mon Sep 17 00:00:00 2001 From: FARHANG Date: Wed, 2 Sep 2026 12:42:02 -0400 Subject: [PATCH] build(macos): pin gz tap unconditionally, add weekly refresh macos.sh only pinned osrf/simulation when --ci was passed, so dev machines still hit OSRF's bottle-gap window and built Gazebo from source. Apply it whenever --sim-tools runs. The pin is a point-in-time SHA with nothing to advance it, so add a weekly workflow that checks whether osrf/simulation HEAD is fully bottled and opens a PR bumping gz-tap-pin.txt when it is. Assisted-by: Claude:claude-sonnet-5 Signed-off-by: FARHANG --- .github/workflows/compile_macos.yml | 2 +- .../workflows/macos_gz_tap_pin_refresh.yml | 104 ++++++++++++++++++ Tools/setup/macos.sh | 25 ++--- 3 files changed, 113 insertions(+), 18 deletions(-) create mode 100644 .github/workflows/macos_gz_tap_pin_refresh.yml diff --git a/.github/workflows/compile_macos.yml b/.github/workflows/compile_macos.yml index 3595d3ef948..87180924d42 100644 --- a/.github/workflows/compile_macos.yml +++ b/.github/workflows/compile_macos.yml @@ -49,7 +49,7 @@ jobs: - name: setup run: | - ./Tools/setup/macos.sh --sim-tools --ci + ./Tools/setup/macos.sh --sim-tools echo "${{ github.workspace }}/.venv/bin" >> $GITHUB_PATH - uses: ./.github/actions/setup-ccache diff --git a/.github/workflows/macos_gz_tap_pin_refresh.yml b/.github/workflows/macos_gz_tap_pin_refresh.yml new file mode 100644 index 00000000000..efc4d44a8e8 --- /dev/null +++ b/.github/workflows/macos_gz_tap_pin_refresh.yml @@ -0,0 +1,104 @@ +name: macOS - Refresh gz tap pin + +# Tools/setup/macos.sh pins osrf/simulation to a known-bottled commit so +# --sim-tools installs Gazebo from a binary instead of compiling it (see +# Tools/setup/gz-tap-pin.txt for why). That pin goes stale as OSRF's bot +# rebuilds bottles for newer commits. This checks weekly whether the tap's +# current HEAD is fully bottled and, if so, opens a PR bumping the pin. + +on: + schedule: + - cron: '0 9 * * 1' # Mondays at 09:00 UTC + workflow_dispatch: + +permissions: + contents: write + pull-requests: write + +jobs: + check-pin: + runs-on: macos-latest + steps: + - uses: actions/checkout@v6 + + - name: Tap osrf/simulation + id: tap + run: | + brew tap osrf/simulation + if brew trust --help &> /dev/null; then + brew trust osrf/simulation + fi + GZ_TAP_DIR=$(brew --repo osrf/simulation) + echo "dir=${GZ_TAP_DIR}" >> "$GITHUB_OUTPUT" + echo "head=$(git -C "${GZ_TAP_DIR}" rev-parse HEAD)" >> "$GITHUB_OUTPUT" + + - name: Check whether tap HEAD is fully bottled + id: bottled + run: | + # Same package list as the --sim-tools block in macos.sh. Kept in + # sync manually since the formula names aren't easy to extract + # from the script without duplicating its parsing. + PACKAGES=( + exiftool + glog + graphviz + gstreamer + opencv@4 + osrf/simulation/gz-harmonic + protobuf + ) + + if brew install --dry-run --formula "${PACKAGES[@]}" 2>&1 | tee /tmp/dry-run.txt | grep -q "from source"; then + echo "[refresh] tap HEAD (${{ steps.tap.outputs.head }}) would build at least one formula from source, skipping" + echo "fully_bottled=false" >> "$GITHUB_OUTPUT" + else + echo "[refresh] tap HEAD (${{ steps.tap.outputs.head }}) is fully bottled" + echo "fully_bottled=true" >> "$GITHUB_OUTPUT" + fi + + - name: Compare against current pin + if: steps.bottled.outputs.fully_bottled == 'true' + id: compare + run: | + CURRENT_PIN=$(grep -v '^#' Tools/setup/gz-tap-pin.txt | tr -d '[:space:]') + NEW_PIN="${{ steps.tap.outputs.head }}" + if [[ "$CURRENT_PIN" == "$NEW_PIN" ]]; then + echo "[refresh] pin is already current (${CURRENT_PIN})" + echo "needs_bump=false" >> "$GITHUB_OUTPUT" + else + echo "[refresh] bumping pin ${CURRENT_PIN} -> ${NEW_PIN}" + echo "needs_bump=true" >> "$GITHUB_OUTPUT" + echo "new_pin=${NEW_PIN}" >> "$GITHUB_OUTPUT" + fi + + - name: Open PR with the new pin + if: steps.compare.outputs.needs_bump == 'true' + env: + GH_TOKEN: ${{ secrets.PX4BUILTBOT_PERSONAL_ACCESS_TOKEN }} + NEW_PIN: ${{ steps.compare.outputs.new_pin }} + run: | + git config user.name "px4buildbot" + git config user.email "buildbot@px4.io" + + BRANCH="chore/gz-tap-pin-${NEW_PIN:0:12}" + git checkout -b "$BRANCH" + + sed -i '' "s/^[0-9a-f]\{40\}$/${NEW_PIN}/" Tools/setup/gz-tap-pin.txt + git add Tools/setup/gz-tap-pin.txt + git commit -m "chore(macos): bump gz tap pin to ${NEW_PIN:0:12}" + git push origin "$BRANCH" + + PR_BODY_FILE=$(mktemp) + { + echo "Weekly check found that osrf/simulation HEAD (\`${NEW_PIN}\`) has bottles" + echo "for every formula \`macos.sh --sim-tools\` installs. Bumping" + echo "\`Tools/setup/gz-tap-pin.txt\` to this commit." + echo "" + echo "Verify the compile_macos.yml legs pass before merging." + } > "$PR_BODY_FILE" + + gh pr create \ + --base main \ + --head "$BRANCH" \ + --title "chore(macos): bump gz tap pin to ${NEW_PIN:0:12}" \ + --body-file "$PR_BODY_FILE" diff --git a/Tools/setup/macos.sh b/Tools/setup/macos.sh index 98beea377b3..181c644d9e7 100755 --- a/Tools/setup/macos.sh +++ b/Tools/setup/macos.sh @@ -8,10 +8,8 @@ ## - Cross compilers for building hardware targets using NuttX ## - With --sim-tools: Gazebo Harmonic and jMAVSim simulation stack ## -## --ci trades freshness for reproducibility and is meant for automation, -## not development machines. Today it pins the osrf/simulation tap to -## gz-tap-pin.txt so Gazebo installs from bottles even while OSRF has -## them pulled. +## --sim-tools pins the osrf/simulation tap to gz-tap-pin.txt so Gazebo +## installs from bottles even while OSRF has them pulled. ## ## Homebrew 4.5+ no longer auto-resolves cross-tap dependencies, so ## every tap and package is listed explicitly here rather than hidden @@ -25,8 +23,6 @@ DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd ) REINSTALL_FORMULAS="" # Install simulation tools? INSTALL_SIM="" -# Favour reproducibility over freshness (automation, not dev machines)? -CI_MODE="" # Parse arguments for arg in "$@" @@ -35,8 +31,6 @@ do REINSTALL_FORMULAS=$arg elif [[ $arg == "--sim-tools" ]]; then INSTALL_SIM=$arg - elif [[ $arg == "--ci" ]]; then - CI_MODE=$arg fi done @@ -138,15 +132,12 @@ if [[ $INSTALL_SIM == "--sim-tools" ]]; then # osrf/simulation: gz-harmonic (Gazebo Harmonic meta-formula) brew tap osrf/simulation - # Under --ci only: OSRF drops the gz bottle blocks within minutes of a - # breaking homebrew-core dependency bump and rebuilds them days later, - # so an unpinned tap compiles Gazebo from source for a large part of - # the year. Development machines keep tracking the tap normally, and - # get the newer formulae at the cost of that build. See gz-tap-pin.txt. - GZ_TAP_PIN="" - if [[ -n $CI_MODE ]]; then - GZ_TAP_PIN=$(grep -v '^#' "${DIR}/gz-tap-pin.txt" | tr -d '[:space:]') - fi + # OSRF drops the gz bottle blocks within minutes of a breaking + # homebrew-core dependency bump and rebuilds them days later, so an + # unpinned tap compiles Gazebo from source for a large part of the + # year. Pin unconditionally so dev machines get the same fast, binary + # install as CI. See gz-tap-pin.txt. + GZ_TAP_PIN=$(grep -v '^#' "${DIR}/gz-tap-pin.txt" | tr -d '[:space:]') if [[ -n $GZ_TAP_PIN ]]; then GZ_TAP_DIR=$(brew --repo osrf/simulation) echo "[macos.sh] Pinning osrf/simulation to ${GZ_TAP_PIN}"