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(swift): fix cold macOS Swift builds that time out PRs, benchmark off the PR path (#6568)

cua-agents[bot]a1945502b63d
diff --git a/.github/scripts/tests/test_ci_swift_samples_scope.py b/.github/scripts/tests/test_ci_swift_samples_scope.py
index 238e77a24a..bb9826fa18 100644
--- a/.github/scripts/tests/test_ci_swift_samples_scope.py
+++ b/.github/scripts/tests/test_ci_swift_samples_scope.py
@@ -283,11 +283,14 @@ class WorkflowWiringTests(unittest.TestCase):
"""Evaluate the small subset of the expression language the job conditions use."""
expression = re.fullmatch(r"\$\{\{\s*(.*?)\s*\}\}", condition.strip()).group(1)
expression = re.sub(r"startsWith\(([\w.]+), ('[^']*')\)", r"\1.startswith(\2)", expression)
- expression = expression.replace("&&", " and ").replace("||", " or ").replace("!", " not ")
+ # No earlier job failed or was cancelled in these scenarios; skipped needs are fine.
+ expression = expression.replace("!failure()", "True").replace("!cancelled()", "True")
+ expression = expression.replace("!=", "\0")
+ expression = expression.replace("&&", " and ").replace("||", " or ").replace("!", " not ").replace("\0", "!=")
for name, key in (("needs.changes.outputs.run", "run"), ("needs.changes.outputs.typescript", "typescript"),
("github.head_ref", "head_ref"), ("github.event_name", "event_name")):
expression = expression.replace(name, key)
- return eval(expression, {"__builtins__": {}}, context)
+ return eval(expression, {"__builtins__": {}}, {"event_name": "pull_request", **context})
def test_macos_job_waits_for_the_scope_job(self):
for lane in LANES:
@@ -323,7 +326,15 @@ class WorkflowWiringTests(unittest.TestCase):
self.assertEqual(self.load("openkoalabot")["jobs"]["typescript"]["needs"], "changes")
def test_no_other_job_in_the_infinite_canvas_workflow(self):
- self.assertEqual(set(self.load("infinite-canvas")["jobs"]), {"quick", "changes", "swift"})
+ self.assertEqual(set(self.load("infinite-canvas")["jobs"]), {"quick", "changes", "swift", "bench"})
+
+ def test_benchmark_never_runs_on_pull_requests(self):
+ bench = self.load("infinite-canvas")["jobs"]["bench"]
+ self.assertEqual(bench["needs"], "changes")
+ for event in ("pull_request",):
+ self.assertFalse(self.evaluate(bench["if"], run="true", head_ref="feature/x", event_name=event))
+ for event in ("push", "schedule", "workflow_dispatch"):
+ self.assertTrue(self.evaluate(bench["if"], run="true", head_ref="feature/x", event_name=event))
if __name__ == "__main__":
diff --git a/.github/workflows/ci-infinite-canvas-swift.yml b/.github/workflows/ci-infinite-canvas-swift.yml
index 1f0005ae6c..5e2dc5d8a0 100644
--- a/.github/workflows/ci-infinite-canvas-swift.yml
+++ b/.github/workflows/ci-infinite-canvas-swift.yml
@@ -17,7 +17,9 @@ name: "CI: infinite-canvas (Swift)"
# label, every push to main and the nightly schedule reach it. Rust-internal
# changes that leave the binding alone are covered by the full run on every
# push to main and by the nightly schedule. Release-please branches skip the
-# macOS job as they always have.
+# macOS job as they always have. The benchmark is a separate job that
+# never runs on pull requests (it is not a gate: it only records numbers), so it
+# cannot delay or fail one.
on:
pull_request:
@@ -84,10 +86,13 @@ jobs:
swift:
needs: changes
- if: ${{ needs.changes.outputs.run == 'true' && !startsWith(github.head_ref, 'release-please--branches--') }}
+ # The status functions matter: `quick` is skipped on push and schedule, and
+ # without them the implicit success() skips this job too, so main never ran
+ # it or saved the SDK build cache and every pull request built cold (56 minutes).
+ if: ${{ !failure() && !cancelled() && needs.changes.outputs.run == 'true' && !startsWith(github.head_ref, 'release-please--branches--') }}
name: infinite-canvas-swift (swift test)
runs-on: macos-26
- # The cold SDK build alone takes ~25 minutes; 30 cancelled the benchmark step.
+ # A cold SDK build takes 25 to 56 minutes; main's cache makes it a few.
timeout-minutes: 60
steps:
- uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
@@ -112,9 +117,38 @@ jobs:
- name: Cursor theme is the driver's
run: examples/infinite-canvas-swift/scripts/sync-cursor-assets.sh --check
- name: Test the sample
+ timeout-minutes: 20
run: examples/infinite-canvas-swift/scripts/test.sh
- - name: Benchmark (headless hot paths)
+
+ # Not a gate and never on pull requests: records the headless hot-path numbers
+ # on main and nightly, with its own limit. Nothing in ci-gate reads it.
+ bench:
+ needs: changes
+ if: ${{ !failure() && !cancelled() && github.event_name != 'pull_request' && needs.changes.outputs.run == 'true' }}
+ name: infinite-canvas-bench (headless hot paths)
+ runs-on: macos-26
+ timeout-minutes: 60
+ steps:
+ - uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
+ with:
+ persist-credentials: false
+ - name: Install protoc
+ uses: ./.github/actions/setup-protoc
+ - name: Install pinned Rust toolchain
+ uses: dtolnay/[email protected]
+ - uses: ./.github/actions/rust-cache
+ with:
+ workspaces: libs/cua
+ shared-key: libs-cua-sdk-release-macos
+ # The swift job saves this family; do not race it for the same key.
+ save-if: "false"
+ - name: Build and stage the cua SDK for Swift
+ run: |
+ (cd libs/cua && cargo build --locked --release -p cua-sdk)
+ node libs/cua/scripts/stage-uniffi-library.mjs --only=swift
+ - name: Benchmark
working-directory: examples/infinite-canvas-swift
+ timeout-minutes: 15
run: |
swift build -c release --product canvas-bench
.build/release/canvas-bench --tiles 8 --seconds 5 --json canvas-bench.json
diff --git a/.github/workflows/ci-openkoalabot-example-samples.yml b/.github/workflows/ci-openkoalabot-example-samples.yml
index e6e147c99d..60147761db 100644
--- a/.github/workflows/ci-openkoalabot-example-samples.yml
+++ b/.github/workflows/ci-openkoalabot-example-samples.yml
@@ -62,7 +62,7 @@ jobs:
typescript:
needs: changes
- if: ${{ needs.changes.outputs.typescript == 'true' && !startsWith(github.head_ref, 'release-please--branches--') }}
+ if: ${{ !failure() && !cancelled() && needs.changes.outputs.typescript == 'true' && !startsWith(github.head_ref, 'release-please--branches--') }}
name: openkoalabot-example-ts (npm test)
runs-on: ubuntu-24.04
timeout-minutes: 60
@@ -152,7 +152,7 @@ jobs:
swift:
needs: changes
- if: ${{ needs.changes.outputs.run == 'true' && !startsWith(github.head_ref, 'release-please--branches--') }}
+ if: ${{ !failure() && !cancelled() && needs.changes.outputs.run == 'true' && !startsWith(github.head_ref, 'release-please--branches--') }}
name: openkoalabot-example-swift (swift test)
runs-on: macos-26
timeout-minutes: 30