Skip to content

The ultimate harness for coding agents and beyond. All your agents. All your machines. One command center. Start with code, then follow your curiosity and build across disciplines: CAD, circuits, robots, games and music.

Compile macOS once and publish both renderer variants in parallel (#626)

Deea94c7aa839eb
diff --git a/.github/workflows/desktop-internal-build.yml b/.github/workflows/desktop-internal-build.yml
index 30fb02fc4..ccf278aed 100644
--- a/.github/workflows/desktop-internal-build.yml
+++ b/.github/workflows/desktop-internal-build.yml
@@ -16,11 +16,10 @@ name: Desktop internal build
# summary says how); the upload step drops the release's year-long cache headers so a deletion sticks.
#
# Built by the release's own code, so it IS what a release would ship, flags aside:
-# scripts/publish-macos-variant.sh --build-only builds and pins each renderer (Intel on Skia, Apple
-# Silicon on Impeller — RELEASE.md, "Two macOS builds"), then scripts/upload-desktop.sh --no-build
-# signs, notarizes, staples, runs Gatekeeper's check and uploads, moved onto the internal path by the
-# env overrides it already has. A build made by hand, Info.plist edited and re-signed by hand, is how
-# a tester got "The application "Harness" can't be opened"; this replaces that rather than copying it.
+# scripts/build-macos-variants.py compiles once and pins each renderer (Intel on Skia, Apple Silicon
+# on Impeller). The same release uploader signs, notarizes, staples, checks Gatekeeper and uploads
+# to separate internal paths. Both variants' downloads are verified before links are handed out.
+# test_build=true exercises this complete path, then deletes only the run's disposable objects.
#
# Self-update is pinned OFF: DESKTOP_UPDATE_METADATA_URL names a manifest nothing ever writes, so the
# updater finds nothing, forever. A tester stays on the build they were asked to test instead of being
@@ -39,6 +38,10 @@ on:
description: 'Show Settings > Debug and Tracking (HARNESS_DEBUG_SURFACE)'
type: boolean
default: false
+ test_build:
+ description: 'Verify the complete internal build, then delete only this run’s disposable artifacts'
+ type: boolean
+ default: false
permissions:
contents: read
@@ -112,36 +115,20 @@ jobs:
needs: prepare
runs-on: macos-15
timeout-minutes: 60 # two notarization submissions per build (zip, then dmg)
- strategy:
- fail-fast: false
- matrix:
- include:
- - { variant: intel, artifact: Harness-macos, ota_key: desktop-macos, label: 'Intel, on Skia (runs on any Mac)' }
- - { variant: apple-silicon, artifact: Harness-macos-arm64, ota_key: desktop-macos-arm64, label: 'Apple Silicon, on Impeller' }
env:
VERSION: ${{ needs.prepare.outputs.version }}
PREFIX: ${{ needs.prepare.outputs.prefix }}
- VARIANT: ${{ matrix.variant }}
DEBUG_SURFACE: ${{ needs.prepare.outputs.debug_surface }}
- # The file a tester downloads names the build it is: version AND commit.
- ARTIFACT: ${{ matrix.artifact }}-${{ needs.prepare.outputs.version }}-${{ needs.prepare.outputs.short_sha }}
+ SHORT_SHA: ${{ needs.prepare.outputs.short_sha }}
defaults:
run:
working-directory: desktop
steps:
- uses: actions/checkout@v7
- - uses: subosito/flutter-action@v2
+ - uses: ./.github/actions/desktop-flutter
with:
- flutter-version: ${{ needs.prepare.outputs.flutter_version }}
- channel: stable
- cache: true
-
- # SPM must be on BEFORE pub get — see release-desktop.yml and desktop/CLAUDE.md.
- - name: Enable Swift Package Manager
- run: flutter config --enable-swift-package-manager
-
- - run: flutter pub get
+ version: ${{ needs.prepare.outputs.flutter_version }}
- uses: ./.github/actions/macos-signing
with:
@@ -167,62 +154,73 @@ jobs:
service_account: ${{ secrets.GCP_SERVICE_ACCOUNT }}
- uses: google-github-actions/setup-gcloud@e427ad8a34f8676edf47cf7d7925499adf3eb74f # v2
- - name: Build ${{ matrix.variant }} and pin its renderer
+ - name: Build once, publish both renderers and verify all four downloads
+ id: build
env:
KEYCHAIN_PASSWORD: ${{ secrets.KEYCHAIN_PASSWORD }}
SIGN_IDENTITY: ${{ secrets.APPLE_SIGNING_IDENTITY }}
run: |
set -euo pipefail
security unlock-keychain -p "$KEYCHAIN_PASSWORD" "$KEYCHAIN_PATH"
- bash scripts/publish-macos-variant.sh "$VARIANT" "$VERSION" --build-only \
+ export CDN_ASSET_BASE_URL="https://storage.googleapis.com/${GCS_BUCKET}"
+ python3 scripts/build-macos-variants.py "$VERSION" \
+ --metadata-prefix "$PREFIX" --artifact-prefix "$PREFIX" \
+ --artifact-suffix="-$VERSION-$SHORT_SHA" --verify-downloads \
--dart-define=HARNESS_DEBUG_SURFACE="$DEBUG_SURFACE" \
--dart-define=DESKTOP_UPDATE_METADATA_URL="https://storage.googleapis.com/${GCS_BUCKET}/harness/desktop-internal/no-updates.json"
- - name: Sign, notarize and upload ${{ matrix.variant }} to its unlisted path
- env:
- KEYCHAIN_PASSWORD: ${{ secrets.KEYCHAIN_PASSWORD }}
- SIGN_IDENTITY: ${{ secrets.APPLE_SIGNING_IDENTITY }}
- OTA_KEY: ${{ matrix.ota_key }}
- DMG_KEY: ${{ matrix.ota_key }}-dmg
+ - name: Make the internal artifacts removable
run: |
set -euo pipefail
- security unlock-keychain -p "$KEYCHAIN_PASSWORD" "$KEYCHAIN_PATH"
- # upload-desktop.sh's own overrides, every path moved off the release's. The manifest it
- # always writes lands under the prefix too: read by nothing, it records what was published.
- export GCS_PATH="$PREFIX/$ARTIFACT.zip"
- export DMG_GCS_PATH="$PREFIX/$ARTIFACT.dmg"
- export METADATA_PATH="$PREFIX/manifest-$VARIANT.json"
- bash scripts/upload-desktop.sh --no-build "$VERSION"
# upload-desktop.sh uploads with a year-long immutable cache: right for a release path
# nobody ever changes, wrong for a build that may have to be taken back.
# `gcloud storage`, not gsutil: gsutil cannot use the external-account credential
# federation issues, and parallelises by default so `-m` has no equivalent.
gcloud storage objects update \
- "gs://${GCS_BUCKET}/${GCS_PATH}" "gs://${GCS_BUCKET}/${DMG_GCS_PATH}" \
+ "gs://${GCS_BUCKET}/${PREFIX}/*.zip" "gs://${GCS_BUCKET}/${PREFIX}/*.dmg" \
--cache-control="private, max-age=0, no-store"
- - name: Hand out the link
+ - name: Hand out the links
+ if: ${{ !inputs.test_build }}
+ run: |
+ set -euo pipefail
+ for variant in intel apple-silicon; do
+ artifact=Harness-macos
+ [[ "$variant" != apple-silicon ]] || artifact=Harness-macos-arm64
+ artifact="$artifact-$VERSION-$SHORT_SHA"
+ url="https://storage.googleapis.com/${GCS_BUCKET}/${PREFIX}/${artifact}.dmg"
+ sha="$(shasum -a 256 "build/macos-variants/$variant/Harness-macos-${VERSION}.dmg" | awk '{print $1}')"
+ echo "::notice title=macOS ${variant}::${url}"
+ {
+ echo "### macOS — ${variant} (universal)"
+ echo "**[${artifact}.dmg](${url})**"
+ echo "${VERSION} · \`${SHORT_SHA}\` on \`${GITHUB_REF_NAME}\` · Debug ${DEBUG_SURFACE} · self-update off"
+ echo "dmg sha256 \`${sha}\`"
+ echo "Unlisted, not private. Remove both builds with \`gcloud storage rm -r gs://${GCS_BUCKET}/${PREFIX}\`."
+ } >> "$GITHUB_STEP_SUMMARY"
+ done
+
+ - uses: actions/upload-artifact@v4
+ if: always()
+ with:
+ name: macos-build-timings
+ path: desktop/build/macos-variants/timing.json
+ if-no-files-found: ignore
+
+ - name: Remove this test build's disposable objects
+ if: ${{ always() && inputs.test_build }}
env:
- LABEL: ${{ matrix.label }}
+ BUILD_OUTCOME: ${{ steps.build.outcome }}
run: |
set -euo pipefail
- url="https://storage.googleapis.com/${GCS_BUCKET}/${PREFIX}/${ARTIFACT}.dmg"
- sha="$(shasum -a 256 "build/Harness-macos-${VERSION}.dmg" | awk '{print $1}')"
- # A notice as well as the summary: it sits at the top of the run page, where it is found.
- echo "::notice title=macOS ${VARIANT}::${url}"
- {
- echo "### macOS — ${LABEL}"
- echo
- echo "**[${ARTIFACT}.dmg](${url})**"
- echo
- echo "${VERSION} · \`${GITHUB_SHA::7}\` on \`${GITHUB_REF_NAME}\` · Debug ${DEBUG_SURFACE} · self-update off"
- echo
- echo "dmg sha256 \`${sha}\`"
- echo
- echo "Unlisted, not private: this repository is public, so anyone who opens this page can"
- echo "download the build. Take it back with \`gcloud storage rm -r gs://${GCS_BUCKET}/${PREFIX}\`"
- echo "(both builds of this run)."
- } >> "$GITHUB_STEP_SUMMARY"
+ [[ "$PREFIX" =~ ^harness/desktop-internal/[0-9a-f]{32}$ ]]
+ if [[ "$BUILD_OUTCOME" = success ]]; then
+ gcloud storage rm --recursive "gs://${GCS_BUCKET}/${PREFIX}/"
+ else
+ # An earlier failure may have produced no objects; this is still
+ # restricted to the new random prefix owned by this run.
+ gcloud storage rm --recursive "gs://${GCS_BUCKET}/${PREFIX}/" || true
+ fi
- name: Remove the signing keychain
if: always()
diff --git a/.github/workflows/release-desktop.yml b/.github/workflows/release-desktop.yml
index 069f231bc..5d4cb4a2a 100644
--- a/.github/workflows/release-desktop.yml
+++ b/.github/workflows/release-desktop.yml
@@ -11,22 +11,11 @@ name: Release desktop
# The Flutter project lives under desktop/: the jobs that touch the tree run with
# working-directory: desktop, and `desktop/scripts/...` below is what `scripts/...` used to mean.
#
-# Shape (the one autonomous-grid's release.yml uses): every platform builds IN PARALLEL, and the
-# real manifest is written exactly once at the end.
-#
-# metadata.json is a download-modify-reupload, so four jobs each merging their own key would drop
-# each other's. Rather than schedule around that — the first version of this file ran macOS and the
-# two Linux architectures one after another, ~70 minutes of wall clock — each build job is pointed
-# at its OWN scratch manifest under harness/desktop/.ci/<run id>/. Nothing collides because nothing
-# shares a file, the artifacts still go straight to their real paths, and the `publish` job merges
-# those scratch files into the real manifest in a single read-modify-write. ~25 minutes, and the
-# race cannot happen rather than being avoided.
-#
-# desktop/scripts/upload-desktop.sh and desktop/scripts/upload-desktop-linux.sh are used EXACTLY as
-# they are, with no flags this file invented: METADATA_PATH is an env override they already support.
-# macOS reaches upload-desktop.sh through desktop/scripts/publish-macos-variant.sh, which builds, pins
-# the renderer, then calls it with --no-build and that build's keys — a flag and env overrides it
-# already takes.
+# macOS and both Linux architectures build in parallel. The macOS coordinator compiles one
+# universal app, derives both renderer bundles, and packages/notarizes/uploads them in parallel.
+# Each variant writes its own scratch manifest under harness/desktop/.ci/<run id>/.
+# The publish job combines all four parts with a generation-conditional write and verifies every
+# public download while holding the publication lock. Different releases may build concurrently.
#
# The tag IS the version — CI never auto-bumps. The scripts bump by reading the current version out
# of the remote metadata.json, so four jobs left to bump on their own would read the same number
@@ -167,24 +156,14 @@ jobs:
echo "$GITHUB_RUN_ID" | gcloud storage cp - "$probe"
gcloud storage rm "$probe"
- # BOTH macOS builds, side by side: one universal app built twice, differing only in its renderer
- # (Intel on Skia, Apple Silicon on Impeller — RELEASE.md, "Two macOS builds"). A macos-15 runner is
- # Apple Silicon and neither build needs an Intel host: both are universal, and the renderer is an
- # Info.plist key, not a compile.
+ # Compile the universal app once, then derive the two renderer bundles. Both
+ # retain arm64+x86_64; their packaging/notarization/uploads run in parallel.
build-macos:
needs: [version, preflight]
runs-on: macos-15
timeout-minutes: 60 # two notarization submissions per build (zip, then dmg) — see RELEASE.md
- strategy:
- # Each build writes its own scratch manifest, so they cannot race — and one failing should say
- # so on its own rather than cancel the other mid-notarization. `publish` needs both either way.
- fail-fast: false
- matrix:
- variant: [intel, apple-silicon]
env:
- # The script's own env override, pointed at this build's scratch file instead of the real
- # manifest. The artifacts still land on their real GCS paths; only the keys land here.
- METADATA_PATH: ${{ needs.version.outputs.scratch_prefix }}/macos-${{ matrix.variant }}.json
+ MACOS_METADATA_PREFIX: ${{ needs.version.outputs.scratch_prefix }}
defaults:
run:
working-directory: desktop
@@ -218,16 +197,23 @@ jobs:
# SIGN_IDENTITY is read twice here: by publish-macos-variant.sh, re-signing the Intel build once
# it pins the renderer, and by upload-desktop.sh, signing the dmg.
- - name: Build, sign, notarize and upload macOS (${{ matrix.variant }})
+ - name: Build once, then sign, notarize and upload both macOS variants
env:
KEYCHAIN_PASSWORD: ${{ secrets.KEYCHAIN_PASSWORD }}
SIGN_IDENTITY: ${{ secrets.APPLE_SIGNING_IDENTITY }}
VERSION: ${{ needs.version.outputs.version }}
- VARIANT: ${{ matrix.variant }}
run: |
set -euo pipefail
security unlock-keychain -p "$KEYCHAIN_PASSWORD" "$KEYCHAIN_PATH"
- bash scripts/publish-macos-variant.sh "$VARIANT" "$VERSION"
+ python3 scripts/build-macos-variants.py "$VERSION" \
+ --metadata-prefix "$MACOS_METADATA_PREFIX"
+
+ - uses: actions/upload-artifact@v4
+ if: always()
+ with:
+ name: macos-build-timings
+ path: desktop/build/macos-variants/timing.json
+ if-no-files-found: ignore
# Free on an ephemeral runner; the whole point the day this moves to a self-hosted Mac.
- name: Remove the signing keychain
diff --git a/desktop/RELEASE.md b/desktop/RELEASE.md
index 345be9e45..949892832 100644
--- a/desktop/RELEASE.md
+++ b/desktop/RELEASE.md
@@ -142,8 +142,23 @@ commit, differing in one Info.plist key, `FLTEnableImpeller` — which renderer
| Intel | Skia (`FLTEnableImpeller = false`) | `desktop-macos`, `desktop-macos-dmg` | `Harness-macos.{zip,dmg}` | Intel Macs, **every install from before the split on either CPU**, and the website download |
| Apple Silicon | Impeller (the engine default) | `desktop-macos-arm64`, `desktop-macos-arm64-dmg` | `Harness-macos-arm64.{zip,dmg}` | Apple Silicon Macs whose updater knows the key |
-`scripts/publish-macos-variant.sh intel|apple-silicon <version>` builds and publishes one of them;
-`release-desktop.yml` runs both side by side.
+CI calls `scripts/build-macos-variants.py <version> --metadata-prefix <run-prefix>`.
+It compiles one universal app, copies it into separate directories, pins and verifies each
+renderer, then packages, notarizes and uploads both variants in parallel. Version/build-number,
+arm64/x86_64 slices, signatures and hardened runtime are checked before publication. Each variant
+still receives both app and DMG notarization, with the stapled app inside the DMG. Separate scratch
+manifests are combined only after all macOS and Linux builds succeed, followed by verification of
+all six public downloads. `macos-build-timings` records the bounded build and per-variant phases.
+
+`scripts/publish-macos-variant.sh intel|apple-silicon <version>` remains the single-variant entry
+point. With `--no-build`, `APP_BUNDLE` selects an existing bundle; the uploader's `OUTPUT_DIR`
+keeps parallel archives separate. These overrides do not permit rebuilding an arbitrary path.
+Without `--metadata-prefix`, the coordinator only builds and verifies local bundles.
+
+To validate workflow changes with real signing and notarization, dispatch
+`desktop-internal-build.yml` on the candidate branch with `test_build=true`. It builds both
+renderers, verifies all four internal downloads, records timings, and deletes only that run's
+random artifact prefix. It does not update release tags or the live updater manifest.
**Why.** Intel users report the app stuttering; Apple Silicon users do not. Flutter renders macOS with
Impeller by default, and the one thing that differs between those two users running the same universal
diff --git a/desktop/scripts/build-macos-variants.py b/desktop/scripts/build-macos-variants.py
new file mode 100644
index 000000000..2243c070e
--- /dev/null
+++ b/desktop/scripts/build-macos-variants.py
@@ -0,0 +1,151 @@
+#!/usr/bin/env python3
+"""Compile one universal app, derive both renderers and optionally publish them.
+
+Publication requires an explicit per-run metadata prefix. The live Desktop
+manifest is never written here. Both existing signing/notarization paths run,
+in parallel, in separate local directories and remote manifest objects.
+"""
+import argparse
+from concurrent.futures import ThreadPoolExecutor
+import importlib.util
+import json
+import os
+from pathlib import Path
+import re
+import shutil
+import subprocess
+import sys
+import time
+
+DESKTOP = Path(__file__).resolve().parents[1]
+
+
+def module(name, filename):
+ spec = importlib.util.spec_from_file_location(name, DESKTOP.parent / "scripts" / filename)
+ loaded = importlib.util.module_from_spec(spec)
+ spec.loader.exec_module(loaded)
+ return loaded
+
+
+runner = module("validation_runner", "validate-change.py")
+verification = module("desktop_verification", "verify-desktop-release.py")
+VARIANTS = {"intel": "Harness-macos", "apple-silicon": "Harness-macos-arm64"}
+MACOS_KEYS = tuple(key for key in verification.KEYS if key.startswith("desktop-macos"))
+
+
+def object_prefix(value):
+ if not re.fullmatch(r"[A-Za-z0-9._/-]+", value) or value.startswith("/") or ".." in value.split("/"):
+ raise argparse.ArgumentTypeError("prefix must be a literal GCS object directory")
+ return value.rstrip("/")
+
+
+def check(name, argv, timeout=900):
+ return dict(name=name, argv=argv, timeout_seconds=timeout)
+
+
+def phase(checks, desktop, output, receipt):
+ results = runner.run_checks({"checks": checks}, desktop, output, jobs=2)
+ # Dart defines can contain credentials. Never save command arguments or the
+ # inherited environment in the timing artifact; the scripts mask define values.
+ receipt["checks"].extend({key: value for key, value in result.items()
+ if key in {"name", "status", "started_at", "finished_at", "duration_seconds", "exit_code", "cleanup_error"}}
+ for result in results)
+ for result in results:
+ print(f"::group::{result['name']} ({result['status']})", flush=True)
+ if result.get("log"):
+ print(Path(result["log"]).read_text(errors="replace"), flush=True)
+ if result.get("error"):
+ print(result["error"], file=sys.stderr)
+ print("::endgroup::", flush=True)
+ if any(result["status"] != "passed" for result in results):
+ raise RuntimeError("macOS phase failed; see the per-variant results")
+
+
+def build(version, defines, desktop, output, receipt):
+ variant_script = str(desktop / "scripts/publish-macos-variant.sh")
+ phase([check("universal-build", ["bash", variant_script, "apple-silicon", version, "--build-only", *defines], 1800)],
+ desktop, output, receipt)
+ source = desktop / "build/macos/Build/Products/Release/Harness.app"
+ copies = []
+ for variant in VARIANTS:
+ bundle = output / variant / "Harness.app"
+ if bundle.exists():
+ shutil.rmtree(bundle)
+ bundle.parent.mkdir(parents=True, exist_ok=True)
+ copies.append(check(f"copy-{variant}", ["ditto", str(source), str(bundle)], 60))
+ phase(copies, desktop, output, receipt)
+ phase([check(f"renderer-{variant}", ["env", f"APP_BUNDLE={output / variant / 'Harness.app'}",
+ "bash", variant_script, variant, version, "--no-build", "--build-only"], 120)
+ for variant in VARIANTS], desktop, output, receipt)
+
+
+def publication_checks(version, metadata_prefix, artifact_prefix, artifact_suffix, desktop, output):
+ checks = []
+ for variant, filename in VARIANTS.items():
+ key = "desktop-macos" if variant == "intel" else "desktop-macos-arm64"
+ checks.append(check(f"publish-{variant}", [
+ "env", f"APP_BUNDLE={output / variant / 'Harness.app'}", f"OUTPUT_DIR={output / variant}",
+ f"OTA_KEY={key}", f"DMG_KEY={key}-dmg",
+ f"GCS_PATH={artifact_prefix}/{filename}{artifact_suffix}.zip",
+ f"DMG_GCS_PATH={artifact_prefix}/{filename}{artifact_suffix}.dmg",
+ f"METADATA_PATH={metadata_prefix}/macos-{variant}.json",
+ "bash", str(desktop / "scripts/upload-desktop.sh"), "--no-build", version,
+ ], 1800))
+ return checks
+
+
+def verify_downloads(version, prefix):
+ bucket = os.environ.get("GCS_BUCKET", "s3-autonomous-upgrade-3")
+ entries = {}
+ for variant in VARIANTS:
+ manifest, _ = verification.read_manifest(f"https://storage.googleapis.com/{bucket}/{prefix}/macos-{variant}.json", 20)
+ entries.update(manifest)
+ items = verification.entries_for_version(entries, version, keys=MACOS_KEYS)
+ with ThreadPoolExecutor(max_workers=2) as pool:
+ results = list(pool.map(lambda item: verification.verify_artifact(item, 90), items))
+ return results
+
+
+def main(argv=None):
+ parser = argparse.ArgumentParser(description=__doc__)
+ parser.add_argument("version")
+ parser.add_argument("--metadata-prefix", type=object_prefix, help="publish only to these separate per-variant manifests")
+ parser.add_argument("--artifact-prefix", type=object_prefix)
+ parser.add_argument("--artifact-suffix", default="")
+ parser.add_argument("--verify-downloads", action="store_true", help="verify all four internal-build downloads; real releases use their six-artifact final gate")
+ parser.add_argument("--dart-define", action="append", default=[])
+ args = parser.parse_args(argv)
+ if not re.fullmatch(r"(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)", args.version):
+ parser.error("version must be X.Y.Z")
+ if not re.fullmatch(r"[A-Za-z0-9._-]*", args.artifact_suffix):
+ parser.error("artifact suffix must not contain paths")
+ if (args.verify_downloads or args.artifact_prefix or args.artifact_suffix) and not args.metadata_prefix:
+ parser.error("publication options require --metadata-prefix")
+ output = DESKTOP / "build/macos-variants"
+ output.mkdir(parents=True, exist_ok=True)
+ receipt = dict(version=args.version, started_at=runner.utc_now(), status="failed", checks=[])
+ started = time.monotonic()
+ try:
+ build(args.version, [f"--dart-define={item}" for item in args.dart_define], DESKTOP, output, receipt)
+ if args.metadata_prefix:
+ checks = publication_checks(args.version, args.metadata_prefix,
+ args.artifact_prefix or f"harness/desktop/{args.version}",
+ args.artifact_suffix, DESKTOP, output)
+ phase(checks, DESKTOP, output, receipt)
+ if args.verify_downloads:
+ receipt["artifacts"] = verify_downloads(args.version, args.metadata_prefix)
+ if any(item["status"] != "passed" for item in receipt["artifacts"]):
+ raise RuntimeError("an internal macOS download failed verification")
+ receipt["status"] = "passed"
+ except (OSError, ValueError, RuntimeError, subprocess.SubprocessError) as error:
+ receipt["error"] = str(error)
+ print(f"error: {error}", file=sys.stderr)
+ finally:
+ receipt.update(finished_at=runner.utc_now(), duration_seconds=round(time.monotonic() - started, 3))
+ (output / "timing.json").write_text(json.dumps(receipt, indent=2) + "\n")
+ print(f"macOS variants: {receipt['status']} in {receipt['duration_seconds']}s", flush=True)
+ return 0 if receipt["status"] == "passed" else 1
+
+
+if __name__ == "__main__":
+ sys.exit(main())
diff --git a/desktop/scripts/publish-macos-variant.sh b/desktop/scripts/publish-macos-variant.sh
index 33a5d4962..de17c68b4 100755
--- a/desktop/scripts/publish-macos-variant.sh
+++ b/desktop/scripts/publish-macos-variant.sh
@@ -1,8 +1,8 @@
#!/usr/bin/env bash
# Publish ONE of the two macOS builds: build -> pin its renderer -> hand the bundle to
# scripts/upload-desktop.sh --no-build, which packages, notarizes, uploads and merges the manifest
-# exactly as it always has. upload-desktop.sh is not modified — everything reaches it through the
-# flags and env overrides it already takes. See RELEASE.md, "Two macOS builds".
+# through its flags and env overrides. --no-build accepts an existing APP_BUNDLE so
+# build-macos-variants.py can compile once and derive both renderers. See RELEASE.md.
#
# Usage:
# bash scripts/publish-macos-variant.sh intel 1.2.4 # desktop-macos — Skia
@@ -37,15 +37,15 @@ set -euo pipefail
set +x
APP_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" # repository root
-# Where upload-desktop.sh --no-build picks the bundle up (its APP_BUNDLE, which takes no override).
-APP_BUNDLE="$APP_DIR/build/macos/Build/Products/Release/Harness.app"
+# An override is accepted only with --no-build and passed to upload-desktop.sh.
+APP_BUNDLE="${APP_BUNDLE:-$APP_DIR/build/macos/Build/Products/Release/Harness.app}"
PLIST="$APP_BUNDLE/Contents/Info.plist"
SIGN_IDENTITY="${SIGN_IDENTITY:-Developer ID Application}" # same default as upload-desktop.sh
die() { echo "error: $*" >&2; exit 1; }
usage() {
- echo "usage: bash scripts/publish-macos-variant.sh <intel|apple-silicon> <X.Y.Z> [--build-only] [--no-notarize] [--dart-define=KEY=VALUE ...]" >&2
+ echo "usage: bash scripts/publish-macos-variant.sh <intel|apple-silicon> <X.Y.Z> [--build-only] [--no-build] [--no-notarize] [--dart-define=KEY=VALUE ...]" >&2
exit 1
}
@@ -55,16 +55,18 @@ VARIANT="$(printf '%s' "$1" | tr '[:upper:]' '[:lower:]')" # macOS bash 3.2 ha
VER="$2"
shift 2
BUILD_ONLY=0
+DO_BUILD=1
DO_NOTARIZE=1
# Handed to `flutter build` and nowhere else — upload-desktop.sh --no-build never builds. A release
-# passes none; .github/workflows/internal-build.yml passes the flags a tester's build carries.
+# passes none; .github/workflows/desktop-internal-build.yml passes the tester's flags.
DART_DEFINES=()
for arg in "$@"; do
case "$arg" in
--build-only) BUILD_ONLY=1 ;;
+ --no-build) DO_BUILD=0 ;;
--no-notarize) DO_NOTARIZE=0 ;;
--dart-define=*) DART_DEFINES+=("$arg") ;;
- *) die "unknown argument '$arg' — only --build-only, --no-notarize and --dart-define=KEY=VALUE; the version is explicit, so there is nothing to bump" ;;
+ *) die "unknown argument '$arg' — only --build-only, --no-build, --no-notarize and --dart-define=KEY=VALUE; the version is explicit, so there is nothing to bump" ;;
esac
done
@@ -85,20 +87,37 @@ BUILD_NUM=$(( 10#${BASH_REMATCH[1]} * 10000 + 10#${BASH_REMATCH[2]} * 100 + 10#$
[ "$(uname -s)" = Darwin ] || die "a macOS build needs a macOS host"
command -v flutter >/dev/null 2>&1 || die "flutter not found"
-# --- build ---
-echo ">> building the $VARIANT build $VER (build $BUILD_NUM), rendering on $RENDERER"
-# Names only: a define's value can be a credential (GRID_API_TOKEN is one).
-for define in ${DART_DEFINES[@]+"${DART_DEFINES[@]}"}; do
- define="${define#--dart-define=}"
- echo " dart-define ${define%%=*}"
-done
-# Removed first for the reason upload-desktop.sh removes it: an incremental Xcode build can skip
-# re-stamping Info.plist and leave a previous version inside.
-rm -rf "$APP_BUNDLE"
-# `${a[@]+"${a[@]}"}`: an empty array under `set -u` is an error on the bash 3.2 macOS ships.
-( cd "$APP_DIR" && flutter build macos --release --build-name="$VER" --build-number="$BUILD_NUM" \
- ${DART_DEFINES[@]+"${DART_DEFINES[@]}"} )
+# --- build, or derive a renderer variant from an explicitly supplied build ---
+if [ "$DO_BUILD" -eq 0 ]; then
+ [ "${#DART_DEFINES[@]}" -eq 0 ] || die "--dart-define cannot be applied with --no-build"
+ echo ">> using the existing universal app for $VARIANT $VER"
+else
+ [ "$APP_BUNDLE" = "$APP_DIR/build/macos/Build/Products/Release/Harness.app" ] \
+ || die "APP_BUNDLE is only supported with --no-build"
+ echo ">> building the $VARIANT build $VER (build $BUILD_NUM), rendering on $RENDERER"
+ # Names only: a define's value can be a credential (GRID_API_TOKEN is one).
+ for define in ${DART_DEFINES[@]+"${DART_DEFINES[@]}"}; do
+ define="${define#--dart-define=}"
+ echo " dart-define ${define%%=*}"
+ done
+ # An incremental Xcode build can skip re-stamping Info.plist and leave an old version.
+ rm -rf "$APP_BUNDLE"
+ # An empty array under set -u needs this expansion on macOS bash 3.2.
+ ( cd "$APP_DIR" && flutter build macos --release --build-name="$VER" --build-number="$BUILD_NUM" \
+ ${DART_DEFINES[@]+"${DART_DEFINES[@]}"} )
+fi
[ -d "$APP_BUNDLE" ] || die "app bundle missing after the build: $APP_BUNDLE"
+# A copied app must be the requested build and keep both architectures. Renderer
+# selection changes Info.plist only; it must never turn an old/thin app into a release.
+[ "$(plutil -extract CFBundleShortVersionString raw "$PLIST")" = "$VER" ] \
+ || die "app version differs from $VER"
+[ "$(plutil -extract CFBundleVersion raw "$PLIST")" = "$BUILD_NUM" ] \
+ || die "app build number differs from $BUILD_NUM"
+for binary in "$APP_BUNDLE/Contents/MacOS/Harness" \
+ "$APP_BUNDLE/Contents/Frameworks/App.framework/App" \
+ "$APP_BUNDLE/Contents/Frameworks/FlutterMacOS.framework/FlutterMacOS"; do
+ lipo "$binary" -verify_arch arm64 x86_64 || die "not a universal macOS binary: $binary"
+done
# --- pin the renderer ---
renderer_key() { /usr/libexec/PlistBuddy -c "Print :FLTEnableImpeller" "$PLIST" 2>/dev/null || true; }
@@ -144,8 +163,8 @@ if [ "$BUILD_ONLY" -eq 1 ]; then
exit 0
fi
-# --- publish, through the unmodified script ---
-export OTA_KEY
+# --- publish the selected bundle ---
+export APP_BUNDLE OTA_KEY
export DMG_KEY="$OTA_KEY-dmg"
export GCS_PATH="harness/desktop/$VER/$ARTIFACT.zip"
export DMG_GCS_PATH="harness/desktop/$VER/$ARTIFACT.dmg"
diff --git a/desktop/scripts/upload-desktop.sh b/desktop/scripts/upload-desktop.sh
index 3157758ee..866e75bd8 100755
--- a/desktop/scripts/upload-desktop.sh
+++ b/desktop/scripts/upload-desktop.sh
@@ -37,7 +37,8 @@ set -euo pipefail
set +x
APP_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")/.." && pwd)" # repository root
-APP_BUNDLE="$APP_DIR/build/macos/Build/Products/Release/Harness.app"
+APP_BUNDLE="${APP_BUNDLE:-$APP_DIR/build/macos/Build/Products/Release/Harness.app}"
+OUTPUT_DIR="${OUTPUT_DIR:-$APP_DIR/build}"
# --- GCS config (all overridable via env) ---
GCS_BUCKET="${GCS_BUCKET:-s3-autonomous-upgrade-3}"
@@ -194,6 +195,8 @@ echo ">> releasing version: $VER (build $BUILD_NUM)"
# --- Step 2: build ---
if [ "$DO_BUILD" -eq 1 ]; then
+ [ "$APP_BUNDLE" = "$APP_DIR/build/macos/Build/Products/Release/Harness.app" ] \
+ || { echo "error: APP_BUNDLE requires --no-build" >&2; exit 1; }
echo ">> building release $VER"
# Xcode's incremental build sometimes decides the Info.plist processing step is already
# up to date and skips re-stamping MARKETING_VERSION/CURRENT_PROJECT_VERSION into it, silently
@@ -215,7 +218,8 @@ STAMPED="$(plutil -extract CFBundleShortVersionString raw "$APP_BUNDLE/Contents/
[ "$STAMPED" = "$VER" ] || { echo "error: bundle CFBundleShortVersionString is '$STAMPED', expected '$VER'" >&2; exit 1; }
# --- Step 3: package ---
-ZIP="$APP_DIR/build/Harness-macos-$VER.zip"
+mkdir -p "$OUTPUT_DIR"
+ZIP="$OUTPUT_DIR/Harness-macos-$VER.zip"
rm -f "$ZIP"
echo ">> packaging $ZIP"
( cd "$(dirname "$APP_BUNDLE")" && ditto -c -k --sequesterRsrc --keepParent "$(basename "$APP_BUNDLE")" "$ZIP" )
@@ -263,7 +267,7 @@ fi
# `hdiutil` rather than `create-dmg`: the latter is a dependency the release machine would have to
# install, and all it buys here is window chrome. The `/Applications` symlink is what actually makes
# the drag-to-install gesture obvious, and that is one line.
-DMG="$APP_DIR/build/Harness-macos-$VER.dmg"
+DMG="$OUTPUT_DIR/Harness-macos-$VER.dmg"
DMG_STAGE="$(mktemp -d)" # removed by cleanup() on EXIT
echo ">> packaging $DMG"
rm -f "$DMG"
diff --git a/docs/performance/2026-10-02-single-macos-build.json b/docs/performance/2026-10-02-single-macos-build.json
new file mode 100644
index 000000000..8cd13ad3c
--- /dev/null
+++ b/docs/performance/2026-10-02-single-macos-build.json
@@ -0,0 +1,130 @@
+{
+ "run": "https://github.com/autonomous-ai/openharness/actions/runs/37028979450",
+ "sourceCommit": "9de45237607423989a679044164642b292ebb7a7",
+ "kind": "disposable-internal-build",
+ "workflowCreatedAt": "2026-10-02T15:43:29Z",
+ "workflowCompletedAt": "2026-10-02T15:53:23Z",
+ "macosJobStartedAt": "2026-10-02T15:44:03Z",
+ "macosJobCompletedAt": "2026-10-02T15:53:22Z",
+ "productReleasePublished": false,
+ "disposablePrefixDeleted": true,
+ "receipt": {
+ "version": "1.2.55",
+ "started_at": "2026-10-02T15:45:35.515649+00:00",
+ "status": "passed",
+ "checks": [
+ {
+ "name": "universal-build",
+ "started_at": "2026-10-02T15:45:35.515917+00:00",
+ "status": "passed",
+ "exit_code": 0,
+ "duration_seconds": 251.722,
+ "finished_at": "2026-10-02T15:49:47.342212+00:00"
+ },
+ {
+ "name": "copy-intel",
+ "started_at": "2026-10-02T15:49:47.359650+00:00",
+ "status": "passed",
+ "exit_code": 0,
+ "duration_seconds": 7.01,
+ "finished_at": "2026-10-02T15:49:54.408477+00:00"
+ },
+ {
+ "name": "copy-apple-silicon",
+ "started_at": "2026-10-02T15:49:47.392494+00:00",
+ "status": "passed",
+ "exit_code": 0,
+ "duration_seconds": 7.016,
+ "finished_at": "2026-10-02T15:49:54.444318+00:00"
+ },
+ {
+ "name": "renderer-intel",
+ "started_at": "2026-10-02T15:49:54.446441+00:00",
+ "status": "passed",
+ "exit_code": 0,
+ "duration_seconds": 6.115,
+ "finished_at": "2026-10-02T15:50:00.645953+00:00"
+ },
+ {
+ "name": "renderer-apple-silicon",
+ "started_at": "2026-10-02T15:49:54.465058+00:00",
+ "status": "passed",
+ "exit_code": 0,
+ "duration_seconds": 7.528,
+ "finished_at": "2026-10-02T15:50:02.030687+00:00"
+ },
+ {
+ "name": "publish-apple-silicon",
+ "started_at": "2026-10-02T15:50:02.042970+00:00",
+ "status": "passed",
+ "exit_code": 0,
+ "duration_seconds": 175.93,
+ "finished_at": "2026-10-02T15:52:58.037115+00:00"
+ },
+ {
+ "name": "publish-intel",
+ "started_at": "2026-10-02T15:50:02.032567+00:00",
+ "status": "passed",
+ "exit_code": 0,
+ "duration_seconds": 176.268,
+ "finished_at": "2026-10-02T15:52:58.346495+00:00"
+ }
+ ],
+ "artifacts": [
+ {
+ "version": "1.2.55",
+ "url": "https://storage.googleapis.com/s3-autonomous-upgrade-3/harness/desktop-internal/b3ae1f966d8a51a8da6f114728ba6136/Harness-macos-1.2.55-9de4523.zip",
+ "sha256": "c7e8d32c7b6718c87fad57bd8b075c68e73290dac710812103a5c93c7904b914",
+ "size": 115436584,
+ "key": "desktop-macos",
+ "started_at": "2026-10-02T15:52:58.950347+00:00",
+ "status": "passed",
+ "actual_size": 115436584,
+ "actual_sha256": "c7e8d32c7b6718c87fad57bd8b075c68e73290dac710812103a5c93c7904b914",
+ "finished_at": "2026-10-02T15:53:01.970287+00:00",
+ "duration_seconds": 3.02
+ },
+ {
+ "version": "1.2.55",
+ "url": "https://storage.googleapis.com/s3-autonomous-upgrade-3/harness/desktop-internal/b3ae1f966d8a51a8da6f114728ba6136/Harness-macos-1.2.55-9de4523.dmg",
+ "sha256": "97ef2805bf60964e9f62c6e22710dcdb63186034daf3884430a75a096f037af2",
+ "size": 119332686,
+ "key": "desktop-macos-dmg",
+ "started_at": "2026-10-02T15:52:58.954579+00:00",
+ "status": "passed",
+ "actual_size": 119332686,
+ "actual_sha256": "97ef2805bf60964e9f62c6e22710dcdb63186034daf3884430a75a096f037af2",
+ "finished_at": "2026-10-02T15:53:01.979149+00:00",
+ "duration_seconds": 3.025
+ },
+ {
+ "version": "1.2.55",
+ "url": "https://storage.googleapis.com/s3-autonomous-upgrade-3/harness/desktop-internal/b3ae1f966d8a51a8da6f114728ba6136/Harness-macos-arm64-1.2.55-9de4523.zip",
+ "sha256": "42c4c15e8f1a3915b19545bc4d58a1a6a4cc49e2aabb50182448218762fd4e59",
+ "size": 115436574,
+ "key": "desktop-macos-arm64",
+ "started_at": "2026-10-02T15:53:01.971860+00:00",
+ "status": "passed",
+ "actual_size": 115436574,
+ "actual_sha256": "42c4c15e8f1a3915b19545bc4d58a1a6a4cc49e2aabb50182448218762fd4e59",
+ "finished_at": "2026-10-02T15:53:04.953485+00:00",
+ "duration_seconds": 2.982
+ },
+ {
+ "version": "1.2.55",
+ "url": "https://storage.googleapis.com/s3-autonomous-upgrade-3/harness/desktop-internal/b3ae1f966d8a51a8da6f114728ba6136/Harness-macos-arm64-1.2.55-9de4523.dmg",
+ "sha256": "12f4c205194a389fd3a0f589929d3e3a7725271134054459a4b189fdfcf545bf",
+ "size": 119332955,
+ "key": "desktop-macos-arm64-dmg",
+ "started_at": "2026-10-02T15:53:01.979345+00:00",
+ "status": "passed",
+ "actual_size": 119332955,
+ "actual_sha256": "12f4c205194a389fd3a0f589929d3e3a7725271134054459a4b189fdfcf545bf",
+ "finished_at": "2026-10-02T15:53:05.086585+00:00",
+ "duration_seconds": 3.107
+ }
+ ],
+ "finished_at": "2026-10-02T15:53:05.087475+00:00",
+ "duration_seconds": 449.572
+ }
+}
diff --git a/docs/performance/2026-10-02-single-macos-build.md b/docs/performance/2026-10-02-single-macos-build.md
new file mode 100644
index 000000000..d84581390
--- /dev/null
+++ b/docs/performance/2026-10-02-single-macos-build.md
@@ -0,0 +1,63 @@
+# Compile the universal macOS app once
+
+Desktop releases compiled the same universal application twice. Only the renderer
+selection in Info.plist differed. In [1.2.52](https://github.com/autonomous-ai/openharness/actions/runs/37017329208),
+those compilations took approximately 2m10s and 4m45s on separate macOS runners.
+Both had to finish before publication.
+
+The release and internal-build workflows now call one coordinator. It compiles once,
+copies independent bundles, verifies both architectures and versions, pins each
+renderer, and runs both publication paths concurrently. Each retains app and DMG
+notarization, stapling, Gatekeeper checks, and separate immutable artifact paths.
+The final release still requires both Linux builds, guarded manifest publication,
+and all six public download checks.
+
+## Native validation
+
+[Run 37028979450](https://github.com/autonomous-ai/openharness/actions/runs/37028979450)
+passed on candidate `9de45237607423989a679044164642b292ebb7a7`, using Flutter 3.47.2
+on macos-15. This was a disposable internal build, with self-update disabled. Its
+version label was 1.2.55; it did not publish a product release or update live metadata.
+
+| Phase | Measured time |
+| --- | ---: |
+| One universal build and initial signature checks | 4m11.722s |
+| Two copies, concurrently | 7.085s elapsed |
+| Renderer/signature checks, concurrently | 7.584s elapsed |
+| Both package/notarize/upload paths, concurrently | 2m56.314s elapsed |
+| Four full download checks, after manifest reads | 6.136s elapsed |
+| Coordinator, including manifest reads and overhead | 7m29.572s |
+| Complete macOS job, including setup and cleanup | 9m19s |
+| Complete internal workflow | 9m54s |
+
+Both app bundles and DMGs received Apple's Accepted verdict and passed Gatekeeper.
+All four public downloads matched version, SHA-256 and size. The cleanup step then
+removed the four archives and two scratch manifests under only this run's random
+prefix. The [raw timing record](2026-10-02-single-macos-build.json) retains these
+results; its internal download URLs have intentionally been deleted.
+
+The first native trial failed before uploading because the new `lipo -verify_arch`
+call put the file after the architecture list. The corrected argument order passed
+against a local universal object and then in the complete native workflow above.
+
+The process suite passed all 56 tests locally and in
+[CI 37028026483](https://github.com/autonomous-ai/openharness/actions/runs/37028026483).
+That CI ran at `3977fc0c8`; the only executable change afterward was the lipo argument
+correction, exercised by the successful native run. Workflow lint and shell syntax
+passed. The later fixture-only change in #627 does not alter application or build
+inputs. These evidence documents were added after validation.
+
+## What the timing establishes
+
+One compilation now supplies both variants, and their packaging overlaps. The new
+macOS job was 1m11s shorter than 1.2.54's 10m30s critical Mac job, 24s shorter than
+1.2.52's 9m43s, and 55s longer than 1.2.53's 8m24s. These runs used different source
+revisions and runner/notary conditions; this is not a controlled end-to-end benchmark.
+The internal workflow also excludes Linux builds and live release publication.
+Do not subtract its total directly from a product release or promise a fixed saving.
+
+Duplicate compilation and a second macOS runner are removed. The observed compilation
+variance remains a larger uncertainty than the roughly 15 seconds needed to copy and
+check both derived bundles. Measure the next real releases before claiming a stable
+wall-clock improvement. The separately merged [fixture setup fix](2026-10-02-desktop-fixture-stalls.md)
+addresses four pre-merge test stalls; it does not depend on this build change.
diff --git a/scripts/tests/test_desktop_verification.py b/scripts/tests/test_desktop_verification.py
index 85d665d94..10688f19d 100644
--- a/scripts/tests/test_desktop_verification.py
+++ b/scripts/tests/test_desktop_verification.py
@@ -126,6 +126,16 @@ class DesktopVerificationTests(unittest.TestCase):
self.assertEqual(code, 1)
self.assertEqual(json.loads(receipt.read_text())["status"], "failed")
+ def test_internal_macos_scope_keeps_all_four_and_release_still_requires_six(self):
+ macos = tuple(key for key in verify.KEYS if key.startswith("desktop-macos"))
+ manifest = {key: self.manifest[key] for key in macos}
+ self.assertEqual(len(verify.entries_for_version(manifest, "1.2.3", keys=macos)), 4)
+ with self.assertRaises(ValueError):
+ verify.entries_for_version(manifest, "1.2.3")
+ manifest.pop(macos[-1])
+ with self.assertRaises(ValueError):
+ verify.entries_for_version(manifest, "1.2.3", keys=macos)
+
if __name__ == "__main__":
unittest.main()
diff --git a/scripts/tests/test_macos_variants.py b/scripts/tests/test_macos_variants.py
new file mode 100644
index 000000000..6ddb3c45f
--- /dev/null
+++ b/scripts/tests/test_macos_variants.py
@@ -0,0 +1,148 @@
+"""Run the build coordinator with disposable toolchain/publication processes.
+
+These cover orchestration and failure isolation. Real signing, renderer pins,
+universal binaries, notarization and downloads are checked by the internal build.
+"""
+import importlib.util
+import json
+import os
+from pathlib import Path
+import sys
+import tempfile
+import unittest
+from unittest import mock
+
+ROOT = Path(__file__).resolve().parents[2]
+spec = importlib.util.spec_from_file_location("macos_variants", ROOT / "desktop/scripts/build-macos-variants.py")
+variants = importlib.util.module_from_spec(spec)
+spec.loader.exec_module(variants)
+
+
+class MacOSVariantTests(unittest.TestCase):
+ def setUp(self):
+ self.temp = tempfile.TemporaryDirectory()
+ self.addCleanup(self.temp.cleanup)
+ self.desktop = Path(self.temp.name) / "desktop with spaces"
+ scripts = self.desktop / "scripts"
+ scripts.mkdir(parents=True)
+ self.bin = self.desktop / "tools"
+ self.bin.mkdir()
+ (self.bin / "variant.py").write_text('''import os,sys
+from pathlib import Path
+variant,version,*args=sys.argv[1:]
+if "--no-build" in args:
+ app=Path(os.environ["APP_BUNDLE"])
+ assert app.joinpath("version").read_text()==version
+ app.joinpath("renderer").write_text(variant)
+else:
+ if os.environ.get("COORDINATOR_FAIL")=="build":sys.exit(4)
+ assert variant=="apple-silicon"
+ counter=Path("compile-count")
+ counter.write_text(str(int(counter.read_text())+1) if counter.exists() else "1")
+ Path("build-args.json").write_text(__import__("json").dumps(args))
+ app=Path("build/macos/Build/Products/Release/Harness.app")
+ app.mkdir(parents=True,exist_ok=True)
+ app.joinpath("version").write_text(version)
+ app.joinpath("payload").write_text("shared compiled bytes")
+print("variant ready")
+''')
+ (self.bin / "upload.py").write_text('''import json,os,sys,time
+from pathlib import Path
+assert sys.argv[1]=="--no-build"
+version=sys.argv[2]
+app=Path(os.environ["APP_BUNDLE"])
+assert app.joinpath("version").read_text()==version
+variant=app.joinpath("renderer").read_text()
+other="apple-silicon" if variant=="intel" else "intel"
+Path(variant+"-started").touch()
+deadline=time.monotonic()+2
+while not Path(other+"-started").exists():
+ if time.monotonic()>deadline:raise RuntimeError("publication did not overlap")
+ time.sleep(.01)
+record={key:os.environ[key] for key in ("APP_BUNDLE","OUTPUT_DIR","OTA_KEY","DMG_KEY","GCS_PATH","DMG_GCS_PATH","METADATA_PATH")}
+Path(variant+"-publication.json").write_text(json.dumps(record))
+if os.environ.get("COORDINATOR_FAIL")==variant:sys.exit(7)
+for extension in ("zip","dmg"):
+ Path(os.environ["OUTPUT_DIR"],"Harness-macos-"+version+"."+extension).write_text(app.joinpath("payload").read_text())
+print("published fixture")
+''')
+ for script, tool in (("publish-macos-variant.sh", "variant.py"), ("upload-desktop.sh", "upload.py")):
+ (scripts / script).write_text(f'exec "{sys.executable}" tools/{tool} "$@"\n')
+ ditto = self.bin / "ditto"
+ ditto.write_text(f"#!{sys.executable}\nimport shutil,sys\nshutil.copytree(sys.argv[1],sys.argv[2])\n")
+ ditto.chmod(0o755)
+ self.environment = mock.patch.dict(os.environ, PATH=str(self.bin) + os.pathsep + os.environ["PATH"])
+ self.environment.start()
+ self.addCleanup(self.environment.stop)
+ self.output = self.desktop / "build/macos-variants"
+
+ def run_build(self, *options):
+ with mock.patch.object(variants, "DESKTOP", self.desktop):
+ result = variants.main(["1.2.3", *options])
+ receipt = json.loads((self.output / "timing.json").read_text())
+ return result, receipt
+
+ def test_builds_once_and_derives_independent_renderer_bundles(self):
+ result, receipt = self.run_build("--dart-define=PRIVATE_FIXTURE=do-not-record-this")
+ self.assertEqual(result, 0, receipt)
+ self.assertEqual((self.desktop / "compile-count").read_text(), "1")
+ self.assertIn("--dart-define=PRIVATE_FIXTURE=do-not-record-this", json.loads((self.desktop / "build-args.json").read_text()))
+ self.assertNotIn("do-not-record-this", json.dumps(receipt))
+ for variant in variants.VARIANTS:
+ app = self.output / variant / "Harness.app"
+ self.assertEqual((app / "renderer").read_text(), variant)
+ self.assertEqual((app / "payload").read_text(), "shared compiled bytes")
+ self.assertFalse((self.desktop / "build/macos/Build/Products/Release/Harness.app/renderer").exists())
+ self.assertFalse(list(self.desktop.glob("*-publication.json")), "build-only published artifacts")
+
+ def test_publications_overlap_without_sharing_artifact_or_manifest_paths(self):
+ result, receipt = self.run_build("--metadata-prefix", "harness/desktop/.ci/123")
+ self.assertEqual(result, 0, receipt)
+ intel = json.loads((self.desktop / "intel-publication.json").read_text())
+ arm = json.loads((self.desktop / "apple-silicon-publication.json").read_text())
+ for field in intel:
+ self.assertNotEqual(intel[field], arm[field], field)
+ self.assertEqual(intel["GCS_PATH"], "harness/desktop/1.2.3/Harness-macos.zip")
+ self.assertEqual(arm["GCS_PATH"], "harness/desktop/1.2.3/Harness-macos-arm64.zip")
+ self.assertEqual(intel["METADATA_PATH"], "harness/desktop/.ci/123/macos-intel.json")
+ self.assertEqual(arm["METADATA_PATH"], "harness/desktop/.ci/123/macos-apple-silicon.json")
+ self.assertEqual((self.desktop / "compile-count").read_text(), "1")
+
+ def test_internal_build_prefix_and_suffix_stay_off_product_paths(self):
+ prefix = "harness/desktop-internal/" + "a" * 32
+ result, receipt = self.run_build("--metadata-prefix", prefix, "--artifact-prefix", prefix, "--artifact-suffix=-1.2.3-abcd123")
+ self.assertEqual(result, 0, receipt)
+ for variant, filename in variants.VARIANTS.items():
+ record = json.loads((self.desktop / f"{variant}-publication.json").read_text())
+ self.assertEqual(record["GCS_PATH"], f"{prefix}/{filename}-1.2.3-abcd123.zip")
+ self.assertEqual(record["DMG_GCS_PATH"], f"{prefix}/{filename}-1.2.3-abcd123.dmg")
+
+ def test_failed_variant_blocks_success_but_preserves_both_results(self):
+ with mock.patch.dict(os.environ, COORDINATOR_FAIL="intel"):
+ result, receipt = self.run_build("--metadata-prefix", "harness/desktop/.ci/123")
+ self.assertEqual(result, 1)
+ results = {item["name"]: item for item in receipt["checks"]}
+ self.assertEqual(results["publish-intel"]["status"], "failed")
+ self.assertEqual(results["publish-apple-silicon"]["status"], "passed")
+ self.assertEqual(receipt["status"], "failed")
+
+ def test_failed_build_never_starts_publication(self):
+ with mock.patch.dict(os.environ, COORDINATOR_FAIL="build"):
+ result, receipt = self.run_build("--metadata-prefix", "harness/desktop/.ci/123")
+ self.assertEqual(result, 1)
+ self.assertEqual(len(receipt["checks"]), 1)
+ self.assertFalse(list(self.desktop.glob("*-publication.json")))
+
+ def test_invalid_versions_and_paths_fail_before_building(self):
+ for arguments in (["../escape"], ["1.2.3", "--metadata-prefix", "../live"],
+ ["1.2.3", "--metadata-prefix", "/absolute"], ["1.2.3", "--artifact-prefix", "prefix"],
+ ["1.2.3", "--metadata-prefix", "scratch", "--artifact-suffix=../../escape"]):
+ with self.subTest(arguments=arguments), mock.patch.object(variants, "DESKTOP", self.desktop):
+ with self.assertRaises(SystemExit) as error:
+ variants.main(arguments)
+ self.assertEqual(error.exception.code, 2)
+ self.assertFalse((self.desktop / "compile-count").exists())
+
+
+if __name__ == "__main__":
+ unittest.main()
diff --git a/scripts/verify-desktop-release.py b/scripts/verify-desktop-release.py
index def1ca95f..0c5d3952f 100644
--- a/scripts/verify-desktop-release.py
+++ b/scripts/verify-desktop-release.py
@@ -55,13 +55,13 @@ def read_manifest(url, timeout):
return json.loads(result.stdout), hashlib.sha256(result.stdout).hexdigest()
-def entries_for_version(manifest, version):
+def entries_for_version(manifest, version, keys=KEYS):
if not re.fullmatch(r"(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)", version):
raise ValueError("expected version must be X.Y.Z")
if not isinstance(manifest, dict):
raise ValueError("manifest must be an object")
entries = []
- for key in KEYS:
+ for key in keys:
entry = manifest.get(key)
if not isinstance(entry, dict) or entry.get("version") != version:
raise ValueError(f"{key}: missing entry or version differs from {version}")