chore(build): enforce Xcode 27.0 for Apple builds

Signed-off-by: Tom Brow <tomb@block.xyz>
This commit is contained in:
Tom Brow
2026-10-12 11:30:39 -07:00
parent c09730e874
commit d0a1d61533
14 changed files with 157 additions and 14 deletions

23
scripts/check-xcode.sh Executable file
View File

@@ -0,0 +1,23 @@
#!/usr/bin/env bash
# Validate the active Apple toolchain without changing xcode-select globally.
set -euo pipefail
[[ "$(uname -s)" == Darwin ]] || exit 0
root="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)"
expected="$(cat "$root/.xcode-version")"
[[ "$expected" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]] || {
echo "Invalid .xcode-version: expected a major.minor.patch version" >&2
exit 1
}
if ! version="$(xcodebuild -version)"; then
echo "Buzz requires Xcode $expected. Set DEVELOPER_DIR to its Xcode.app/Contents/Developer." >&2
exit 1
fi
actual="$(printf '%s\n' "$version" | sed -n 's/^Xcode //p')"
[[ "$actual" == *.* ]] || actual="$actual.0"
[[ "$actual" == *.*.* ]] || actual="$actual.0"
if [[ "$actual" != "$expected" ]]; then
echo "Buzz requires Xcode $expected (.xcode-version); active toolchain reports: $version" >&2
echo "Set DEVELOPER_DIR to the matching Xcode.app/Contents/Developer and retry." >&2
exit 1
fi
printf '%s\n' "$version"

View File

@@ -24,6 +24,7 @@ cat > "$fixture/scripts/mobile-worktree-overrides.sh" <<'STUB'
exit 0
STUB
chmod +x "$fixture/bin/flutter" "$fixture/bin/pgrep" "$fixture/scripts/mobile-worktree-overrides.sh"
cp "$fixture/scripts/mobile-worktree-overrides.sh" "$fixture/scripts/check-xcode.sh"
export PATH="$fixture/bin:$PATH"
export CALL_LOG="$fixture/arguments"
unset BUZZ_PUSH_GATEWAY_URL

33
scripts/test-xcode-version.sh Executable file
View File

@@ -0,0 +1,33 @@
#!/usr/bin/env bash
# Exercise version enforcement without installing or switching a real Xcode.
set -euo pipefail
root="$(cd "$(dirname "$0")/.." && pwd)"
fixture="$(mktemp -d)"
trap 'rm -rf "$fixture"' EXIT
mkdir -p "$fixture/scripts" "$fixture/bin"
cp "$root/scripts/check-xcode.sh" "$fixture/scripts/"
cp "$root/.xcode-version" "$fixture/"
cat > "$fixture/bin/uname" <<'STUB'
#!/usr/bin/env bash
printf '%s\n' "${TEST_OS:-Darwin}"
STUB
cat > "$fixture/bin/xcodebuild" <<'STUB'
#!/usr/bin/env bash
[[ "${TEST_XCODE:-}" != broken ]] || exit 1
printf 'Xcode %s\nBuild version fixture\n' "$TEST_XCODE"
STUB
chmod +x "$fixture/bin/"*
export PATH="$fixture/bin:$PATH"
check() { "$fixture/scripts/check-xcode.sh" >/dev/null 2>&1; }
export TEST_XCODE=27.0
check
export TEST_XCODE=27
check
for TEST_XCODE in 26.6 27.1 '27.0 beta' broken ''; do
export TEST_XCODE
if check; then echo "Accepted wrong Xcode: $TEST_XCODE" >&2; exit 1; fi
done
printf 'latest\n' > "$fixture/.xcode-version"
if check; then echo 'Accepted invalid pin' >&2; exit 1; fi
TEST_OS=Linux check
printf 'Xcode version enforcement passed\n'