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: move e2b-bindings, desktop readiness, Nix Linux off PRs (CUA-3560, audit cut 11) (#6598)

Francesco Bonacci1f1f0c01b039
diff --git a/.github/scripts/tests/test_ci_nightly_shaped.py b/.github/scripts/tests/test_ci_nightly_shaped.py
new file mode 100644
index 0000000000..a184a7d056
--- /dev/null
+++ b/.github/scripts/tests/test_ci_nightly_shaped.py
@@ -0,0 +1,67 @@
+"""Nightly-shaped jobs stay off ordinary pull requests, and are heard when they fail at night."""
+
+from pathlib import Path
+
+import pytest
+import yaml
+
+ROOT = Path(__file__).resolve().parents[3]
+
+# workflow -> (paths that still start it on a pull request, a path that must not, a path main runs it for)
+CASES = {
+ "e2b-bindings.yml": ("libs/cua/swift/Package.swift", "libs/cua/crates/cua-sdk/src/lib.rs", "libs/cua/crates/cua-sdk/src/lib.rs"),
+ "ci-cua-driver-preflight.yml": (
+ "scripts/ci/linux/preflight-rust-e2e.sh",
+ "libs/cua-driver/rust/crates/cua-driver/src/main.rs",
+ "libs/cua-driver/rust/crates/cua-driver/src/main.rs",
+ ),
+ "ci-nix-linux.yml": ("flake.lock", "libs/cua-driver/rust/crates/cua-driver/src/main.rs", "libs/cua-driver/rust/crates/cua-driver/src/main.rs"),
+}
+
+
+def load(name):
+ doc = yaml.safe_load((ROOT / ".github/workflows" / name).read_text())
+ return doc, doc.get("on", doc.get(True))
+
+
+def covered(patterns, path):
+ hit = False
+ for raw in patterns:
+ neg, pat = raw.startswith("!"), raw.lstrip("!")
+ if pat.endswith("/**"):
+ ok = path.startswith(pat[:-3] + "/")
+ elif "*" in pat:
+ continue
+ else:
+ ok = path == pat
+ if ok:
+ hit = not neg
+ return hit
+
+
[email protected]("name", CASES)
+def test_pull_requests_run_it_only_for_the_paths_that_matter(name):
+ _, on = load(name)
+ keeps, skips, main_runs = CASES[name]
+ assert covered(on["pull_request"]["paths"], keeps)
+ assert not covered(on["pull_request"]["paths"], skips)
+ assert covered(on["push"]["paths"], main_runs)
+ assert on["push"]["branches"] == ["main"]
+
+
[email protected]("name", CASES)
+def test_it_runs_every_night_and_a_failure_opens_an_issue(name):
+ doc, on = load(name)
+ assert on["schedule"]
+ report = doc["jobs"]["report"]
+ assert "failure()" in report["if"] and "pull_request" in report["if"]
+ assert report["permissions"] == {"issues": "write"}
+ assert any(s.get("uses") == "./.github/actions/nightly-issue" for s in report["steps"])
+ needs = report["needs"] if isinstance(report["needs"], list) else [report["needs"]]
+ assert set(needs) <= set(doc["jobs"]) - {"report"}
+
+
+def test_the_nightly_failures_also_reach_alertmanager():
+ text = (ROOT / ".github/workflows/workflow-failure-alerts.yml").read_text()
+ for name in ("e2b-bindings", "CI: Cua Driver desktop readiness (non-certifying)", "CI: Nix Linux Rust source"):
+ assert f'- "{name}"' in text and f"{name}=ci" in text
diff --git a/.github/scripts/tests/test_ci_nix_linux_paths.py b/.github/scripts/tests/test_ci_nix_linux_paths.py
index 1fefe9e0d9..3ca9b23199 100644
--- a/.github/scripts/tests/test_ci_nix_linux_paths.py
+++ b/.github/scripts/tests/test_ci_nix_linux_paths.py
@@ -62,10 +62,28 @@ class TestCiNixLinuxPaths(unittest.TestCase):
self.push_paths = event_paths(self.workflow, "push")
def workflow_selected(self, changed_paths: tuple[str, ...]) -> bool:
+ """Does a main push of these paths run the workflow (the full list)?"""
+ return any(path_selected(self.push_paths, path) for path in changed_paths)
+
+ def pull_request_selected(self, changed_paths: tuple[str, ...]) -> bool:
return any(path_selected(self.pull_request_paths, path) for path in changed_paths)
- def test_pull_request_and_main_push_filters_stay_aligned(self) -> None:
- self.assertEqual(self.pull_request_paths, self.push_paths)
+ def test_pull_requests_run_only_on_nix_paths_and_main_runs_the_full_list(self) -> None:
+ # Driver source changes are built on main and nightly, not on every pull request.
+ self.assertTrue(set(self.pull_request_paths) < set(self.push_paths))
+ for path in ("flake.nix", "flake.lock", "nix/cua-driver/package.nix",
+ "libs/cua-driver/rust/Cargo.lock", ".github/workflows/ci-nix-linux.yml"):
+ with self.subTest(path=path):
+ self.assertTrue(self.pull_request_selected((path,)))
+ for path in ("libs/cua-driver/rust/crates/cua-driver/src/main.rs",
+ "libs/cua-driver/rust/crates/platform-linux/src/lib.rs"):
+ with self.subTest(path=path):
+ self.assertFalse(self.pull_request_selected((path,)))
+ self.assertTrue(self.workflow_selected((path,)))
+
+ def test_it_also_runs_every_night_and_reports_a_failure_as_an_issue(self) -> None:
+ self.assertIn(" schedule:\n", self.workflow)
+ self.assertIn("uses: ./.github/actions/nightly-issue", self.workflow)
def test_gallery_only_changes_do_not_select_the_five_job_matrix(self) -> None:
gallery_only = (
diff --git a/.github/workflows/ci-cua-driver-preflight.yml b/.github/workflows/ci-cua-driver-preflight.yml
index e304d607d2..ba8054d3f2 100644
--- a/.github/workflows/ci-cua-driver-preflight.yml
+++ b/.github/workflows/ci-cua-driver-preflight.yml
@@ -1,7 +1,26 @@
name: "CI: Cua Driver desktop readiness (non-certifying)"
+# Not a certifying check (its own name says so), so it is nightly-shaped: 18 minutes
+# on every driver change that tells the author nothing the E2E gate does not.
+# - pull requests: only when the readiness checks themselves change (the
+# preflight scripts, the sandbox actions, this workflow).
+# - push to main on those paths plus the driver crates it builds, and nightly.
+# - a failed main or nightly run opens or updates one issue (`report` job).
on:
pull_request:
+ paths:
+ - "scripts/ci/linux/preflight-rust-e2e.sh"
+ - "scripts/ci/windows/preflight-rust-e2e.ps1"
+ - "scripts/ci/windows/verify-user-session.ps1"
+ - ".github/actions/cua-sandbox/**"
+ - ".github/actions/build-cua-under-test/**"
+ - ".github/workflows/ci-cua-driver-preflight.yml"
+ # Docs-only edits never start the sandbox job.
+ - "!.github/actions/cua-sandbox/lint-docs-yaml.py"
+ - "!**/*.md"
+ - "!**/*.mdx"
+ push:
+ branches: [main]
paths:
- "scripts/ci/linux/preflight-rust-e2e.sh"
- "scripts/ci/windows/preflight-rust-e2e.ps1"
@@ -12,10 +31,11 @@ on:
- "libs/cua-driver/rust/crates/cua-driver-core/**"
- "libs/cua-driver/rust/crates/platform-linux/**"
- ".github/workflows/ci-cua-driver-preflight.yml"
- # Docs-only edits never start the sandbox job.
- "!.github/actions/cua-sandbox/lint-docs-yaml.py"
- "!**/*.md"
- "!**/*.mdx"
+ schedule:
+ - cron: "17 4 * * *"
workflow_dispatch:
permissions:
@@ -28,6 +48,7 @@ env:
concurrency:
group: ci-cua-driver-preflight-${{ github.ref }}
+ # A main or nightly run always finishes.
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
jobs:
@@ -89,3 +110,24 @@ jobs:
- name: Check host readiness
shell: pwsh
run: .\scripts\ci\windows\preflight-rust-e2e.ps1
+
+ report:
+ name: open or update the issue
+ needs: [linux, windows]
+ if: ${{ failure() && github.event_name != 'pull_request' }}
+ runs-on: ubuntu-latest
+ timeout-minutes: 5
+ permissions:
+ issues: write
+ steps:
+ - uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
+ with:
+ persist-credentials: false
+ sparse-checkout: .github/actions/nightly-issue
+ - uses: ./.github/actions/nightly-issue
+ with:
+ title: "Cua Driver desktop readiness is failing on main"
+ detail: >-
+ The desktop readiness checks (Linux sandbox, Windows host) failed on a main push or the nightly run.
+ Pull requests only run them when the readiness scripts or actions change. This check does not
+ certify a release.
diff --git a/.github/workflows/ci-nix-linux.yml b/.github/workflows/ci-nix-linux.yml
index fb910ce1c3..35efed8018 100644
--- a/.github/workflows/ci-nix-linux.yml
+++ b/.github/workflows/ci-nix-linux.yml
@@ -1,10 +1,15 @@
name: "CI: Nix Linux Rust source"
# Nix owns reproducible Linux package and Rust-source builds. Interactive
-# desktop behavior is owned by the Rust E2E workflows.
+# desktop behavior is owned by the Rust E2E workflows. Pull requests run it
+# when Nix, flake or lockfile paths change; driver source changes run it on
+# main and nightly. A failed main or nightly run opens or updates one issue.
on:
pull_request:
types: [opened, synchronize, reopened, ready_for_review]
+ # Only what decides the Nix build. A change to the driver's Rust sources is
+ # built by the Rust CI on the pull request and by this workflow on main and
+ # nightly (14 minutes, p90 33, on every driver change before).
paths:
- "flake.nix"
- "flake.lock"
@@ -12,17 +17,6 @@ on:
- "libs/cua-driver/rust/.cargo/**"
- "libs/cua-driver/rust/Cargo.toml"
- "libs/cua-driver/rust/Cargo.lock"
- - "libs/cua-driver/rust/crates/cua-driver/**"
- - "libs/cua-driver/rust/crates/cua-driver-core/**"
- - "libs/cua-driver/rust/crates/cua-driver-testkit/**"
- - "libs/cua-driver/rust/crates/cua-driver-e2e/**"
- - "libs/cua-driver/rust/crates/cua-cursor-motion/**"
- - "libs/cua-driver/rust/crates/cursor-overlay/**"
- - "!libs/cua-driver/rust/crates/cursor-overlay/examples/export_gallery_frames.rs"
- - "libs/cua-driver/rust/crates/pip-preview/**"
- - "libs/cua-driver/rust/crates/platform-linux/**"
- - "libs/cua-driver/wayland-helper/**"
- - "libs/cua-driver/tests/fixtures/shared/web/index.html"
- ".github/workflows/ci-nix-linux.yml"
push:
branches: [main]
@@ -45,6 +39,8 @@ on:
- "libs/cua-driver/wayland-helper/**"
- "libs/cua-driver/tests/fixtures/shared/web/index.html"
- ".github/workflows/ci-nix-linux.yml"
+ schedule:
+ - cron: "47 3 * * *"
workflow_dispatch:
permissions:
@@ -119,3 +115,24 @@ jobs:
targets+=(".#checks.x86_64-linux.${attribute}")
done
nix build "${targets[@]}" --no-link --print-build-logs --show-trace
+
+ report:
+ name: open or update the issue
+ needs: rust-source
+ if: ${{ failure() && github.event_name != 'pull_request' }}
+ runs-on: ubuntu-latest
+ timeout-minutes: 5
+ permissions:
+ issues: write
+ steps:
+ - uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
+ with:
+ persist-credentials: false
+ sparse-checkout: .github/actions/nightly-issue
+ - uses: ./.github/actions/nightly-issue
+ with:
+ title: "Nix Linux Rust source build is failing on main"
+ detail: >-
+ A Nix build of the driver, the policy VMs or the compositor failed on a main push or the nightly run.
+ Pull requests only run it when Nix, flake or lockfile paths change, so a driver source change that
+ breaks the Nix build shows up here.
diff --git a/.github/workflows/e2b-bindings.yml b/.github/workflows/e2b-bindings.yml
index 16bc3db2b6..c4557986bb 100644
--- a/.github/workflows/e2b-bindings.yml
+++ b/.github/workflows/e2b-bindings.yml
@@ -1,13 +1,16 @@
-# Swift binding tests on every PR that touches the cua SDK bindings.
+# Swift binding tests (swift/scripts/test.sh, against the release dylib and the
+# loopback test fixtures). 43 minutes (p90 64) and 187 runs a week made this the
+# longest job on the pull requests that touched the SDK, and it is nightly-shaped:
+# it checks that a Swift binding still works against the SDK, not that this
+# change is right.
+#
+# - pull requests: only when the Swift binding itself (libs/cua/swift/**) or
+# this workflow changes. Binding drift (`generate-uniffi-bindings.mjs --check`)
+# and the Kotlin compile still run on every SDK change in ci-cua-sdk.yml.
+# - push to main on every path below, and the nightly schedule: the full list.
+# ci-cua-sdk.yml's `swift` job runs the same suite there too.
+# - a failed main or nightly run opens or updates one issue (`report` job).
#
-# ci-cua-sdk.yml already runs, unconditionally on these paths (libs/cua/**):
-# - `bindings`: `generate-uniffi-bindings.mjs --check` (drift, regenerates
-# Python/Swift/Kotlin/TypeScript and fails when the tree differs), and
-# - `kotlin`: `gradle -p libs/cua/kotlin compileKotlin`.
-# Its `swift` job, however, only runs on release-please PRs, the `ci:full`
-# label, pushes to main and the nightly schedule. This workflow adds the
-# missing piece: the Swift suite (swift/scripts/test.sh, against the release
-# dylib and the loopback test fixtures) on ordinary PRs for the binding paths.
# It uses the same Rust cache family (cua-sdk-swift) as ci-cua-sdk.yml's
# swift job, which main's pushes and the nightly keep warm. (It used to share
# the macOS `libs-cua` family with jobs of other shapes: 4 GB full of
@@ -17,6 +20,11 @@ name: e2b-bindings
on:
pull_request:
types: [opened, synchronize, reopened, ready_for_review]
+ paths:
+ - "libs/cua/swift/**"
+ - ".github/workflows/e2b-bindings.yml"
+ push:
+ branches: [main]
paths:
- "libs/cua/crates/cua-sdk/**"
- "libs/cua/proto/**"
@@ -25,6 +33,8 @@ on:
- "libs/cua/python/src/**"
- "libs/cua/typescript/src/**"
- ".github/workflows/e2b-bindings.yml"
+ schedule:
+ - cron: "37 3 * * *"
workflow_dispatch:
permissions:
@@ -32,6 +42,7 @@ permissions:
concurrency:
group: e2b-bindings-${{ github.ref }}
+ # A main or nightly run always finishes: it saves the cache pull requests restore.
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
env:
@@ -70,3 +81,23 @@ jobs:
scripts/build-test-fixtures.sh
node scripts/stage-uniffi-library.mjs --only=swift
swift/scripts/test.sh
+
+ report:
+ name: open or update the issue
+ needs: swift
+ if: ${{ failure() && github.event_name != 'pull_request' }}
+ runs-on: ubuntu-latest
+ timeout-minutes: 5
+ permissions:
+ issues: write
+ steps:
+ - uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
+ with:
+ persist-credentials: false
+ sparse-checkout: .github/actions/nightly-issue
+ - uses: ./.github/actions/nightly-issue
+ with:
+ title: "e2b-bindings: Swift binding tests are failing on main"
+ detail: >-
+ The Swift binding suite failed on a main push or the nightly run. Pull requests only run it when
+ libs/cua/swift changes, so an SDK or proto change that breaks the Swift binding shows up here.
diff --git a/.github/workflows/workflow-failure-alerts.yml b/.github/workflows/workflow-failure-alerts.yml
index 69fcc8426b..7f7a432448 100644
--- a/.github/workflows/workflow-failure-alerts.yml
+++ b/.github/workflows/workflow-failure-alerts.yml
@@ -21,6 +21,9 @@ on:
workflows:
- "Nightly: Cua Driver"
- "Nightly: Lume"
+ - "e2b-bindings"
+ - "CI: Cua Driver desktop readiness (non-certifying)"
+ - "CI: Nix Linux Rust source"
- "E2E: Cua Driver release gate"
- "CI: Cua Driver installer compatibility"
- "Monitor branded installer endpoints"
@@ -57,6 +60,9 @@ jobs:
WATCH: |
Nightly: Cua Driver=ci
Nightly: Lume=ci
+ e2b-bindings=ci
+ CI: Cua Driver desktop readiness (non-certifying)=ci
+ CI: Nix Linux Rust source=ci
E2E: Cua Driver release gate=release
CI: Cua Driver installer compatibility=release
Monitor branded installer endpoints=release