Scale computer-use 2.0 with open-source drivers, cross-OS sandboxes, and benchmarks for training, evaluation, and data generation.
Rust agentai-agentapplecomputer-usecomputer-use-agentcontainerizationcuadesktop-automationhacktoberfestlumemacosmanusoperatorswiftvirtualizationvirtualization-frameworkwindowswindows-sandbox
ci(cua-driver): nightly + PR release-gate E2E lanes with retry-once (CUA-1569) (#5135)
Francesco Bonacci8ccf531fb54b
diff --git a/.github/scripts/cua_driver_e2e_gate_paths.py b/.github/scripts/cua_driver_e2e_gate_paths.pynew file mode 100644index 0000000000..5722576dfd--- /dev/null+++ b/.github/scripts/cua_driver_e2e_gate_paths.py@@ -0,0 +1,45 @@+"""Decide whether changed paths need the Cua Driver release-gate E2E lanes.++Reads one repo-relative path per line on stdin and prints the matching paths.+Exit status is always 0; an empty output means the change is not gated by path.+The globs cover the code that past release gates broke on: the cursor overlay,+focus handling, background input, and browser routing, plus the gate harness.+"""++import re+import sys++RUST = "libs/cua-driver/rust/"+GATED_PATTERNS = (+ # Whole crates dedicated to the cursor/overlay.+ RUST + r"crates/(cursor-overlay|cua-cursor-motion|cursor-theme-cli)/",+ # Cursor overlay, focus handling, background input, browser routing in any+ # driver crate, by directory or by file name.+ RUST + r"crates/[^/]+/src/(.*/)?(cursor|overlay|focus|background|browser|input|pointer)[^/]*",+ RUST + r"crates/[^/]+/src/(.*/)?[^/]*(cursor|overlay|focus|background_|browser|pointer_shape|key_focus)[^/]*",+ RUST + r"crates/cua-driver-core/src/(browser|background_input|agent_cursor)",+ RUST + r"crates/cua-driver-contract/src/cursor",+ # The behavior harness the lanes execute.+ RUST + r"crates/cua-driver-(e2e|testkit)/",+ RUST + r"test-apps/",+ r"libs/cua-driver/tests/fixtures/",+ # The gate itself.+ r"scripts/ci/(lib/|linux/run-|macos/run-|windows/run-|run-rust-standalone)",+ r"\.github/workflows/(e2e-rust-(linux|windows|macos|standalone-browsers)|e2e-cua-driver-release-gate)\.yml",+)+_COMPILED = [re.compile(p) for p in GATED_PATTERNS]+++def gated(path: str) -> bool:+ return any(rx.match(path) for rx in _COMPILED)+++def main() -> None:+ for line in sys.stdin:+ path = line.strip()+ if path and gated(path):+ print(path)+++if __name__ == "__main__":+ main()diff --git a/.github/scripts/tests/test_cua_driver_e2e_gate_paths.py b/.github/scripts/tests/test_cua_driver_e2e_gate_paths.pynew file mode 100644index 0000000000..70be135375--- /dev/null+++ b/.github/scripts/tests/test_cua_driver_e2e_gate_paths.py@@ -0,0 +1,56 @@+"""Path globs that put a pull request behind the release-gate E2E lanes."""++import importlib.util+from pathlib import Path++import pytest++MODULE_PATH = Path(__file__).resolve().parents[1] / "cua_driver_e2e_gate_paths.py"+SPEC = importlib.util.spec_from_file_location("cua_driver_e2e_gate_paths", MODULE_PATH)+assert SPEC is not None and SPEC.loader is not None+paths = importlib.util.module_from_spec(SPEC)+SPEC.loader.exec_module(paths)++R = "libs/cua-driver/rust/crates/"+++ "path",+ [+ R + "cursor-overlay/src/lib.rs",+ R + "cua-cursor-motion/src/lib.rs",+ R + "platform-macos/src/cursor/mod.rs",+ R + "platform-macos/src/focus_guard.rs",+ R + "platform-macos/src/focus_steal.rs",+ R + "platform-macos/src/background_mutation.rs",+ R + "platform-macos/src/browser/mod.rs",+ R + "platform-macos/src/input/click.rs",+ R + "platform-windows/src/overlay.rs",+ R + "platform-windows/src/browser_platform.rs",+ R + "platform-linux/src/overlay_capture.rs",+ R + "cua-driver-core/src/background_input.rs",+ R + "cua-driver-core/src/agent_cursor.rs",+ R + "cua-driver-core/src/browser/routes.rs",+ R + "cua-driver-e2e/tests/standalone_browser_behavior_test.rs",+ "scripts/ci/macos/run-rust-e2e.sh",+ "scripts/ci/lib/e2e-retry-once.sh",+ ".github/workflows/e2e-rust-linux.yml",+ ],+)+def test_gated(path: str) -> None:+ assert paths.gated(path)+++ "path",+ [+ "docs/guide.md",+ "libs/cua-driver/docs/test-harnesses-guide.md",+ R + "cua-perception/src/lib.rs",+ R + "cua-driver/src/updater.rs",+ R + "platform-macos/src/history.rs",+ "libs/lume/Package.swift",+ ],+)+def test_not_gated(path: str) -> None:+ assert not paths.gated(path)diff --git a/.github/scripts/tests/test_cua_perception_pr_review_trigger.py b/.github/scripts/tests/test_cua_perception_pr_review_trigger.pyindex 7390cec38e..1142e6a7c2 100644--- a/.github/scripts/tests/test_cua_perception_pr_review_trigger.py+++ b/.github/scripts/tests/test_cua_perception_pr_review_trigger.py@@ -180,7 +180,7 @@ def test_macos_direct_lume_registration_is_manual_and_not_pr_event_chained() ->for path in (ROOT / ".github/workflows").glob("*.yml")if "uses: ./.github/workflows/e2e-rust-macos.yml" in path.read_text(encoding="utf-8"))- assert callers == ["cd-rust-cua-driver.yml"]+ assert callers == ["cd-rust-cua-driver.yml", "e2e-cua-driver-release-gate.yml"]assert "pull_request:" not in entry_text and "pull_request_target" not in entry_textassert "live-jev-perception" not in entry_workflow["jobs"]assert "authorized-live-jev-macos-evidence.yml" not in entry_textdiff --git a/.github/scripts/tests/test_e2e_rust_windows_workflow.py b/.github/scripts/tests/test_e2e_rust_windows_workflow.pyindex 78018e73f7..de94b6147a 100644--- a/.github/scripts/tests/test_e2e_rust_windows_workflow.py+++ b/.github/scripts/tests/test_e2e_rust_windows_workflow.py@@ -88,6 +88,7 @@ def test_matrix_summary_recovers_results_when_lane_summary_is_missing(tmp_path:"SOURCE_SHA": "0123456789abcdef0123456789abcdef01234567",})+ (tmp_path / "scripts").symlink_to(ROOT / "scripts")subprocess.run(["bash", "-euo", "pipefail", "-c", matrix_summary_script()],cwd=tmp_path,diff --git a/.github/scripts/tests/test_macos_hosted_e2e_workflow.py b/.github/scripts/tests/test_macos_hosted_e2e_workflow.pyindex b21f8cea4c..a9ecfaa85e 100644--- a/.github/scripts/tests/test_macos_hosted_e2e_workflow.py+++ b/.github/scripts/tests/test_macos_hosted_e2e_workflow.py@@ -52,14 +52,15 @@ PROBE_REFUSALS = [({"GITHUB_ACTIONS": ""}, "GITHUB_ACTIONS must be true"),({"RUNNER_ENVIRONMENT": "self-hosted"}, "runner must be GitHub-hosted"),({"CI": ""}, "CI must be true"),- ({"GITHUB_EVENT_NAME": "pull_request"}, "probe must be manually dispatched or run by a stable cua-driver-rs tag release gate"),+ ({"GITHUB_EVENT_NAME": "schedule", "GITHUB_REF": "refs/heads/feature"}, "probe must be manually dispatched, run by a stable cua-driver-rs tag release gate, or run by the nightly schedule on main"),+ ({"GITHUB_EVENT_NAME": "pull_request"}, "probe must be manually dispatched, run by a stable cua-driver-rs tag release gate, or run by the nightly schedule on main"),({"GITHUB_EVENT_NAME": "push", "GITHUB_REF": "refs/heads/main"},- "probe must be manually dispatched or run by a stable cua-driver-rs tag release gate",+ "probe must be manually dispatched, run by a stable cua-driver-rs tag release gate, or run by the nightly schedule on main",),({"GITHUB_EVENT_NAME": "push", "GITHUB_REF": "refs/tags/lume-v0.3.0"},- "probe must be manually dispatched or run by a stable cua-driver-rs tag release gate",+ "probe must be manually dispatched, run by a stable cua-driver-rs tag release gate, or run by the nightly schedule on main",),({"CUA_E2E_SOURCE_SHA": "main"}, "source SHA must contain 40 hexadecimal characters"),(@@ -104,8 +105,9 @@ def test_hosted_macos_probe_refuses_outside_a_dispatched_hosted_run([{"GITHUB_EVENT_NAME": "workflow_dispatch"},{"GITHUB_EVENT_NAME": "push", "GITHUB_REF": "refs/tags/cua-driver-rs-v0.29.0"},+ {"GITHUB_EVENT_NAME": "schedule", "GITHUB_REF": "refs/heads/main"},],- ids=["workflow_dispatch", "stable-tag-push"],+ ids=["workflow_dispatch", "stable-tag-push", "nightly-schedule-on-main"],)def test_hosted_macos_probe_identity_gates_pass_for_a_dispatched_hosted_run(tmp_path: Path, event: dict[str, str]@@ -120,14 +122,15 @@ def test_hosted_macos_probe_identity_gates_pass_for_a_dispatched_hosted_run(HOSTED_RUNNER_REFUSALS = [({"GITHUB_ACTIONS": ""}, "requires GitHub Actions"),- ({"GITHUB_EVENT_NAME": "pull_request"}, "runs only from workflow_dispatch or a stable cua-driver-rs tag release gate"),+ ({"GITHUB_EVENT_NAME": "schedule", "GITHUB_REF": "refs/heads/feature"}, "runs only from workflow_dispatch, a stable cua-driver-rs tag release gate, or the nightly schedule on main"),+ ({"GITHUB_EVENT_NAME": "pull_request"}, "runs only from workflow_dispatch, a stable cua-driver-rs tag release gate, or the nightly schedule on main"),({"GITHUB_EVENT_NAME": "push", "GITHUB_REF": "refs/heads/main"},- "runs only from workflow_dispatch or a stable cua-driver-rs tag release gate",+ "runs only from workflow_dispatch, a stable cua-driver-rs tag release gate, or the nightly schedule on main",),({"GITHUB_EVENT_NAME": "push", "GITHUB_REF": "refs/tags/lume-v0.3.0"},- "runs only from workflow_dispatch or a stable cua-driver-rs tag release gate",+ "runs only from workflow_dispatch, a stable cua-driver-rs tag release gate, or the nightly schedule on main",),({"RUNNER_ENVIRONMENT": "self-hosted"}, "requires a GitHub-hosted runner"),({"RUNNER_OS": "Linux"}, "requires RUNNER_OS=macOS"),diff --git a/.github/workflows/e2e-cua-driver-release-gate.yml b/.github/workflows/e2e-cua-driver-release-gate.ymlnew file mode 100644index 0000000000..51015f0b34--- /dev/null+++ b/.github/workflows/e2e-cua-driver-release-gate.yml@@ -0,0 +1,236 @@+name: "E2E: Cua Driver release gate"++# Runs the same desktop E2E lanes the stable tag gate runs (Linux, Windows,+# macOS hosted native, standalone browsers) WITHOUT publishing anything, so a+# gate failure surfaces before a release tags instead of after.+#+# nightly 06:00 UTC against main's HEAD. Failures (and flaky cases) open or+# update ONE tracking issue; the failed run also reaches #releases+# through the GitHub Slack app workflow-run subscription.+# PR runs when the `e2e-gate` label is present, when the PR touches the+# gated paths (.github/scripts/cua_driver_e2e_gate_paths.py: cursor+# overlay, focus, background input, browser routing, the harness),+# or when it is the release-please PR for cua-driver-rs.+# Otherwise the lanes are skipped and `E2E gate / result` passes at once, so+# that one check can be required on every PR (see scripts/ci/README.md).+#+# Each lane retries a failed case once (scripts/ci/lib/e2e-retry-once.sh): a+# pass on the retry is reported as flaky and does not fail the gate; two+# failures do.++on:+ schedule:+ - cron: "0 6 * * *"+ pull_request:+ types: [opened, reopened, synchronize, ready_for_review, labeled, unlabeled]+ workflow_dispatch:++permissions:+ contents: read+ actions: read+ pull-requests: read++# One run per PR (a new push supersedes the old one); nightly and manual runs+# never cancel each other. A label event for an unrelated label gets its own+# group so it cannot cancel a running gate and then skip.+concurrency:+ group: >-+ e2e-gate-${{ github.event_name }}-${{ github.event.pull_request.number || github.ref }}-${{+ (github.event.action == 'labeled' || github.event.action == 'unlabeled') && github.event.label.name != 'e2e-gate' && github.run_id || 'main' }}+ cancel-in-progress: ${{ github.event_name == 'pull_request' }}++jobs:+ decide:+ name: "E2E gate / decide"+ runs-on: ubuntu-latest+ timeout-minutes: 10+ outputs:+ run: ${{ steps.decide.outputs.run }}+ mode: ${{ steps.decide.outputs.mode }}+ reason: ${{ steps.decide.outputs.reason }}+ steps:+ - uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4+ with:+ # The decision script comes from the base branch; never run PR code here.+ ref: ${{ github.event.repository.default_branch }}+ sparse-checkout: .github/scripts+ - id: decide+ name: Decide whether the gate lanes apply+ env:+ GH_TOKEN: ${{ github.token }}+ EVENT: ${{ github.event_name }}+ PR_NUMBER: ${{ github.event.pull_request.number }}+ PR_DRAFT: ${{ github.event.pull_request.draft }}+ PR_HEAD_REPO: ${{ github.event.pull_request.head.repo.full_name }}+ PR_HEAD_REF: ${{ github.event.pull_request.head.ref }}+ PR_LABELS: ${{ toJSON(github.event.pull_request.labels.*.name) }}+ REPO: ${{ github.repository }}+ run: |+ set -euo pipefail+ emit() {+ { echo "run=$1"; echo "mode=$2"; echo "reason=$3"; } >> "$GITHUB_OUTPUT"+ echo "gate: run=$1 mode=$2 ($3)"+ }+ if [[ "$EVENT" != pull_request ]]; then+ emit true "$([[ $EVENT == schedule ]] && echo nightly || echo manual)" "$EVENT on ${GITHUB_REF_NAME}"+ exit 0+ fi+ if jq -e 'index("e2e-gate")' <<< "$PR_LABELS" >/dev/null; then+ emit true pr "label e2e-gate"; exit 0+ fi+ if [[ "$PR_DRAFT" == true ]]; then+ emit false pr "draft PR without the e2e-gate label"; exit 0+ fi+ files=$(gh api --paginate "repos/$REPO/pulls/$PR_NUMBER/files?per_page=100" --jq '.[].filename')+ if [[ "$PR_HEAD_REPO" == "$REPO" && "$PR_HEAD_REF" == release-please--branches--* ]] \+ && grep -qx 'libs/cua-driver/rust/VERSION' <<< "$files"; then+ emit true release-pr "release-please PR for cua-driver-rs"; exit 0+ fi+ if [[ ! -f .github/scripts/cua_driver_e2e_gate_paths.py ]]; then+ # Bootstrap: the base branch does not carry the path script until+ # this workflow merges. Label, schedule and release PRs still gate.+ emit false pr "path script not on the default branch yet"; exit 0+ fi+ matched=$(python3 .github/scripts/cua_driver_e2e_gate_paths.py <<< "$files" | head -n 5)+ if [[ -n "$matched" ]]; then+ emit true pr "gated paths, e.g. $(head -n 1 <<< "$matched")"; exit 0+ fi+ emit false pr "no gated paths and no e2e-gate label"++ linux:+ name: "gate / Linux E2E"+ needs: decide+ if: needs.decide.outputs.run == 'true'+ permissions:+ actions: read+ contents: read+ uses: ./.github/workflows/e2e-rust-linux.yml+ with:+ ref: ${{ github.sha }}++ windows:+ name: "gate / Windows E2E"+ needs: decide+ if: needs.decide.outputs.run == 'true'+ permissions:+ actions: read+ contents: read+ uses: ./.github/workflows/e2e-rust-windows.yml+ with:+ ref: ${{ github.sha }}++ # Hosted macOS seeds TCC state, so it never runs on pull_request events+ # (the probe rejects them). PRs get it from the nightly and the tag gate.+ macos:+ name: "gate / macOS hosted E2E"+ needs: decide+ if: needs.decide.outputs.run == 'true' && github.event_name != 'pull_request'+ permissions:+ actions: read+ contents: read+ pull-requests: read+ uses: ./.github/workflows/e2e-rust-macos.yml+ with:+ source_sha: ${{ github.sha }}++ browsers:+ name: "gate / standalone browser E2E"+ needs: decide+ if: needs.decide.outputs.run == 'true'+ permissions:+ actions: read+ contents: read+ uses: ./.github/workflows/e2e-rust-standalone-browsers.yml+ with:+ ref: ${{ github.sha }}++ # The single check to require in branch protection. Skipped lanes pass+ # (path-based requirement); gated PRs need every lane green.+ result:+ name: "E2E gate / result"+ if: always()+ needs: [decide, linux, windows, macos, browsers]+ runs-on: ubuntu-latest+ timeout-minutes: 5+ steps:+ - name: Evaluate lanes+ env:+ RUN: ${{ needs.decide.outputs.run }}+ EVENT: ${{ github.event_name }}+ DECIDE: ${{ needs.decide.result }}+ LANES: ${{ toJSON(needs) }}+ run: |+ set -euo pipefail+ if [[ "$DECIDE" != success ]]; then+ echo "::error::gate decision job ${DECIDE}"; exit 1+ fi+ if [[ "$RUN" != true ]]; then+ echo "Release-gate lanes not required for this change." | tee -a "$GITHUB_STEP_SUMMARY"+ exit 0+ fi+ bad=$(jq -r 'to_entries[] | select(.key != "decide") | select(.value.result != "success") | select(.key != "macos" or .value.result != "skipped" or env.EVENT != "pull_request") | "\(.key)=\(.value.result)"' <<< "$LANES")+ if [[ -n "$bad" ]]; then+ echo "::error::release-gate lanes not green: $bad"; exit 1+ fi+ echo "All release-gate lanes passed." | tee -a "$GITHUB_STEP_SUMMARY"++ # Nightly only: keep ONE tracking issue up to date (same pattern as+ # release-pipeline-guard.yml). Fails when the gate failed so the run is red+ # in #releases via the GitHub Slack app subscription.+ nightly-report:+ name: "E2E gate / nightly report"+ if: always() && needs.decide.outputs.mode == 'nightly'+ needs: [decide, linux, windows, macos, browsers]+ runs-on: ubuntu-latest+ timeout-minutes: 10+ permissions:+ contents: read+ actions: read+ issues: write+ steps:+ - uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4+ with:+ sparse-checkout: scripts/ci+ - name: Download lane evidence (flaky records)+ uses: actions/download-artifact@fa0a91b85d4f404e444e00e005971372dc801d16 # v4+ with:+ pattern: rust-*+ path: lane-evidence+ continue-on-error: true+ - name: Open, update or close the tracking issue+ env:+ GH_TOKEN: ${{ github.token }}+ REPO: ${{ github.repository }}+ LANES: ${{ toJSON(needs) }}+ RUN_URL: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}+ SHA: ${{ github.sha }}+ run: |+ set -euo pipefail+ TITLE="Cua Driver release gate failing on main (nightly)"+ mkdir -p lane-evidence+ failed=$(jq -r 'to_entries[] | select(.key != "decide") | select(.value.result != "success") | "- `\(.key)`: \(.value.result)"' <<< "$LANES")+ flaky=$(scripts/ci/summarize-flaky-cases.sh lane-evidence)+ existing=$(gh issue list -R "$REPO" --state open --search "\"$TITLE\" in:title" --json number,title \+ --jq "[.[]|select(.title==\"$TITLE\")][0].number // empty")+ if [[ -z "$failed" && -z "$flaky" ]]; then+ echo "Release gate green." | tee -a "$GITHUB_STEP_SUMMARY"+ [[ -z "$existing" ]] || gh issue close "$existing" -R "$REPO" -c "Nightly release gate is green on ${SHA:0:12} ($RUN_URL)."+ exit 0+ fi+ if [[ -n "$failed" ]]; then status="FAILING"; else status="passing, with flaky cases"; fi+ body="Nightly Cua Driver release gate on main @ \`${SHA:0:12}\` is **${status}** ($(date -u +%FT%TZ), [run]($RUN_URL))."$'\n\n'+ if [[ -n "$failed" ]]; then+ body+="### Failed lanes"$'\n\n'"$failed"$'\n\n'"A case counts as failed only after a retry also failed. Fix main before the next release tags; the tag gate runs these same lanes."$'\n\n'+ fi+ [[ -z "$flaky" ]] || body+="$flaky"$'\n\n'+ body+="This issue is updated by \`.github/workflows/e2e-cua-driver-release-gate.yml\` and closes itself on the first fully clean nightly."+ printf '%s\n' "$body" >> "$GITHUB_STEP_SUMMARY"+ if [[ -n "$existing" ]]; then+ gh issue edit "$existing" -R "$REPO" --body "$body"+ else+ gh issue create -R "$REPO" --title "$TITLE" --body "$body"+ fi+ if [[ -n "$failed" ]]; then+ echo "::error::Nightly release gate failed"+ exit 1+ fidiff --git a/.github/workflows/e2e-rust-linux.yml b/.github/workflows/e2e-rust-linux.ymlindex 5803650688..aa1a1274da 100644--- a/.github/workflows/e2e-rust-linux.yml+++ b/.github/workflows/e2e-rust-linux.yml@@ -49,6 +49,9 @@ env:CARGO_NET_RETRY: "10"CARGO_HTTP_TIMEOUT: "120"CARGO_HTTP_MULTIPLEXING: "false"+ # Failed cases are rerun once inside the gate; a pass on the rerun is+ # reported as flaky, two failures fail. See scripts/ci/lib/e2e-retry-once.sh.+ CUA_E2E_RETRY_ONCE: "1"# Cua programs and packages run here never send usage telemetry.CUA_TELEMETRY: "0"DO_NOT_TRACK: "1"@@ -376,6 +379,7 @@ jobs:{echoecho "Each evidence link opens its owning lane artifact; the row text is the exact \`recordings/<cell-label>-pid<pid>-<sequence>/recording.mp4\` path, with an adjacent \`trajectory.json\`."+ scripts/ci/summarize-flaky-cases.sh artifacts} >> "$summary_path"cat "$summary_path" >> "$GITHUB_STEP_SUMMARY"- name: Upload matrix summarydiff --git a/.github/workflows/e2e-rust-macos.yml b/.github/workflows/e2e-rust-macos.ymlindex c0abe27e75..a72ff3c2f3 100644--- a/.github/workflows/e2e-rust-macos.yml+++ b/.github/workflows/e2e-rust-macos.yml@@ -51,6 +51,9 @@ concurrency:cancel-in-progress: falseenv:+ # Failed cases are rerun once inside the gate; a pass on the rerun is+ # reported as flaky, two failures fail. See scripts/ci/lib/e2e-retry-once.sh.+ CUA_E2E_RETRY_ONCE: "1"# Cua programs and packages run here never send usage telemetry.CUA_TELEMETRY: "0"DO_NOT_TRACK: "1"@@ -206,6 +209,11 @@ jobs:shell: bashrun: scripts/ci/macos/run-hosted-rust-e2e.sh+ - name: Report flaky cases+ if: always()+ shell: bash+ run: scripts/ci/summarize-flaky-cases.sh artifacts/cua-driver >> "$GITHUB_STEP_SUMMARY"+- name: Upload hosted macOS lane evidenceif: always()uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # v4.6.2diff --git a/.github/workflows/e2e-rust-standalone-browsers.yml b/.github/workflows/e2e-rust-standalone-browsers.ymlindex edc70acda9..3749b5ee2f 100644--- a/.github/workflows/e2e-rust-standalone-browsers.yml+++ b/.github/workflows/e2e-rust-standalone-browsers.yml@@ -23,6 +23,9 @@ env:CARGO_NET_RETRY: "10"CARGO_HTTP_TIMEOUT: "120"CARGO_HTTP_MULTIPLEXING: "false"+ # Failed cases are rerun once inside the gate; a pass on the rerun is+ # reported as flaky, two failures fail. See scripts/ci/lib/e2e-retry-once.sh.+ CUA_E2E_RETRY_ONCE: "1"# Cua programs and packages run here never send usage telemetry.CUA_TELEMETRY: "0"DO_NOT_TRACK: "1"@@ -179,6 +182,7 @@ jobs:elseecho "Standalone browser summary was not produced." >> "$GITHUB_STEP_SUMMARY"fi+ scripts/ci/summarize-flaky-cases.sh artifacts/cua-driver/standalone-browser >> "$GITHUB_STEP_SUMMARY"- name: Upload browser evidenceif: always()uses: actions/upload-artifact@65c4c4a1ddee5b72f698fdd19549f0f0fb45cf08 # v4diff --git a/.github/workflows/e2e-rust-windows.yml b/.github/workflows/e2e-rust-windows.ymlindex df0a5bfcd9..1412eae319 100644--- a/.github/workflows/e2e-rust-windows.yml+++ b/.github/workflows/e2e-rust-windows.yml@@ -49,6 +49,9 @@ env:CARGO_NET_RETRY: "10"CARGO_HTTP_TIMEOUT: "120"CARGO_HTTP_MULTIPLEXING: "false"+ # Failed cases are rerun once inside the gate; a pass on the rerun is+ # reported as flaky, two failures fail. See scripts/ci/lib/e2e-retry-once.sh.+ CUA_E2E_RETRY_ONCE: "1"# Cua programs and packages run here never send usage telemetry.CUA_TELEMETRY: "0"DO_NOT_TRACK: "1"@@ -411,9 +414,11 @@ jobs:artifact_link="Artifact link unavailable"fi- echo "## $artifact" >> "$summary_path"- echo >> "$summary_path"- echo "The lane did not produce \`summary.md\`. Results recovered from \`results.jsonl\`: $artifact_link." >> "$summary_path"+ {+ echo "## $artifact"+ echo+ echo "The lane did not produce \`summary.md\`. Results recovered from \`results.jsonl\`: $artifact_link."+ } >> "$summary_path"echo >> "$summary_path"result_count=$(jq -s 'length' "$results")pass_count=$(jq -s '[.[] | select(.test_status == "pass")] | length' "$results")@@ -483,6 +488,7 @@ jobs:{echoecho "Each evidence link opens its owning lane artifact; the row text is the exact \`recordings/<cell-label>-pid<pid>-<sequence>/recording.mp4\` path, with an adjacent \`trajectory.json\`."+ scripts/ci/summarize-flaky-cases.sh artifacts} >> "$summary_path"cat "$summary_path" >> "$GITHUB_STEP_SUMMARY"- name: Upload matrix summarydiff --git a/scripts/ci/README.md b/scripts/ci/README.mdindex 12d72b3152..862efc9822 100644--- a/scripts/ci/README.md+++ b/scripts/ci/README.md@@ -413,3 +413,17 @@ Use this runbook when the canary issue opens, or when users report that default- Run `python3 .github/scripts/validate_release_versions.py --product driver` and `python3 -m pytest libs/cua-driver/scripts/tests/test_install_version_fallback.py`.4. **Merge it.** The branded endpoints serve `main`. The canary runs on the push, so compare its installed version with the rollback version. To recheck the public one-liners after the endpoints refresh, dispatch `Monitor branded installer endpoints`.5. **Ship the fix as a new Release Please release.** Its tag run bakes the installers forward automatically once the published assets pass verification. Leave the withdrawn release and its assets in place for audit.++## Cua Driver release gate before merge and nightly++The stable tag run certifies the exact tag commit with the desktop E2E lanes. `E2E: Cua Driver release gate` (`.github/workflows/e2e-cua-driver-release-gate.yml`) runs the same lanes earlier, without publishing:++| Trigger | When | Result |+| --- | --- | --- |+| Nightly, 06:00 UTC | main's HEAD | A failure opens or updates one issue, "Cua Driver release gate failing on main (nightly)". The failed run also posts to #releases through the GitHub Slack app workflow-run subscription. The first fully clean nightly closes the issue. |+| Pull request | The `e2e-gate` label is present, or the PR touches the cursor overlay, focus, background input or browser routing paths (globs in `.github/scripts/cua_driver_e2e_gate_paths.py`), or it is the release-please PR for cua-driver-rs | The four lanes run on the PR merge commit. |+| Other pull requests | Everything else | The lanes are skipped and `E2E gate / result` passes at once. |++**Retry once.** Inside each lane a failed case is rerun once (`lib/e2e-retry-once.sh`, and `Invoke-CargoTest` in the Windows runner). A pass on the retry is flaky: it is listed under "Flaky cases" in the job summary and in the tracking issue, and does not fail the gate. Two failures are a real failure. The first attempt's rows, videos and log are kept under `retried-attempts/` in the lane artifact.++**Required check.** Branch protection cannot require a check by path, so the workflow always runs and `E2E gate / result` is the one check to require on `main`. It is green when the lanes are not needed. A repository admin has to add it under Settings, Branches. Until then the gate is advisory on pull requests; the label, path and release-PR triggers still run the lanes.diff --git a/scripts/ci/lib/e2e-retry-once.sh b/scripts/ci/lib/e2e-retry-once.shnew file mode 100644index 0000000000..baed51dc2b--- /dev/null+++ b/scripts/ci/lib/e2e-retry-once.sh@@ -0,0 +1,80 @@+#!/usr/bin/env bash+# Retry-once for a single E2E case inside the release gate.+#+# cua_e2e_run_case NAME LOG_FILE WORK_DIR CMD [ARGS...]+#+# Runs CMD in WORK_DIR, teeing output to LOG_FILE, and returns its exit code.+# When CUA_E2E_RETRY_ONCE=1 a failed case is rerun exactly once:+# - pass on the rerun: the case is "flaky". It is appended to+# ${CUA_E2E_FLAKY_FILE} (default: <results dir>/flaky-cases.jsonl) and the+# function returns 0, so the lane does not fail.+# - fail on the rerun: two failures are a real failure; returns the rerun's+# exit code.+# The first attempt's typed result rows, declarations and recordings are moved+# to <results dir>/retried-attempts/NAME/ so the report validator only sees the+# attempt that counts and no orphan video is left behind.+#+# Environment (set by the harness scripts): CUA_E2E_RESULTS_FILE,+# CUA_E2E_DECLARATIONS_FILE, CUA_E2E_RECORDINGS_ROOT.++cua_e2e_run_case() {+ local name="$1" log="$2" workdir="$3"+ shift 3+ local results="${CUA_E2E_RESULTS_FILE:-}"+ local decls="${CUA_E2E_DECLARATIONS_FILE:-}"+ local rec_root="${CUA_E2E_RECORDINGS_ROOT:-}"+ local retry="${CUA_E2E_RETRY_ONCE:-0}"+ local base_dir="" results_lines=0 decl_lines=0 before_dirs=""++ if [[ "${retry}" == 1 && -n "${results}" ]]; then+ base_dir="$(dirname "${results}")"+ results_lines=$(wc -l < "${results}" 2>/dev/null | tr -d ' ' || echo 0)+ [[ -n "${decls}" ]] && decl_lines=$(wc -l < "${decls}" 2>/dev/null | tr -d ' ' || echo 0)+ [[ -n "${rec_root}" && -d "${rec_root}" ]] \+ && before_dirs="$(find "${rec_root}" -mindepth 1 -maxdepth 1 | sort)"+ fi++ local code+ set +e+ (cd "${workdir}" && "$@") 2>&1 | tee "${log}"+ code=${PIPESTATUS[0]}+ set -e+ if [[ "${code}" == 0 || "${retry}" != 1 || -z "${base_dir}" ]]; then+ return "${code}"+ fi++ echo "[RETRY] ${name} failed (exit ${code}); rerunning once"+ local quarantine="${base_dir}/retried-attempts/${name//[^a-zA-Z0-9._-]/_}"+ mkdir -p "${quarantine}/recordings"+ cp "${log}" "${quarantine}/attempt1.log"+ tail -n +"$((results_lines + 1))" "${results}" > "${quarantine}/results.jsonl" || true+ awk -v n="${results_lines}" 'NR <= n' "${results}" > "${results}.keep" && mv "${results}.keep" "${results}"+ if [[ -n "${decls}" ]]; then+ tail -n +"$((decl_lines + 1))" "${decls}" > "${quarantine}/cases.jsonl" || true+ awk -v n="${decl_lines}" 'NR <= n' "${decls}" > "${decls}.keep" && mv "${decls}.keep" "${decls}"+ fi+ if [[ -n "${rec_root}" && -d "${rec_root}" ]]; then+ local d+ while IFS= read -r d; do+ [[ -n "${d}" ]] || continue+ grep -Fxq -- "${d}" <<< "${before_dirs}" || mv "${d}" "${quarantine}/recordings/"+ done < <(find "${rec_root}" -mindepth 1 -maxdepth 1 | sort)+ fi++ local code2+ set +e+ (cd "${workdir}" && "$@") 2>&1 | tee "${log}"+ code2=${PIPESTATUS[0]}+ set -e+ if [[ "${code2}" == 0 ]]; then+ local flaky_file="${CUA_E2E_FLAKY_FILE:-${base_dir}/flaky-cases.jsonl}"+ echo "[FLAKY] ${name} failed once (exit ${code}) then passed; not failing the gate"+ jq -cn --arg name "${name}" --argjson first_exit "${code}" \+ --arg platform "${CUA_E2E_PLATFORM:-$(uname -s)}" \+ '{case: $name, platform: $platform, first_attempt_exit: $first_exit, second_attempt: "passed"}' \+ >> "${flaky_file}"+ return 0+ fi+ echo "[FAIL] ${name} failed twice (exit ${code}, then ${code2}); real failure"+ return "${code2}"+}diff --git a/scripts/ci/linux/run-rust-e2e.sh b/scripts/ci/linux/run-rust-e2e.shindex 62baaacec3..ed7f4f5160 100755--- a/scripts/ci/linux/run-rust-e2e.sh+++ b/scripts/ci/linux/run-rust-e2e.sh@@ -210,14 +210,16 @@ if [[ "${PREFLIGHT_EXIT}" != 0 ]]; thenexit 1fi+# shellcheck source=../lib/e2e-retry-once.sh+source "${REPO_ROOT}/scripts/ci/lib/e2e-retry-once.sh"+export CUA_E2E_PLATFORM=linux+run_test() {local name="$1"shiftecho "[RUN] ${name}"- set +e- (cd "${RUST_ROOT}" && "$@") 2>&1 | tee "${ARTIFACT_DIR}/${name}.log"- local exit_code=${PIPESTATUS[0]}- set -e+ local exit_code=0+ cua_e2e_run_case "${name}" "${ARTIFACT_DIR}/${name}.log" "${RUST_ROOT}" "$@" || exit_code=$?if [[ "${exit_code}" != 0 ]]; thenFAILURE_COUNT=$((FAILURE_COUNT + 1))fidiff --git a/scripts/ci/macos/probe-hosted-runner.sh b/scripts/ci/macos/probe-hosted-runner.shindex 338eeadf77..dc2b25c05c 100755--- a/scripts/ci/macos/probe-hosted-runner.sh+++ b/scripts/ci/macos/probe-hosted-runner.sh@@ -92,11 +92,12 @@ run_with_deadline() {[[ "${RUNNER_ENVIRONMENT:-}" == github-hosted ]] || fail "runner must be GitHub-hosted"[[ "${CI:-}" == true ]] || fail "CI must be true"# Only maintainer-controlled events may seed hosted TCC state: a manual-# dispatch, or the stable Cua Driver tag push whose CD run calls this matrix+# dispatch, the nightly schedule on main, or the stable Cua Driver tag push whose CD run calls this matrix# as its release gate. Pull request events are never accepted.if [[ "${GITHUB_EVENT_NAME:-}" != workflow_dispatch ]]; then- [[ "${GITHUB_EVENT_NAME:-}" == push && "${GITHUB_REF:-}" == refs/tags/cua-driver-rs-v* ]] \- || fail "probe must be manually dispatched or run by a stable cua-driver-rs tag release gate"+ [[ ( "${GITHUB_EVENT_NAME:-}" == push && "${GITHUB_REF:-}" == refs/tags/cua-driver-rs-v* ) \+ || ( "${GITHUB_EVENT_NAME:-}" == schedule && "${GITHUB_REF:-}" == refs/heads/main ) ]] \+ || fail "probe must be manually dispatched, run by a stable cua-driver-rs tag release gate, or run by the nightly schedule on main"fi[[ "${SOURCE_SHA}" =~ ^[0-9a-fA-F]{40}$ ]] || fail "source SHA must contain 40 hexadecimal characters"[[ -z "${SSH_CONNECTION:-}${SSH_CLIENT:-}${SSH_TTY:-}" ]] || fail "SSH sessions cannot seed or certify hosted TCC state"diff --git a/scripts/ci/macos/run-hosted-rust-e2e.sh b/scripts/ci/macos/run-hosted-rust-e2e.shindex d5e39c5bff..01215d8453 100755--- a/scripts/ci/macos/run-hosted-rust-e2e.sh+++ b/scripts/ci/macos/run-hosted-rust-e2e.sh@@ -169,8 +169,9 @@ capture_command_output() {# Manual dispatch, or the stable Cua Driver tag release gate. Pull request# events never seed hosted TCC state.if [[ "${GITHUB_EVENT_NAME:-}" != workflow_dispatch ]]; then- [[ "${GITHUB_EVENT_NAME:-}" == push && "${GITHUB_REF:-}" == refs/tags/cua-driver-rs-v* ]] \- || fail "runs only from workflow_dispatch or a stable cua-driver-rs tag release gate"+ [[ ( "${GITHUB_EVENT_NAME:-}" == push && "${GITHUB_REF:-}" == refs/tags/cua-driver-rs-v* ) \+ || ( "${GITHUB_EVENT_NAME:-}" == schedule && "${GITHUB_REF:-}" == refs/heads/main ) ]] \+ || fail "runs only from workflow_dispatch, a stable cua-driver-rs tag release gate, or the nightly schedule on main"fi[[ "${RUNNER_ENVIRONMENT:-}" == github-hosted ]] \|| fail "requires a GitHub-hosted runner"diff --git a/scripts/ci/macos/run-rust-e2e.sh b/scripts/ci/macos/run-rust-e2e.shindex 990e652eb3..562b9208b9 100755--- a/scripts/ci/macos/run-rust-e2e.sh+++ b/scripts/ci/macos/run-rust-e2e.sh@@ -121,14 +121,16 @@ write_failure_record() {> "${failures_file}"}+# shellcheck source=../lib/e2e-retry-once.sh+source "${REPO_ROOT}/scripts/ci/lib/e2e-retry-once.sh"+export CUA_E2E_PLATFORM=macos+run_test() {local name="$1"; shiftlocal log_name="${name//[^a-zA-Z0-9._-]/_}"echo "[RUN] ${name}"- set +e- (cd "${RUST_ROOT}" && "$@") 2>&1 | tee "${ARTIFACT_DIR}/${log_name}.log"- local exit_code=${PIPESTATUS[0]}- set -e+ local exit_code=0+ cua_e2e_run_case "${name}" "${ARTIFACT_DIR}/${log_name}.log" "${RUST_ROOT}" "$@" || exit_code=$?if [[ "${exit_code}" != 0 ]]; thennote_lane_failure "${name}"fidiff --git a/scripts/ci/run-rust-standalone-browser-e2e.sh b/scripts/ci/run-rust-standalone-browser-e2e.shindex ca45817572..fba6e85723 100755--- a/scripts/ci/run-rust-standalone-browser-e2e.sh+++ b/scripts/ci/run-rust-standalone-browser-e2e.sh@@ -144,17 +144,18 @@ elsetests+=(standalone_browser_native_omnibox_select_all)fifi+# shellcheck source=lib/e2e-retry-once.sh+source "${REPO_ROOT}/scripts/ci/lib/e2e-retry-once.sh"+export CUA_E2E_PLATFORM=browsersfailure_count=0for test_name in "${tests[@]}"; doecho "[RUN] ${test_name}"- set +e- (cd "${RUST_ROOT}" && cargo test --release -p cua-driver-e2e \+ test_status=0+ cua_e2e_run_case "${test_name}" "${ARTIFACT_DIR}/${test_name}.log" "${RUST_ROOT}" \+ cargo test --release -p cua-driver-e2e \${CARGO_DRIVER_FEATURE_ARGS[@]+"${CARGO_DRIVER_FEATURE_ARGS[@]}"} \--test standalone_browser_behavior_test "${test_name}" -- \- --ignored --exact --nocapture --test-threads=1) \- 2>&1 | tee "${ARTIFACT_DIR}/${test_name}.log"- test_status=${PIPESTATUS[0]}- set -e+ --ignored --exact --nocapture --test-threads=1 || test_status=$?if [[ "${test_status}" != 0 ]]; thenfailure_count=$((failure_count + 1))fidiff --git a/scripts/ci/summarize-flaky-cases.sh b/scripts/ci/summarize-flaky-cases.shnew file mode 100755index 0000000000..0ca89d34c8--- /dev/null+++ b/scripts/ci/summarize-flaky-cases.sh@@ -0,0 +1,17 @@+#!/usr/bin/env bash+# Print a markdown "Flaky cases" section for every flaky-cases.jsonl under DIR.+# A flaky case failed once and passed on the single retry (see+# scripts/ci/lib/e2e-retry-once.sh). Prints nothing when there are none, so the+# caller can append the output to a job summary or an issue body unconditionally.+# Usage: summarize-flaky-cases.sh DIR+set -euo pipefail+dir="${1:?usage: summarize-flaky-cases.sh DIR}"+rows=""+while IFS= read -r -d '' file; do+ rows+="$(jq -r '"| \(.platform) | `\(.case)` | \(.first_attempt_exit) | passed |"' "${file}")"$'\n'+done < <(find "${dir}" -type f -name flaky-cases.jsonl -print0 | sort -z)+rows="$(printf '%s' "${rows}" | sed '/^$/d')"+[[ -n "${rows}" ]] || exit 0+printf '## Flaky cases (failed once, passed on retry)\n\n'+printf 'These did not fail the gate. Two failures of the same case are a real failure.\n\n'+printf '| Platform | Case | First exit | Retry |\n| --- | --- | ---: | --- |\n%s\n' "${rows}"diff --git a/scripts/ci/windows/run-rust-e2e.ps1 b/scripts/ci/windows/run-rust-e2e.ps1index e47a0f5b3b..9feb0e26ca 100644--- a/scripts/ci/windows/run-rust-e2e.ps1+++ b/scripts/ci/windows/run-rust-e2e.ps1@@ -177,12 +177,10 @@ if ($preflightExit -ne 0) {throw "Windows E2E environment preflight failed"}-function Invoke-CargoTest {- param([string]$Name, [string[]]$Arguments)- Write-Host "[RUN] $Name" -ForegroundColor Yellow+function Invoke-CargoTestAttempt {+ param([string[]]$Arguments, [string]$LogPath)Push-Location $rustRoottry {- $logPath = Join-Path $artifactDir ("$($Name -replace '[^A-Za-z0-9_.-]', '-').log")$previousPreference = $ErrorActionPreference$ErrorActionPreference = "Continue"try {@@ -197,15 +195,55 @@ function Invoke-CargoTest {} finally {$ErrorActionPreference = $previousPreference}- $output | Tee-Object -FilePath $logPath- if ($exitCode -ne 0) {- $script:FailureCount++- }+ $output | Tee-Object -FilePath $LogPath | Out-Host+ return $exitCode} finally {Pop-Location}}+# With CUA_E2E_RETRY_ONCE=1 a failed case is rerun exactly once. A pass on the+# rerun is "flaky": it is recorded in flaky-cases.jsonl and does not fail the+# gate. Two failures are a real failure. Mirrors scripts/ci/lib/e2e-retry-once.sh.+function Invoke-CargoTest {+ param([string]$Name, [string[]]$Arguments)+ Write-Host "[RUN] $Name" -ForegroundColor Yellow+ $logPath = Join-Path $artifactDir ("$($Name -replace '[^A-Za-z0-9_.-]', '-').log")+ $retry = $env:CUA_E2E_RETRY_ONCE -eq "1"+ if ($retry) {+ $resultsLines = @(Get-Content $resultsPath).Count+ $caseLines = @(Get-Content $casesPath).Count+ $beforeDirs = @(Get-ChildItem -Path $recordingRoot -Directory | ForEach-Object { $_.FullName })+ }+ $exitCode = Invoke-CargoTestAttempt -Arguments $Arguments -LogPath $logPath+ if ($exitCode -ne 0 -and $retry) {+ Write-Host "[RETRY] $Name failed (exit $exitCode); rerunning once" -ForegroundColor Yellow+ $quarantine = Join-Path $artifactDir ("retried-attempts\" + ($Name -replace '[^A-Za-z0-9_.-]', '-'))+ New-Item -ItemType Directory -Force (Join-Path $quarantine "recordings") | Out-Null+ Copy-Item $logPath (Join-Path $quarantine "attempt1.log")+ $resultRows = @(Get-Content $resultsPath)+ $caseRows = @(Get-Content $casesPath)+ $resultRows | Select-Object -Skip $resultsLines | Set-Content (Join-Path $quarantine "results.jsonl")+ $caseRows | Select-Object -Skip $caseLines | Set-Content (Join-Path $quarantine "cases.jsonl")+ Set-Content -Path $resultsPath -Value ($resultRows | Select-Object -First $resultsLines)+ Set-Content -Path $casesPath -Value ($caseRows | Select-Object -First $caseLines)+ Get-ChildItem -Path $recordingRoot -Directory | Where-Object { $beforeDirs -notcontains $_.FullName } |+ ForEach-Object { Move-Item $_.FullName (Join-Path $quarantine "recordings") }+ $secondExit = Invoke-CargoTestAttempt -Arguments $Arguments -LogPath $logPath+ if ($secondExit -eq 0) {+ Write-Host "[FLAKY] $Name failed once (exit $exitCode) then passed; not failing the gate"+ $record = [ordered]@{ case = $Name; platform = "windows"; first_attempt_exit = $exitCode; second_attempt = "passed" }+ Add-Content -Path (Join-Path $artifactDir "flaky-cases.jsonl") -Value ($record | ConvertTo-Json -Compress)+ return+ }+ Write-Host "[FAIL] $Name failed twice (exit $exitCode, then $secondExit); real failure"+ $exitCode = $secondExit+ }+ if ($exitCode -ne 0) {+ $script:FailureCount+++ }+}+function Invoke-ComputerHistoryGate {$historyHome = Join-Path $artifactDir "history-product-home"$historyBinDir = Join-Path $artifactDir "history-product-bin"