diff --git a/CHANGELOG.md b/CHANGELOG.md index 44cf04f870..cc18170a4d 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -48,6 +48,7 @@ ## Unreleased — CI and contributor workflow - Set up Homebrew in the macOS integration and benchmark workflows with `scripts/setup-macos-homebrew.sh` instead of the `Homebrew/actions/setup-homebrew` action. The organization Actions policy does not allow that action, so both workflows stopped at startup. The script uses an installed `brew` or installs Homebrew from a pinned, checksum-verified installer. +- Fix the Homebrew setup script failing at exit after a successful install (`installer: unbound variable`), and test the install path through to script exit. - Run provider unit, SDK and prompt-parity checks on independent workers with compatible build caches, retaining MiMo fixture preparation and isolated native gates. - Separate prerequisite-dependent MiMo qualification from ordinary provider tests, retaining required prepared-fixture checks and explicit qualification gaps. Normalize the rollback test's filesystem identity and synchronize the zombie-stream timing test with the initial cancellation. - Pin the production prompt fixture's EOF format during regeneration; parity still compares the complete corpus bytes and unchanged token/contract expectations. diff --git a/docs/developer/test.md b/docs/developer/test.md index 6e560eceb3..419a4020ae 100644 --- a/docs/developer/test.md +++ b/docs/developer/test.md @@ -1,6 +1,6 @@ # Test -> Last updated: 2026-09-30 +> Last updated: 2026-10-01 The `d-inference` macOS CI lanes pin `blacksmith-12vcpu-macos-27` and select Xcode 27 / native SwiftPM before compilation. Unit, SDK, prompt-parity, @@ -1979,7 +1979,7 @@ make benchmark-wrapper-test # python3 -m unittest discover -s gemma_contb python3 scripts/test-provider-release-resolution.py # signed-validation and publication routing before credentials ./scripts/sync-install-embed.sh check # coordinator/api/install.sh byte-identical to scripts/install.sh ./scripts/test-prod-env-refresh.sh # deploy/gcp/prod/refresh-env.sh contract -./scripts/test-setup-macos-homebrew.sh # scripts/setup-macos-homebrew.sh with brew already installed +./scripts/test-setup-macos-homebrew.sh # scripts/setup-macos-homebrew.sh, brew present and brew installed ./scripts/test-publish-model.sh # scripts/publish-model.sh dry-run contract ``` @@ -2805,9 +2805,13 @@ before they install `postgresql@16` and get its binary path with checksum-verified installer. If Homebrew is still missing, the step fails before E2E tests run. See `.github/workflows/integration.yml` and `.github/workflows/benchmarks.yml`. -`./scripts/test-setup-macos-homebrew.sh` tests the path where `brew` is -already installed. It uses a fake `brew` in a temporary directory, makes no -download, and runs in the "Release Integrity" CI job. +`./scripts/test-setup-macos-homebrew.sh` tests two paths. In the first, `brew` +is already installed: the script uses a fake `brew` and downloads nothing. In +the second, `brew` is missing: the script runs a local fake installer through +to script exit, so the exit trap that deletes the installer also runs. A wrong +checksum must stop the installer. The test sets `SETUP_MACOS_HOMEBREW_TEST=1` +to point the script at the fake installer; CI workflows never set it. The test +runs in the "Release Integrity" CI job. ### Retained unsigned release recovery checks diff --git a/scripts/setup-macos-homebrew.sh b/scripts/setup-macos-homebrew.sh index 327ece7be5..e782252646 100755 --- a/scripts/setup-macos-homebrew.sh +++ b/scripts/setup-macos-homebrew.sh @@ -10,6 +10,16 @@ set -euo pipefail # Homebrew/install commit and the SHA-256 of its install.sh. Change both together. installer_commit=f6632bc2e9afc0ba20cdee1f2d28bcd7672b3245 installer_sha256=fa4ed743b4ca38316c8f32fd6623baa5bbb928fd4a47ad9f49c2be78ea833449 +installer_url="https://raw.githubusercontent.com/Homebrew/install/$installer_commit/install.sh" +brew_locations=(/opt/homebrew/bin/brew /usr/local/bin/brew) + +# Test-only overrides for scripts/test-setup-macos-homebrew.sh. CI never sets +# SETUP_MACOS_HOMEBREW_TEST, so the pinned values above always apply there. +if [ "${SETUP_MACOS_HOMEBREW_TEST:-}" = 1 ]; then + installer_url="${SETUP_MACOS_HOMEBREW_INSTALLER_URL:-$installer_url}" + installer_sha256="${SETUP_MACOS_HOMEBREW_INSTALLER_SHA256:-$installer_sha256}" + read -r -a brew_locations <<< "${SETUP_MACOS_HOMEBREW_LOCATIONS:-${brew_locations[*]}}" +fi find_brew() { local candidate @@ -17,7 +27,7 @@ find_brew() { printf '%s\n' "$candidate" return 0 fi - for candidate in /opt/homebrew/bin/brew /usr/local/bin/brew; do + for candidate in "${brew_locations[@]}"; do if [ -x "$candidate" ]; then printf '%s\n' "$candidate" return 0 @@ -32,11 +42,11 @@ install_brew() { exit 2 fi : "${RUNNER_TEMP:?RUNNER_TEMP is required}" - local installer + # Global, not local: the EXIT trap runs after this function returns. installer="$(mktemp "$RUNNER_TEMP/homebrew-install.XXXXXX")" trap 'rm -f "$installer"' EXIT curl --fail --silent --show-error --location --retry 3 --max-time 180 \ - "https://raw.githubusercontent.com/Homebrew/install/$installer_commit/install.sh" \ + "$installer_url" \ --output "$installer" # Verify before executing. printf '%s %s\n' "$installer_sha256" "$installer" | shasum -a 256 --check diff --git a/scripts/test-setup-macos-homebrew.sh b/scripts/test-setup-macos-homebrew.sh index 7db7deee2c..8aec0f52ae 100755 --- a/scripts/test-setup-macos-homebrew.sh +++ b/scripts/test-setup-macos-homebrew.sh @@ -1,6 +1,8 @@ #!/usr/bin/env bash -# Offline test: when brew is already on PATH, setup-macos-homebrew.sh exports -# its environment and downloads nothing. +# Offline tests for setup-macos-homebrew.sh: +# 1. brew is already on PATH: export its environment and download nothing. +# 2. brew is missing: run a local fake installer through to script exit, so the +# EXIT trap runs after install_brew has returned. set -euo pipefail ROOT=$(cd "$(dirname "$0")/.." && pwd) @@ -47,4 +49,54 @@ if env -u GITHUB_ENV PATH="$prefix/bin:$TEST_ROOT/tools:$PATH" GITHUB_PATH="$git exit 1 fi +# Install path. PATH holds only system tools and stubs, so no real brew is found. +install_prefix="$TEST_ROOT/installed" +runner_temp="$TEST_ROOT/runner-temp" +mkdir -p "$TEST_ROOT/stubs" "$runner_temp" +# The install path runs only on macOS; let it run on the Linux CI runner too. +printf '#!/bin/sh\necho Darwin\n' > "$TEST_ROOT/stubs/uname" +chmod +x "$TEST_ROOT/stubs/uname" + +fake_installer="$TEST_ROOT/install.sh" +cat > "$fake_installer" < "$TEST_ROOT/installer-ran" +mkdir -p "$install_prefix/bin" +sed "s|$prefix|$install_prefix|g" "$prefix/bin/brew" > "$install_prefix/bin/brew" +chmod +x "$install_prefix/bin/brew" +FAKE +fake_sha256=$(shasum -a 256 "$fake_installer" | cut -d' ' -f1) + +run_install() { + env PATH="$TEST_ROOT/stubs:/usr/bin:/bin" \ + GITHUB_PATH="$github_path" GITHUB_ENV="$github_env" RUNNER_TEMP="$runner_temp" \ + SETUP_MACOS_HOMEBREW_TEST=1 \ + SETUP_MACOS_HOMEBREW_INSTALLER_URL="file://$fake_installer" \ + SETUP_MACOS_HOMEBREW_INSTALLER_SHA256="$1" \ + SETUP_MACOS_HOMEBREW_LOCATIONS="$install_prefix/bin/brew" \ + "$ROOT/scripts/setup-macos-homebrew.sh" +} + +# A wrong checksum must stop the step before the installer runs. +if run_install "$(printf '%064d' 0)" >/dev/null 2>&1; then + echo 'setup accepted an installer with the wrong SHA-256' >&2 + exit 1 +fi +[ ! -e "$TEST_ROOT/installer-ran" ] +# The EXIT trap removed the downloaded installer on the failure path. +[ -z "$(ls -A "$runner_temp")" ] + +: > "$github_path" +: > "$github_env" +if ! install_out=$(run_install "$fake_sha256" 2>&1); then + printf 'install path failed:\n%s\n' "$install_out" >&2 + exit 1 +fi +grep -Fxq 'NONINTERACTIVE=1 HOMEBREW_NO_ANALYTICS=1' "$TEST_ROOT/installer-ran" +grep -Fxq "HOMEBREW_PREFIX=$install_prefix" "$github_env" +grep -Fxq "$install_prefix/bin" "$github_path" +# The EXIT trap removed the downloaded installer on the success path. +[ -z "$(ls -A "$runner_temp")" ] + echo 'setup-macos-homebrew: ok'