Files
buzz/scripts/test-mobile-gateway-recipes.sh
Tom Brow d79446316b fix(mobile): support DeviceHub in mobile-dev (#8404)
`just mobile-dev` fails on Xcode 27 machines that have DeviceHub instead
of Simulator. Resolve the simulator frontend inside the selected Xcode
installation: DeviceHub for Xcode 27, or Simulator for Xcode 26. Launch
by full path so an older installed or running app cannot determine the
choice.

This extracts the still-needed DeviceHub portion of Wes's
[#8330](https://github.com/block/buzz/pull/8330). The CocoaPods
deployment-target work already landed in
[#8379](https://github.com/block/buzz/pull/8379); this PR does not
change Podfile or its lockfile.

CI and pre-push mobile selection include the shared Justfile and mobile
recipe regression script, so edits to either run the regression in the
mobile gate.

### Validation

- Nine production-recipe checks pass, covering side-by-side Xcode 26/27
selection with spaces in paths, missing apps, launch failure, and
gateway argument forwarding. Mutations reject unqualified Launch
Services lookup and removal of DeviceHub selection.
- All 39 tests of the pinned paths-filter action pass, including the
Justfile and recipe-test selection cases. Mobile formatting, analysis,
and the full mobile suite pass.
- Native macOS smoke checks exercised launch from the selected Xcode
installation and reached the Flutter boundary. Flutter and identity
setup were stubbed, so no app was built or installed.
- The initial full local CI gate stopped on an unchanged ACP
signal-cancellation test; that exact test passed in isolation. The
initial pre-push run also hit missing dependencies and two unchanged
desktop agent-discovery tests. Desktop lint and TypeScript checks passed
after installing pinned dependencies. Publishing used the authorized
local-hook exception.
- Current-head
[CI](https://github.com/block/buzz/actions/runs/38963831198) passed,
including all nine recipe cases and native Swift validation. Owner
approval and Codex code/security reviews are complete with no unresolved
findings.


buzz-review-completed

---------

Signed-off-by: Tom Brow <tomb@block.xyz>
2026-10-16 14:06:53 -07:00

104 lines
4.0 KiB
Bash

#!/bin/bash
# Exercise the production recipes with macOS's system Bash, not a rewritten copy.
set -euo pipefail
repo_root=$(cd "$(dirname "$0")/.." && pwd)
fixture=$(mktemp -d)
trap 'rm -rf "$fixture"' EXIT
mkdir -p "$fixture/bin" "$fixture/scripts" "$fixture/mobile/ios/Flutter"
for recipe in mobile-dev mobile-build-android; do
# Render with the real task runner before installing stubs: a Hermit just
# shim can otherwise prepend the real Flutter to PATH ahead of our stub.
just --justfile "$repo_root/Justfile" --dry-run "$recipe" > "$fixture/$recipe" 2>&1
done
cat > "$fixture/bin/flutter" <<'STUB'
#!/bin/bash
set -eu
printf '%s\n' "$@" > "$CALL_LOG"
STUB
cat > "$fixture/bin/xcode-select" <<'STUB'
#!/bin/bash
[[ "$*" == "-p" ]] || exit 1
printf '%s\n' "$SELECTED_DEVELOPER_DIR"
STUB
cat > "$fixture/bin/open" <<'STUB'
#!/bin/bash
printf '%s\n' "$@" >> "$OPEN_LOG"
[[ "$1" == -a && -d "$2" && "$OPEN_FAIL" == 0 ]]
STUB
cat > "$fixture/bin/sleep" <<'STUB'
#!/bin/bash
exit 0
STUB
cat > "$fixture/scripts/mobile-worktree-overrides.sh" <<'STUB'
#!/bin/bash
exit 0
STUB
chmod +x "$fixture/bin/flutter" "$fixture/bin/xcode-select" "$fixture/bin/open" "$fixture/bin/sleep" "$fixture/scripts/mobile-worktree-overrides.sh"
export PATH="$fixture/bin:$PATH"
export CALL_LOG="$fixture/arguments"
export OPEN_LOG="$fixture/open-calls"
# Spaces also exercise quoting of the selected Xcode path.
export SELECTED_DEVELOPER_DIR="$fixture/Xcode 27.app/Contents/Developer"
export OPEN_FAIL=0
mkdir -p "$SELECTED_DEVELOPER_DIR" "$SELECTED_DEVELOPER_DIR/../Applications/DeviceHub.app"
unset BUZZ_PUSH_GATEWAY_URL
for recipe in mobile-dev mobile-build-android; do
for mode in omitted supplied; do
unset BUZZ_PUSH_GATEWAY_URL
if [[ "$mode" == supplied ]]; then
# A space catches accidental splitting. The build gate validates URLs;
# this test checks exact argument forwarding.
export BUZZ_PUSH_GATEWAY_URL='https://push.example/value with space'
fi
(cd "$fixture" && /bin/bash "$fixture/$recipe")
if [[ "$recipe" == mobile-dev ]]; then
printf '%s\n' run > "$fixture/expected"
else
printf '%s\n' build apk --debug --no-pub > "$fixture/expected"
fi
if [[ "$mode" == supplied ]]; then
printf '%s\n' "--dart-define=BUZZ_PUSH_GATEWAY_URL=$BUZZ_PUSH_GATEWAY_URL" >> "$fixture/expected"
fi
diff -u "$fixture/expected" "$CALL_LOG"
printf 'PASS %s %s\n' "$recipe" "$mode"
done
done
unset BUZZ_PUSH_GATEWAY_URL
printf '%s\n' 'BUZZ_PUSH_GATEWAY_URL = https:/$()/push.example' > "$fixture/mobile/ios/Flutter/AppOverrides.xcconfig"
(cd "$fixture" && /bin/bash "$fixture/mobile-dev")
printf '%s\n' run '--dart-define=BUZZ_PUSH_GATEWAY_URL=https://push.example' > "$fixture/expected"
diff -u "$fixture/expected" "$CALL_LOG"
printf 'PASS mobile-dev Xcode override\n'
# Both installations exist: selection must not depend on Launch Services order.
xcode26="$fixture/Xcode 26.app/Contents/Developer"
xcode27="$SELECTED_DEVELOPER_DIR"
mkdir -p "$xcode26/Applications/Simulator.app"
for scenario in selected-xcode26 selected-xcode27 launch-failure missing-app; do
SELECTED_DEVELOPER_DIR="$xcode27"
OPEN_FAIL=0
case "$scenario" in
selected-xcode26) SELECTED_DEVELOPER_DIR="$xcode26" ;;
launch-failure) OPEN_FAIL=1 ;;
missing-app) SELECTED_DEVELOPER_DIR="$fixture/Missing Xcode.app/Contents/Developer" ;;
esac
expected_app="$SELECTED_DEVELOPER_DIR/../Applications/DeviceHub.app"
if [[ "$scenario" == selected-xcode26 || "$scenario" == missing-app ]]; then
expected_app="$SELECTED_DEVELOPER_DIR/Applications/Simulator.app"
fi
rm -f "$CALL_LOG"
: > "$OPEN_LOG"
printf '%s\n' -a "$expected_app" > "$fixture/expected-open"
if (cd "$fixture" && /bin/bash "$fixture/mobile-dev"); then
[[ "$scenario" != launch-failure && "$scenario" != missing-app ]]
diff -u "$fixture/expected" "$CALL_LOG"
else
[[ "$scenario" == launch-failure || "$scenario" == missing-app ]]
[[ ! -e "$CALL_LOG" ]]
fi
diff -u "$fixture/expected-open" "$OPEN_LOG"
printf 'PASS mobile-dev %s\n' "$scenario"
done