Skip to content

armgit / cua

Public Imported from GitHub
0

Scale computer-use 2.0 with open-source drivers, cross-OS sandboxes, and benchmarks for training, evaluation, and data generation.

ci(spaces): one macOS producer per libs/cua tree, called by the main build (#6596)

Francesco Bonaccid3ef3a75cac9
diff --git a/.github/scripts/spaces_inputs_tree.sh b/.github/scripts/spaces_inputs_tree.sh
index 626a6a00d7..581789c32b 100755
--- a/.github/scripts/spaces_inputs_tree.sh
+++ b/.github/scripts/spaces_inputs_tree.sh
@@ -13,8 +13,10 @@ rev="${1:-HEAD}"
inputs=(
apps/cua-spaces-macos apps/cua-spaces apps/cua-spaces-desktop apps/cua-spaces-web
libs/cua libs/cua-spacesd/VERSION
+ libs/images/sandbox-images.json .cargo .github/scripts/spaces_rust_slice_inputs.py
.github/actions/spaces-native .github/actions/spaces-rust-slice .github/actions/setup-protoc
.github/workflows/cd-cua-spaces-build.yml
+ .github/workflows/ci-cua-spaces-rust-slice.yml .github/workflows/cd-cua-spaces-natives-main.yml
)
args=()
for p in "${inputs[@]}"; do args+=("$rev:$p"); done
diff --git a/.github/scripts/tests/test_ci_cua_spaces_macos_workflow.py b/.github/scripts/tests/test_ci_cua_spaces_macos_workflow.py
index 57649214d7..c3bcdc5090 100644
--- a/.github/scripts/tests/test_ci_cua_spaces_macos_workflow.py
+++ b/.github/scripts/tests/test_ci_cua_spaces_macos_workflow.py
@@ -128,7 +128,9 @@ def test_the_slice_action_builds_by_default_and_restores_only_on_request():
):
assert step["if"].startswith("inputs.build == 'true' &&"), step
# The producer and the release keep their behaviour: they pass no `build`.
- for workflow in ("ci-cua-spaces-rust-slice.yml", "cd-cua-spaces.yml", "cd-cua-spaces-build.yml"):
+ # (The main build's consumer stage restores only; its producer is the
+ # ci-cua-spaces-rust-slice.yml stage it calls.)
+ for workflow in ("ci-cua-spaces-rust-slice.yml", "cd-cua-spaces.yml"):
text = (ROOT / ".github/workflows" / workflow).read_text()
assert "spaces-rust-slice" in text
assert 'build: "false"' not in text
diff --git a/.github/scripts/tests/test_spaces_rust_slice_inputs.py b/.github/scripts/tests/test_spaces_rust_slice_inputs.py
index 250c062ffa..3a0ad6377a 100644
--- a/.github/scripts/tests/test_spaces_rust_slice_inputs.py
+++ b/.github/scripts/tests/test_spaces_rust_slice_inputs.py
@@ -26,6 +26,7 @@ spec.loader.exec_module(inputs)
ACTION = yaml.safe_load((ROOT / ".github/actions/spaces-rust-slice/action.yml").read_text())
PRODUCER = yaml.safe_load((ROOT / ".github/workflows/ci-cua-spaces-rust-slice.yml").read_text())
+BUILD = yaml.safe_load((ROOT / ".github/workflows/cd-cua-spaces-build.yml").read_text())
MACOS = yaml.safe_load((ROOT / ".github/workflows/ci-cua-spaces-macos.yml").read_text())
needs_toml = pytest.mark.skipif(inputs._load_toml is None, reason="no TOML parser for the dependency closure")
@@ -198,7 +199,12 @@ def test_the_action_keys_the_cache_on_the_script():
@needs_toml
def test_the_producer_runs_on_main_when_any_input_changes(extra):
- patterns = PRODUCER[True]["push"]["paths"]
+ # The producer is a stage of the one main pipeline (cd-cua-spaces-build.yml),
+ # which calls it; it has no push trigger of its own, so it never builds
+ # beside the pipeline (CUA-3562).
+ assert "push" not in PRODUCER[True] and "workflow_call" in PRODUCER[True]
+ assert PRODUCER["jobs"] and BUILD["jobs"]["slice"]["uses"] == "./.github/workflows/ci-cua-spaces-rust-slice.yml"
+ patterns = BUILD[True]["push"]["paths"]
for entry in extra:
for path in tracked(entry):
assert any(glob_matches(p, path) for p in patterns), f"{path} does not trigger the producer"
diff --git a/.github/scripts/tests/test_spaces_single_producer.py b/.github/scripts/tests/test_spaces_single_producer.py
new file mode 100644
index 0000000000..e709d88cb5
--- /dev/null
+++ b/.github/scripts/tests/test_spaces_single_producer.py
@@ -0,0 +1,74 @@
+# SPDX-License-Identifier: FSL-1.1-Apache-2.0
+"""One macOS producer per libs/cua tree (CUA-3562).
+
+The main-branch producers (SwiftUI Rust slice, Electron macOS natives) are
+stages of cd-cua-spaces-build.yml, called once per tree, instead of
+workflows of their own that build beside it. A tag run restores what they
+saved. These checks keep it that way.
+"""
+
+from pathlib import Path
+
+import yaml
+
+ROOT = Path(__file__).resolve().parents[3]
+WF = ROOT / ".github/workflows"
+
+
+def load(name):
+ return yaml.safe_load((WF / name).read_text())
+
+
+BUILD = load("cd-cua-spaces-build.yml")
+SLICE = load("ci-cua-spaces-rust-slice.yml")
+NATIVES = load("cd-cua-spaces-natives-main.yml")
+
+
+def test_producers_have_no_push_trigger_of_their_own():
+ for wf in (SLICE, NATIVES):
+ assert "workflow_call" in wf[True]
+ assert "push" not in wf[True]
+ assert "concurrency" not in wf
+
+
+def test_the_build_calls_both_producers_once_per_tree():
+ jobs = BUILD["jobs"]
+ assert jobs["slice"]["uses"] == "./.github/workflows/ci-cua-spaces-rust-slice.yml"
+ assert jobs["natives-mac"]["uses"] == "./.github/workflows/cd-cua-spaces-natives-main.yml"
+ for name in ("slice", "natives-mac"):
+ assert "plan" in jobs[name]["needs"]
+ assert "needs.plan.outputs.skip != 'true'" in (jobs[name].get("if") or "needs.plan.outputs.skip != 'true'")
+ # The stable build set does not wait for the beta-only natives.
+ for name in ("assemble", "verify", "attest"):
+ assert "natives-mac" not in jobs[name].get("needs", [])
+
+
+def test_the_consumer_restores_and_alerts_on_a_miss_instead_of_building():
+ macos = BUILD["jobs"]["macos-rust"]
+ assert "slice" in macos["needs"]
+ steps = macos["steps"]
+ use = next(s for s in steps if s.get("uses") == "./.github/actions/spaces-rust-slice")
+ assert use["with"]["build"] == "false"
+ miss = next(s for s in steps if s.get("name", "").startswith("The producer left the slice"))
+ assert "cache-hit != 'true'" in miss["if"] and "exit 1" in miss["run"]
+
+
+def test_natives_producer_builds_only_macos_the_pipeline_builds_the_rest():
+ include = NATIVES["jobs"]["electron-native"]["strategy"]["matrix"]["include"]
+ assert {i["label"] for i in include} == {"darwin-arm64", "darwin-x64"}
+ assert all(i["runner"] == "macos-26" for i in include)
+ build_labels = {i["label"] for i in BUILD["jobs"]["electron-native"]["strategy"]["matrix"]["include"]}
+ assert {"win32-x64", "win32-arm64", "linux-x64", "linux-arm64"} <= build_labels
+
+
+def test_the_build_is_watched_by_the_failure_alerts():
+ alerts = load("workflow-failure-alerts.yml")
+ assert "CD: Cua Spaces build (shadow)" in alerts[True]["workflow_run"]["workflows"]
+ assert "CD: Cua Spaces build (shadow)=" in alerts["jobs"]["alert"]["env"]["WATCH"]
+
+
+def test_the_tree_hash_covers_every_trigger_path_outside_the_listed_directories():
+ tree = (ROOT / ".github/scripts/spaces_inputs_tree.sh").read_text()
+ for path in ("libs/images/sandbox-images.json", ".cargo", ".github/scripts/spaces_rust_slice_inputs.py",
+ ".github/workflows/ci-cua-spaces-rust-slice.yml", ".github/workflows/cd-cua-spaces-natives-main.yml"):
+ assert path in tree, path
diff --git a/.github/workflows/cd-cua-spaces-build.yml b/.github/workflows/cd-cua-spaces-build.yml
index 8e4db9cae6..73025c8cfc 100644
--- a/.github/workflows/cd-cua-spaces-build.yml
+++ b/.github/workflows/cd-cua-spaces-build.yml
@@ -55,11 +55,19 @@ on:
- "apps/cua-spaces-web/**"
- "libs/cua/**"
- "libs/cua-spacesd/VERSION"
+ # Files outside libs/cua that the SwiftUI Rust slice reads at compile
+ # time (spaces_rust_slice_inputs.py lists them; a unit test checks this
+ # list covers them). apps/cua-spaces-web is above.
+ - "libs/images/sandbox-images.json"
+ - ".cargo/**"
+ - ".github/scripts/spaces_rust_slice_inputs.py"
- ".github/actions/spaces-native/**"
- ".github/actions/spaces-rust-slice/**"
- ".github/actions/setup-protoc/**"
- ".github/scripts/spaces_build_*.py"
- ".github/workflows/cd-cua-spaces-build.yml"
+ - ".github/workflows/ci-cua-spaces-rust-slice.yml"
+ - ".github/workflows/cd-cua-spaces-natives-main.yml"
workflow_dispatch:
inputs:
force:
@@ -211,11 +219,37 @@ jobs:
SPACESD_WAIT_MINUTES: "30"
run: .github/scripts/check_spacesd_published.sh "$CUA_RELEASE_REPOSITORY"
- # The SwiftUI app's Rust slices, restored from the cache the main producer
- # (ci-cua-spaces-rust-slice.yml) fills, or built.
+ # The producers: the one place a libs/cua tree is compiled on main. Each
+ # builds on a cache miss and saves, under the keys the tag run
+ # (cd-cua-spaces.yml) restores, so a release of a commit that main built
+ # compiles nothing. They run once per tree (`plan` skips a tree with a live
+ # build) and one build at a time, never beside another producer.
+ #
+ # SwiftUI app Rust slices (arm64, x86_64), with the cache-key check.
+ slice:
+ name: Producer, SwiftUI Rust
+ needs: [plan, spacesd-published]
+ if: needs.plan.outputs.skip != 'true'
+ uses: ./.github/workflows/ci-cua-spaces-rust-slice.yml
+ permissions:
+ contents: read
+
+ # Electron macOS native layers (beta releases restore them). Not needed by
+ # the stable build set below, so a failure here does not block it.
+ natives-mac:
+ name: Producer, Electron macOS natives
+ needs: [plan, spacesd-published]
+ if: needs.plan.outputs.skip != 'true' && inputs.channel != 'nightly'
+ uses: ./.github/workflows/cd-cua-spaces-natives-main.yml
+ permissions:
+ contents: read
+
+ # The SwiftUI app's Rust slices, restored from the cache `slice` just
+ # filled. A miss here is an alert (the workflow is watched by
+ # workflow-failure-alerts.yml): it never compiles a second copy.
macos-rust:
name: SwiftUI Rust (${{ matrix.arch }})
- needs: [plan, spacesd-published]
+ needs: [plan, spacesd-published, slice]
runs-on: macos-26
timeout-minutes: 180
strategy:
@@ -227,8 +261,15 @@ jobs:
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/spaces-rust-slice
+ id: slice
with:
triple: ${{ matrix.triple }}
+ build: "false"
+ - name: The producer left the slice in the cache
+ if: steps.slice.outputs.cache-hit != 'true'
+ run: |
+ echo "::error title=Cache miss on main::The SwiftUI Rust slice (${{ matrix.triple }}) is not in the Actions cache although the producer stage just ran. Key: ${{ steps.slice.outputs.key }}. Not compiling a second copy."
+ exit 1
# microVMs on Apple silicon: the static aarch64 guest init the app
# bundles (build-release.sh --skip-cargo takes it from here). Same
# step as cd-cua-spaces.yml.
diff --git a/.github/workflows/cd-cua-spaces-natives-main.yml b/.github/workflows/cd-cua-spaces-natives-main.yml
index 651e9c236e..17c0a9af66 100644
--- a/.github/workflows/cd-cua-spaces-natives-main.yml
+++ b/.github/workflows/cd-cua-spaces-natives-main.yml
@@ -1,7 +1,8 @@
name: "CD: Cua Spaces natives on main"
-# Keeps the release's compiled native layers warm, so a cua-spaces-v* tag
-# run (cd-cua-spaces.yml) restores them instead of compiling for an hour.
+# Keeps the release's compiled macOS native layers (Electron, beta releases)
+# warm, so a cua-spaces-v* tag run (cd-cua-spaces.yml) restores them instead
+# of compiling for an hour and a half.
#
# A tag run can restore only its own tag's caches and main's (a cache saved
# by a dry run on a branch or a PR is invisible to it). This workflow builds,
@@ -27,25 +28,17 @@ name: "CD: Cua Spaces natives on main"
# branch to try a change; the first push to main runs it for real.
on:
- push:
- branches: [main]
- paths:
- - "libs/cua/**"
- - "libs/cua-spacesd/VERSION"
- - "apps/cua-spaces-desktop/scripts/build-native.mjs"
- - ".github/actions/spaces-native/**"
- - ".github/workflows/cd-cua-spaces-natives-main.yml"
+ # A stage of cd-cua-spaces-build.yml (the one main pipeline), which calls it
+ # once per libs/cua tree. No push trigger of its own: it used to run beside
+ # the build and compile the same libraries at the same time (CUA-3562).
+ workflow_call:
workflow_dispatch:
permissions:
contents: read
-# One run at a time, never cancelled: a newer push waits (and replaces any
-# older waiting run), so the macOS runners are not all taken by warm-ups and
-# every run that starts finishes and saves.
-concurrency:
- group: cd-cua-spaces-natives-${{ github.ref }}
- cancel-in-progress: false
+# No concurrency group: the caller runs one build at a time and never
+# cancels it.
# Same as cd-cua-spaces.yml: CUA_RELEASE_REPOSITORY is part of the native
# cache key, and rust-cache hashes the CARGO_* variables into its own key.
@@ -66,10 +59,8 @@ jobs:
fail-fast: false
matrix:
include:
- - { label: win32-x64, runner: windows-latest, target: x86_64-pc-windows-msvc }
- - { label: win32-arm64, runner: windows-11-arm, target: aarch64-pc-windows-msvc }
- - { label: linux-x64, runner: ubuntu-22.04, target: x86_64-unknown-linux-gnu }
- - { label: linux-arm64, runner: ubuntu-22.04-arm, target: aarch64-unknown-linux-gnu }
+ # Windows and Linux are built (and cached under the same keys) by
+ # electron-native in cd-cua-spaces-build.yml, which also needs them.
- { label: darwin-arm64, runner: macos-26, target: aarch64-apple-darwin }
- { label: darwin-x64, runner: macos-26, target: x86_64-apple-darwin }
defaults:
diff --git a/.github/workflows/ci-cua-spaces-rust-slice.yml b/.github/workflows/ci-cua-spaces-rust-slice.yml
index 1468c24f13..29bfb6f8ae 100644
--- a/.github/workflows/ci-cua-spaces-rust-slice.yml
+++ b/.github/workflows/ci-cua-spaces-rust-slice.yml
@@ -1,7 +1,8 @@
name: "CI: Cua Spaces SwiftUI Rust slice (producer)"
# The one trusted producer of the SwiftUI app's compiled Rust slice. It builds
-# the slice on main for every change to its inputs and saves it in the Actions
+# the slice on main (as a stage of cd-cua-spaces-build.yml) for every change to
+# its inputs and saves it in the Actions
# cache under the key the release build (cd-cua-spaces.yml, macos-rust) computes
# from the same action, so a release restores it (seconds) instead of
# compiling (33 to 60 minutes). The key covers every file the build reads
@@ -14,21 +15,11 @@ name: "CI: Cua Spaces SwiftUI Rust slice (producer)"
# unsigned compiled slice.
on:
- push:
- branches: [main]
- paths:
- - "libs/cua/**"
- # Files outside libs/cua that the crates of the slice read at compile
- # time (the action's cache key hashes them; `inputs` of
- # .github/scripts/spaces_rust_slice_inputs.py lists them, and
- # test_spaces_rust_slice_inputs.py fails when this list falls behind).
- - "libs/cua-spacesd/VERSION"
- - "libs/images/sandbox-images.json"
- - "apps/cua-spaces-web/src/lib/keybindings.json"
- - ".cargo/**"
- - ".github/scripts/spaces_rust_slice_inputs.py"
- - ".github/actions/spaces-rust-slice/**"
- - ".github/workflows/ci-cua-spaces-rust-slice.yml"
+ # The main-branch producer is a stage of cd-cua-spaces-build.yml, which
+ # calls this workflow once per libs/cua tree (build once, promote at the
+ # release). It no longer has its own push trigger: it used to run beside the
+ # build, so both compiled the same slice at the same time (CUA-3562).
+ workflow_call:
# A change to the producer itself proves its contract: the first run builds,
# a re-run of the same commit restores (the pull request's own cache scope).
pull_request:
@@ -41,10 +32,9 @@ on:
permissions:
contents: read
-# Never cancel a build in progress: its cache is the point.
-concurrency:
- group: ci-cua-spaces-rust-slice-${{ github.ref }}
- cancel-in-progress: false
+# No concurrency group: the caller (cd-cua-spaces-build.yml) runs one build at
+# a time and never cancels it, and a group here would let a newer run replace
+# this one while it waits.
env:
# Same namespace as cd-cua-spaces.yml, so the keys match.
diff --git a/.github/workflows/workflow-failure-alerts.yml b/.github/workflows/workflow-failure-alerts.yml
index 7f7a432448..9b6a2c66b9 100644
--- a/.github/workflows/workflow-failure-alerts.yml
+++ b/.github/workflows/workflow-failure-alerts.yml
@@ -32,6 +32,7 @@ on:
- "CD: Cua Driver (cross-platform)"
- "CD: Cua Driver SDK packages"
- "CD: Cua Spaces"
+ - "CD: Cua Spaces build (shadow)"
- "CD: cua-spacesd"
- "CD: Lume (macOS)"
- "Release: Prepare component releases"
@@ -71,6 +72,7 @@ jobs:
CD: Cua Driver (cross-platform)=release
CD: Cua Driver SDK packages=release
CD: Cua Spaces=release
+ CD: Cua Spaces build (shadow)=ci
CD: cua-spacesd=release
CD: Lume (macOS)=release
Release: Prepare component releases=release