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: macOS clippy on every cua PR; larger-runner guard works without system PyYAML (#6541)

Francesco Bonacci044f52826523
diff --git a/.github/scripts/check_no_larger_runners.py b/.github/scripts/check_no_larger_runners.py
index 435cb96201..8ed3f421cb 100644
--- a/.github/scripts/check_no_larger_runners.py
+++ b/.github/scripts/check_no_larger_runners.py
@@ -21,10 +21,19 @@ Usage: check_no_larger_runners.py [--list] [repo_root]
from __future__ import annotations
import re
+import shutil
import sys
from pathlib import Path
-import yaml
+try:
+ import yaml
+except ImportError: # e.g. a host whose system Python has no PyYAML (g17-4)
+ import os
+
+ if os.environ.get("CUA_LARGER_RUNNERS_REEXEC") or not shutil.which("uv"):
+ sys.exit("check_no_larger_runners.py needs PyYAML: pip install pyyaml (or install uv)")
+ os.environ["CUA_LARGER_RUNNERS_REEXEC"] = "1"
+ os.execvp("uv", ["uv", "run", "--quiet", "--with", "pyyaml", "python", *sys.argv])
LARGER = re.compile(r"(?:^|-)(?:x{0,2}large)$|\d+-?cores?(?:$|-)", re.IGNORECASE)
LITERAL = re.compile(r"'([^']*)'|\"([^\"]*)\"")
diff --git a/.github/scripts/tests/test_check_no_larger_runners.py b/.github/scripts/tests/test_check_no_larger_runners.py
index 9df732e5b6..7a54fcfc4d 100644
--- a/.github/scripts/tests/test_check_no_larger_runners.py
+++ b/.github/scripts/tests/test_check_no_larger_runners.py
@@ -80,6 +80,18 @@ class LargerRunnerCheck(unittest.TestCase):
self.assertEqual(chk.find_uses(REPO), [])
self.assertEqual(chk.load_allowed(REPO), set())
+ def test_missing_pyyaml_gives_a_clear_error_not_a_traceback(self):
+ import os
+ import subprocess
+
+ block = Path(tempfile.mkdtemp())
+ (block / "yaml.py").write_text("raise ImportError('blocked')\n")
+ env = {"PYTHONPATH": str(block), "CUA_LARGER_RUNNERS_REEXEC": "1", "PATH": os.environ.get("PATH", "")}
+ done = subprocess.run([sys.executable, str(Path(chk.__file__))], env=env, capture_output=True, text=True)
+ self.assertEqual(done.returncode, 1)
+ self.assertIn("needs PyYAML", done.stderr)
+ self.assertNotIn("Traceback", done.stderr)
+
if __name__ == "__main__":
unittest.main()
diff --git a/.github/scripts/tests/test_ci_reuse_pr_result.py b/.github/scripts/tests/test_ci_reuse_pr_result.py
index 66b61eba9a..23d861bcf2 100644
--- a/.github/scripts/tests/test_ci_reuse_pr_result.py
+++ b/.github/scripts/tests/test_ci_reuse_pr_result.py
@@ -382,7 +382,7 @@ def test_cua_sdk_subset_names_are_real_jobs_with_the_pull_request_legs():
assert len(names) == len(set(names))
assert '--stamp-job "reuse PR results"' in command
assert wf["jobs"]["reuse"]["name"] == "reuse PR results"
- assert set(names) <= job_names(wf, expand_os=("ubuntu-latest", "windows-latest"))
+ assert set(names) <= job_names(wf, expand_os=("ubuntu-latest", "macos-26", "windows-latest"))
def literals(expr):
@@ -391,7 +391,7 @@ def literals(expr):
MATRIX_JOBS = {
# job id: legs a pull request runs and which of them are in the reused subset
- "rust-lint": ["ubuntu-latest", "windows-latest"],
+ "rust-lint": ["ubuntu-latest", "macos-26", "windows-latest"],
"spaces-e2e": ["ubuntu-latest"],
"bindings": ["ubuntu-latest"],
"python": ["ubuntu-latest"],
@@ -406,7 +406,12 @@ def test_cua_sdk_matrix_on_main_is_the_full_matrix_minus_the_pull_request_legs(j
assert "reuse" in (job["needs"] if isinstance(job["needs"], list) else [job["needs"]])
main_only, full, pr = literals(job["strategy"]["matrix"]["os"])
assert pr == MATRIX_JOBS[job_id]
- assert main_only == [leg for leg in full if leg not in pr]
+ expected_main_only = [leg for leg in full if leg not in pr]
+ if job_id == "rust-lint":
+ # Pull requests now run every lint leg, so nothing is left for main; a matrix
+ # cannot be empty, so main keeps the macOS leg as its backstop.
+ expected_main_only = ["macos-26"]
+ assert main_only == expected_main_only
# Every dropped leg is one the subset covers, and none is dropped when it is not.
subset = re.search(r'--subset "pr_subset=([^"]+)"', reuse_run_command(wf)).group(1).split("|")
prefix = job["name"].split("(")[0].replace("${{ matrix.os }}", "").strip()
diff --git a/.github/workflows/ci-cua-sdk.yml b/.github/workflows/ci-cua-sdk.yml
index e45fafa2b6..8b154fb925 100644
--- a/.github/workflows/ci-cua-sdk.yml
+++ b/.github/workflows/ci-cua-sdk.yml
@@ -109,20 +109,21 @@ jobs:
python3 .github/scripts/ci_reuse_pr_result.py run \
--stamp-job "reuse PR results" \
--float node-22 --float uv --float python-standalone \
- --subset "pr_subset=rust (ubuntu-latest)|rust lint (ubuntu-latest)|rust lint (windows-latest)|crates.io dry run|spaces e2e (ubuntu-latest)|bindings drift (ubuntu-latest)|kotlin compile|build SDK (linux, release)|build test fixtures (linux)|build cua and cua-spaces CLIs (linux)|python smoke (ubuntu-latest)|node smoke (ubuntu-latest)|browser (wasm32) build + smoke"
+ --subset "pr_subset=rust (ubuntu-latest)|rust lint (ubuntu-latest)|rust lint (macos-26)|rust lint (windows-latest)|crates.io dry run|spaces e2e (ubuntu-latest)|bindings drift (ubuntu-latest)|kotlin compile|build SDK (linux, release)|build test fixtures (linux)|build cua and cua-spaces CLIs (linux)|python smoke (ubuntu-latest)|node smoke (ubuntu-latest)|browser (wasm32) build + smoke"
rust-lint:
if: ${{ !cancelled() && (github.event_name != 'pull_request' || !github.event.pull_request.draft) && !startsWith(github.head_ref, 'release-please--branches--') }}
name: rust lint (${{ matrix.os }})
runs-on: ${{ matrix.os }}
needs: reuse
- # Windows clippy runs on every pull request: Windows-only compile errors
- # used to surface only on release PRs.
+ # Windows and macOS clippy run on every pull request: platform-only compile
+ # errors (cfg gaps) used to surface only on release PRs or after merging to
+ # main. Standard runners are free here; this job is lint only, no tests.
timeout-minutes: 60
strategy:
fail-fast: false
matrix:
- os: ${{ fromJSON((github.event_name != 'pull_request' || contains(github.event.pull_request.labels.*.name, 'ci:full')) && (needs.reuse.outputs.pr_subset == 'true' && '["macos-26"]' || '["ubuntu-latest","macos-26","windows-latest"]') || '["ubuntu-latest","windows-latest"]') }}
+ os: ${{ fromJSON((github.event_name != 'pull_request' || contains(github.event.pull_request.labels.*.name, 'ci:full')) && (needs.reuse.outputs.pr_subset == 'true' && '["macos-26"]' || '["ubuntu-latest","macos-26","windows-latest"]') || '["ubuntu-latest","macos-26","windows-latest"]') }}
defaults:
run:
working-directory: libs/cua