From 7a6239ac082adba6bc3f8464298c0390239a74ce Mon Sep 17 00:00:00 2001 From: David Tai Date: Wed, 30 Sep 2026 18:39:18 -0500 Subject: [PATCH] ci: set up Homebrew with a script instead of an action The organization Actions policy does not allow Homebrew/actions/setup-homebrew, so the integration and benchmark workflows stopped at startup. scripts/setup-macos-homebrew.sh uses an installed brew or installs Homebrew from a pinned, checksum-verified installer, then exports its shellenv to later steps. Co-Authored-By: Claude Opus 5.5 --- .github/workflows/benchmarks.yml | 4 +- .github/workflows/ci.yml | 1 + .github/workflows/integration.yml | 4 +- CHANGELOG.md | 1 + docs/developer/build.md | 15 ++++--- docs/developer/test.md | 14 +++++-- scripts/setup-macos-homebrew.sh | 62 ++++++++++++++++++++++++++++ scripts/test-setup-macos-homebrew.sh | 50 ++++++++++++++++++++++ 8 files changed, 136 insertions(+), 15 deletions(-) create mode 100755 scripts/setup-macos-homebrew.sh create mode 100755 scripts/test-setup-macos-homebrew.sh diff --git a/.github/workflows/benchmarks.yml b/.github/workflows/benchmarks.yml index a042bb404c..9d9297b858 100644 --- a/.github/workflows/benchmarks.yml +++ b/.github/workflows/benchmarks.yml @@ -62,9 +62,7 @@ jobs: go-version-file: go.mod - name: Set up Homebrew - uses: Homebrew/actions/setup-homebrew@e99025eb970cfa124b8284a35463d87426917478 - with: - stable: true + run: ./scripts/setup-macos-homebrew.sh - name: Install Postgres run: brew install postgresql@16 diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4887d46f45..81689149d9 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -29,6 +29,7 @@ jobs: python3 scripts/test-app-attest-entitlements.py ./scripts/sync-install-embed.sh check ./scripts/test-prod-env-refresh.sh + ./scripts/test-setup-macos-homebrew.sh - name: Test startup observer against local stubs run: python3 -m unittest discover -s scripts/startup_measurement -t scripts -p 'test_*.py' - name: Test advisory threat review with local HTTP fixtures diff --git a/.github/workflows/integration.yml b/.github/workflows/integration.yml index f05499228d..d9299448d4 100644 --- a/.github/workflows/integration.yml +++ b/.github/workflows/integration.yml @@ -46,9 +46,7 @@ jobs: go-version-file: go.mod - name: Set up Homebrew - uses: Homebrew/actions/setup-homebrew@e99025eb970cfa124b8284a35463d87426917478 - with: - stable: true + run: ./scripts/setup-macos-homebrew.sh - name: Install Postgres run: brew install postgresql@16 diff --git a/CHANGELOG.md b/CHANGELOG.md index 8a16174524..b3bdaaa401 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -40,6 +40,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. - 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/build.md b/docs/developer/build.md index 1d60b8fe7b..3b0e7abdac 100644 --- a/docs/developer/build.md +++ b/docs/developer/build.md @@ -12,11 +12,16 @@ test-only resource (`libs/mlx-swift-lm/Package.swift`). Those files are not provider product resources. Build SDK tests separately from provider tests when validating the media working-set change; see [test gates](test.md). -The macOS integration and benchmark workflows explicitly initialize Homebrew -with the pinned `Homebrew/actions/setup-homebrew` action before installing -`postgresql@16`. The action exposes an existing installation or installs -Homebrew when the runner image does not provide it; the job no longer depends -on GitHub-hosted image defaults. +The macOS integration and benchmark workflows run +`scripts/setup-macos-homebrew.sh` before they install `postgresql@16`. The +script uses `brew` if it is on `PATH`, at `/opt/homebrew/bin/brew` or at +`/usr/local/bin/brew`. If it finds no `brew`, it downloads the official +Homebrew installer from a pinned commit, checks its SHA-256, and runs it with +`NONINTERACTIVE=1`. In both cases it writes the `brew shellenv` values to +`$GITHUB_ENV` and `$GITHUB_PATH` for later steps. The workflows do not use the +`Homebrew/actions/setup-homebrew` action, because the organization Actions +policy does not allow it. To move the installer pin, change the commit and the +SHA-256 in the script together. macOS jobs that download artifacts, verify source signatures through the GitHub API, or post benchmark results run `scripts/install-macos-github-cli.sh` diff --git a/docs/developer/test.md b/docs/developer/test.md index 4aaff375ba..4cb50f7876 100644 --- a/docs/developer/test.md +++ b/docs/developer/test.md @@ -1970,6 +1970,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-publish-model.sh # scripts/publish-model.sh dry-run contract ``` @@ -2789,10 +2790,15 @@ Model findings and live API failures remain non-blocking in the separate ### macOS E2E Postgres setup -The integration and benchmark jobs initialize Homebrew before installing -`postgresql@16` and deriving its binary path with `brew --prefix`. A missing -Homebrew executable is a runner-setup failure before E2E tests execute. See -`.github/workflows/integration.yml` and `.github/workflows/benchmarks.yml`. +The integration and benchmark jobs run `scripts/setup-macos-homebrew.sh` +before they install `postgresql@16` and get its binary path with +`brew --prefix`. The script finds Homebrew or installs it from a pinned, +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. ### Retained unsigned release recovery checks diff --git a/scripts/setup-macos-homebrew.sh b/scripts/setup-macos-homebrew.sh new file mode 100755 index 0000000000..327ece7be5 --- /dev/null +++ b/scripts/setup-macos-homebrew.sh @@ -0,0 +1,62 @@ +#!/usr/bin/env bash +# Find Homebrew on a macOS CI runner, or install it from a pinned installer, +# and export its environment to later steps. Replaces the setup-homebrew +# action, which the organization Actions policy does not allow. +set -euo pipefail + +: "${GITHUB_PATH:?GITHUB_PATH is required}" +: "${GITHUB_ENV:?GITHUB_ENV is required}" + +# Homebrew/install commit and the SHA-256 of its install.sh. Change both together. +installer_commit=f6632bc2e9afc0ba20cdee1f2d28bcd7672b3245 +installer_sha256=fa4ed743b4ca38316c8f32fd6623baa5bbb928fd4a47ad9f49c2be78ea833449 + +find_brew() { + local candidate + if candidate="$(command -v brew)"; then + printf '%s\n' "$candidate" + return 0 + fi + for candidate in /opt/homebrew/bin/brew /usr/local/bin/brew; do + if [ -x "$candidate" ]; then + printf '%s\n' "$candidate" + return 0 + fi + done + return 1 +} + +install_brew() { + if [ "$(uname -s)" != Darwin ]; then + echo 'Homebrew bootstrap requires macOS' >&2 + exit 2 + fi + : "${RUNNER_TEMP:?RUNNER_TEMP is required}" + local installer + 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" \ + --output "$installer" + # Verify before executing. + printf '%s %s\n' "$installer_sha256" "$installer" | shasum -a 256 --check + NONINTERACTIVE=1 HOMEBREW_NO_ANALYTICS=1 /bin/bash "$installer" +} + +if ! brew_bin="$(find_brew)"; then + install_brew + if ! brew_bin="$(find_brew)"; then + echo 'Homebrew installer finished but brew was not found' >&2 + exit 1 + fi +fi + +eval "$("$brew_bin" shellenv bash)" +: "${HOMEBREW_PREFIX:?brew shellenv did not set HOMEBREW_PREFIX}" +"$brew_bin" --version +{ + printf 'HOMEBREW_PREFIX=%s\n' "$HOMEBREW_PREFIX" + printf 'HOMEBREW_CELLAR=%s\n' "${HOMEBREW_CELLAR:-$HOMEBREW_PREFIX/Cellar}" + printf 'HOMEBREW_REPOSITORY=%s\n' "${HOMEBREW_REPOSITORY:-$HOMEBREW_PREFIX}" +} >> "$GITHUB_ENV" +printf '%s\n' "$HOMEBREW_PREFIX/sbin" "$HOMEBREW_PREFIX/bin" >> "$GITHUB_PATH" diff --git a/scripts/test-setup-macos-homebrew.sh b/scripts/test-setup-macos-homebrew.sh new file mode 100755 index 0000000000..7db7deee2c --- /dev/null +++ b/scripts/test-setup-macos-homebrew.sh @@ -0,0 +1,50 @@ +#!/usr/bin/env bash +# Offline test: when brew is already on PATH, setup-macos-homebrew.sh exports +# its environment and downloads nothing. +set -euo pipefail + +ROOT=$(cd "$(dirname "$0")/.." && pwd) +TEST_ROOT=$(mktemp -d "${TMPDIR:-/tmp}/darkbloom-homebrew.XXXXXX") +trap 'rm -rf "$TEST_ROOT"' EXIT + +prefix="$TEST_ROOT/homebrew" +mkdir -p "$prefix/bin" "$TEST_ROOT/tools" +cat > "$prefix/bin/brew" <&2; exit 1 ;; +esac +FAKE +# Any download means the script took the install path. +printf '#!/usr/bin/env bash\necho "curl must not run" >&2\nexit 1\n' > "$TEST_ROOT/tools/curl" +chmod +x "$prefix/bin/brew" "$TEST_ROOT/tools/curl" + +github_path="$TEST_ROOT/github_path" +github_env="$TEST_ROOT/github_env" +: > "$github_path" +: > "$github_env" + +env -u RUNNER_TEMP PATH="$prefix/bin:$TEST_ROOT/tools:$PATH" \ + GITHUB_PATH="$github_path" GITHUB_ENV="$github_env" \ + "$ROOT/scripts/setup-macos-homebrew.sh" >/dev/null + +grep -Fxq "HOMEBREW_PREFIX=$prefix" "$github_env" +grep -Fxq "HOMEBREW_CELLAR=$prefix/Cellar" "$github_env" +grep -Fxq "HOMEBREW_REPOSITORY=$prefix" "$github_env" +grep -Fxq "$prefix/bin" "$github_path" +grep -Fxq "$prefix/sbin" "$github_path" + +# Missing GitHub output files must fail before any other work. +if env -u GITHUB_ENV PATH="$prefix/bin:$TEST_ROOT/tools:$PATH" GITHUB_PATH="$github_path" \ + "$ROOT/scripts/setup-macos-homebrew.sh" >/dev/null 2>&1; then + echo 'setup accepted a missing GITHUB_ENV' >&2 + exit 1 +fi + +echo 'setup-macos-homebrew: ok'