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: scope E2E: cua SDK with the package graph (CUA-3558, cut #6 addendum) (#6603)

Francesco Bonaccifc856a4902c7
diff --git a/.github/scripts/e2e_cua_sdk_scope.py b/.github/scripts/e2e_cua_sdk_scope.py
index 7b7814c1f6..99a7dec94a 100644
--- a/.github/scripts/e2e_cua_sdk_scope.py
+++ b/.github/scripts/e2e_cua_sdk_scope.py
@@ -39,6 +39,9 @@ from dataclasses import dataclass
from pathlib import Path
from typing import Callable, Optional, Sequence
+sys.path.insert(0, str(Path(__file__).resolve().parent))
+import ci_graph # noqa: E402
+
REPO = Path(__file__).resolve().parents[2]
EXTRACT = REPO / "tests" / "e2e" / "cua-sdk" / "docs" / "extract.py"
@@ -90,6 +93,7 @@ PATHS = (
".github/actions/setup-protoc/**",
".github/actions/rust-cache/**",
".github/scripts/e2e_cua_sdk_scope.py",
+ ".github/scripts/ci_graph.py",
".github/workflows/e2e-cua-sdk.yml",
)
@@ -116,8 +120,46 @@ def _glob(pattern: str) -> re.Pattern[str]:
_INPUTS = [_glob(p) for p in PATHS]
-def is_input(path: str) -> bool:
- return any(rx.match(path) for rx in _INPUTS)
+# The package graph narrows the two broad entries of PATHS (CUA-3558): a file under libs/cua/ or
+# libs/cua-spacesd/ is an input only when it belongs to the dependency closure of what the suite
+# builds and runs. The roots are the SDK and CLI crates, the static cua-spacesd, the cua-test-fixtures
+# crate (libs/cua-spacesd/tests/spaces-e2e), the Rust half of the suite and the TypeScript package.
+GRAPH_SCOPED = ("libs/cua/", "libs/cua-spacesd/")
+ROOT_NAMES = ("cua-sdk", "cua-cli", "cua-spacesd", "cua-sdk-e2e", "cua-spaces-e2e")
+ROOT_DIRS = ("libs/cua/typescript", "libs/cua/python")
+# Directories of libs/cua that the suite never builds, loads or runs.
+NOT_INPUT_DIRS = ("libs/cua/swift/", "libs/cua/kotlin/", "libs/cua/vz/", "libs/cua/bench/")
+
+
+def closure(graph: "ci_graph.Graph") -> set[str]:
+ roots = {d for n in ROOT_NAMES for d in graph.by_name(n)} | {d for d in ROOT_DIRS if d in graph.packages}
+ return graph.closure(roots)
+
+
+# Release notes and a package's top-level README are read by no build or test.
+_NOT_BUILT = re.compile(r"(^|.*/)CHANGELOG\.md\Z|libs/cua(-spacesd)?/[^/]+\.md\Z")
+
+
+def _graph_input(path: str, graph: "ci_graph.Graph", closed: set[str]) -> bool:
+ if _NOT_BUILT.match(path):
+ return False
+ if graph.workspace_file(path):
+ return True # a workspace root manifest, lockfile or toolchain pin affects every member
+ if path.startswith(NOT_INPUT_DIRS):
+ return False
+ owner = graph.owner(path)
+ if owner is None:
+ return True # scripts, protos, images, config: no package to ask, so it counts
+ # A package nested in a closure package (a crate's web/ folder) is built into it.
+ return owner in closed or any(owner.startswith(d + "/") for d in closed)
+
+
+def is_input(path: str, graph: Optional["ci_graph.Graph"] = None) -> bool:
+ if not any(rx.match(path) for rx in _INPUTS):
+ return False
+ if graph is not None and path.startswith(GRAPH_SCOPED):
+ return _graph_input(path, graph, closure(graph))
+ return True
def is_page(path: str) -> bool:
@@ -197,6 +239,7 @@ def decide(
event: str = "pull_request",
head_ref: str = "",
extract=None,
+ graph: Optional["ci_graph.Graph"] = None,
) -> tuple[bool, str]:
if event != "pull_request":
return True, f"{event} runs the suite"
@@ -208,7 +251,7 @@ def decide(
for change in changes:
touched = [change.path] + ([change.old_path] if change.old_path else [])
for path in touched:
- if is_input(path):
+ if is_input(path, graph):
return True, f"{path} is an input of the suite"
if any(is_page(p) for p in touched):
pages.append(change)
@@ -277,11 +320,16 @@ def main(argv: Sequence[str]) -> int:
if event != "pull_request":
run, why = True, f"{event} runs the suite"
else:
+ try:
+ graph = ci_graph.load(args.repo)
+ except Exception: # noqa: BLE001 - no graph, no narrowing: the old, wider filter
+ graph = None
run, why = decide(
git_changes(args.repo, args.base, args.head),
git_reader(args.repo, args.base, args.head),
event,
head_ref,
+ graph=graph,
)
except Exception as exc: # noqa: BLE001 - any doubt runs the suite
run, why = True, f"cannot list the changed files ({exc}), failing closed"
diff --git a/.github/scripts/tests/test_e2e_cua_sdk_scope.py b/.github/scripts/tests/test_e2e_cua_sdk_scope.py
index 6cdf3797af..d30a38c832 100644
--- a/.github/scripts/tests/test_e2e_cua_sdk_scope.py
+++ b/.github/scripts/tests/test_e2e_cua_sdk_scope.py
@@ -531,3 +531,61 @@ def test_gate_does_not_wait_for_a_workflow_that_never_started():
done = run_gate("1\t11\tbuild\tsuccess\tcompleted", "test\tsuccess")
assert done.returncode == 0
assert "E2E: cua SDK" not in done.stdout
+
+
+# --- the package graph narrows libs/cua and libs/cua-spacesd (CUA-3558) ------------
+
+GRAPH = scope.ci_graph.load(ROOT)
+
+
+def graph_decide(*paths):
+ return scope.decide([scope.Change("M", p) for p in paths], lambda side, path: None, graph=GRAPH)
+
+
+ "path",
+ [
+ "libs/cua/crates/cua-spaces-app-core/src/connectors.rs",
+ "libs/cua/crates/cua-spaces-cluster/src/pool/mod.rs",
+ "libs/cua/bench/streaming/budgets.json",
+ "libs/cua/swift/Package.swift",
+ "libs/cua-spacesd/CHANGELOG.md",
+ "libs/cua/CHANGELOG.md",
+ "libs/cua-spacesd/crates/cua-oidc/src/lib.rs",
+ ],
+)
+def test_out_of_closure_files_skip_with_the_graph(path):
+ assert not graph_decide(path)[0]
+
+
+ "path",
+ [
+ "libs/cua/crates/cua-sdk/src/lib.rs",
+ "libs/cua/crates/cua-cli/src/main.rs",
+ "libs/cua/crates/cua-daemon/src/lib.rs",
+ "libs/cua/crates/cua-mesh/src/lib.rs",
+ "libs/cua/typescript/src/index.ts",
+ "libs/cua/python/cua/__init__.py",
+ "libs/cua/scripts/build-test-fixtures.sh",
+ "libs/cua/skills/cua-spaces/SKILL.md",
+ "libs/cua/proto/cua/env/v1/env.proto",
+ "libs/cua/Cargo.lock",
+ "libs/cua-spacesd/Cargo.lock",
+ "libs/cua-spacesd/crates/cua-spacesd-server/src/lib.rs",
+ "libs/cua-spacesd/crates/cua-relay/src/lib.rs",
+ "libs/cua-spacesd/tests/spaces-e2e/src/main.rs",
+ "libs/cua-spacesd/scripts/ci/relay-e2e.sh",
+ "libs/images/linux/build.sh",
+ ],
+)
+def test_closure_files_and_unknown_files_run_with_the_graph(path):
+ assert graph_decide(path)[0]
+
+
+def test_without_a_graph_every_path_in_the_filter_still_runs():
+ assert scope.decide([scope.Change("M", "libs/cua/crates/cua-spaces-app-core/src/x.rs")], lambda s, p: None)[0]
+
+
+def test_one_input_among_out_of_closure_files_runs():
+ assert graph_decide("libs/cua/crates/cua-spaces-app-core/src/x.rs", "libs/cua/crates/cua-sdk/src/lib.rs")[0]
diff --git a/.github/workflows/e2e-cua-sdk.yml b/.github/workflows/e2e-cua-sdk.yml
index c11b673860..1f6475f0c6 100644
--- a/.github/workflows/e2e-cua-sdk.yml
+++ b/.github/workflows/e2e-cua-sdk.yml
@@ -6,8 +6,10 @@ name: "E2E: cua SDK"
# pull_request hermetic (fixtures, daemon) + container (docker + gVisor on
# the locally built reference images) + docs blocks: five
# build jobs in parallel, then 4 test shards (see `jobs:`). A
-# docs edit that leaves every fenced code block as it was
-# skips the suite (the `changes` job,
+# docs edit that leaves every fenced code block as it was,
+# or a change to a crate outside the dependency closure of
+# what the suite builds (package graph, ci_graph.py), skips
+# the suite (the `changes` job,
# .github/scripts/e2e_cua_sdk_scope.py).
# nightly cua-sandbox and local QEMU (KVM) on the reference disk.
# Cua Cloud has ended, so there is no live Fleet lane.
@@ -61,6 +63,7 @@ on:
- ".github/actions/setup-protoc/**"
- ".github/actions/rust-cache/**"
- ".github/scripts/e2e_cua_sdk_scope.py"
+ - ".github/scripts/ci_graph.py"
- ".github/workflows/e2e-cua-sdk.yml"
schedule:
- cron: "23 7 * * *"