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: gate macOS Swift linker and Check Docs rows on their inputs (#4129)

Francesco Bonacci1cc4d3718525
diff --git a/.github/workflows/ci-check-docs.yml b/.github/workflows/ci-check-docs.yml
index d323d95088..1d2c449b13 100644
--- a/.github/workflows/ci-check-docs.yml
+++ b/.github/workflows/ci-check-docs.yml
@@ -25,33 +25,81 @@ on:
permissions:
contents: read
+concurrency:
+ group: ci-check-docs-${{ github.ref }}
+ cancel-in-progress: true
+
jobs:
+ # Route once on Linux, then start only the generator rows this change can
+ # affect. Unaffected rows previously booted a macOS or Windows runner just to
+ # decide to skip.
+ scope:
+ name: Select affected generators
+ runs-on: ubuntu-latest
+ timeout-minutes: 10
+ outputs:
+ matrix: ${{ steps.scope.outputs.matrix }}
+ selected: ${{ steps.scope.outputs.selected }}
+ steps:
+ # The merge commit's first parent is the base, so two commits of history
+ # are enough to list exactly what the pull request changes.
+ - uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
+ with:
+ fetch-depth: 2
+ persist-credentials: false
+ - uses: actions/setup-node@v4
+ with:
+ node-version: "20"
+ - uses: pnpm/action-setup@v4
+ - name: Install docs dependencies
+ run: pnpm --dir docs install --frozen-lockfile
+ - name: Test generator routing and ownership
+ run: |
+ node docs/node_modules/tsx/dist/cli.mjs scripts/docs-generators/runner.ts --test-routing
+ node docs/node_modules/tsx/dist/cli.mjs --test scripts/docs-generators/runner.test.ts scripts/docs-generators/cua-driver.test.ts scripts/docs-generators/cua-driver-platform.test.ts scripts/docs-generators/sandbox.test.ts
+ - name: Select affected generator rows
+ id: scope
+ run: |
+ set -euo pipefail
+ git diff --name-only HEAD^1 HEAD > "$RUNNER_TEMP/docs-changed-files.txt"
+ GENERATORS=$(node docs/node_modules/tsx/dist/cli.mjs scripts/docs-generators/runner.ts --changed-files-file "$RUNNER_TEMP/docs-changed-files.txt")
+ echo "Selected generators: ${GENERATORS:-none}"
+ python3 - "$GENERATORS" >> "$GITHUB_OUTPUT" <<'PY'
+ import json
+ import sys
+
+ rows = {
+ "cua-driver": [
+ {"library": "cua-driver", "platform": "linux", "os": "ubuntu-latest"},
+ {"library": "cua-driver", "platform": "macos", "os": "macos-latest"},
+ {"library": "cua-driver", "platform": "windows", "os": "windows-latest"},
+ ],
+ "lume": [{"library": "lume", "platform": "macos", "os": "macos-latest"}],
+ "sandbox": [{"library": "sandbox", "platform": "linux", "os": "ubuntu-latest"}],
+ }
+ selected = sys.argv[1].split()
+ unknown = sorted(set(selected) - set(rows))
+ if unknown:
+ raise SystemExit(f"no Check Docs row for generator(s): {', '.join(unknown)}")
+ include = [row for key in selected for row in rows[key]]
+ print(f"matrix={json.dumps({'include': include})}")
+ print(f"selected={'true' if include else 'false'}")
+ PY
+
native-reference:
name: Reference / ${{ matrix.library }} / ${{ matrix.platform }}
+ needs: scope
+ if: needs.scope.outputs.selected == 'true'
strategy:
fail-fast: false
- matrix:
- include:
- - library: cua-driver
- platform: linux
- os: ubuntu-latest
- - library: cua-driver
- platform: macos
- os: macos-latest
- - library: cua-driver
- platform: windows
- os: windows-latest
- - library: lume
- platform: macos
- os: macos-latest
- - library: sandbox
- platform: linux
- os: ubuntu-latest
+ matrix: ${{ fromJSON(needs.scope.outputs.matrix) }}
runs-on: ${{ matrix.os }}
+ timeout-minutes: 45
defaults:
run:
shell: bash
steps:
+ # The generators read release tags to record the documented version.
- uses: actions/checkout@v4
with:
fetch-depth: 0
@@ -62,46 +110,53 @@ jobs:
- uses: pnpm/action-setup@v4
- name: Install docs dependencies
run: pnpm --dir docs install --frozen-lockfile
- - name: Test generator routing and ownership
- run: |
- node docs/node_modules/tsx/dist/cli.mjs scripts/docs-generators/runner.ts --test-routing
- node docs/node_modules/tsx/dist/cli.mjs --test scripts/docs-generators/runner.test.ts scripts/docs-generators/cua-driver.test.ts scripts/docs-generators/cua-driver-platform.test.ts scripts/docs-generators/sandbox.test.ts
- - name: Select affected generator
- id: scope
- env:
- BASE_SHA: ${{ github.event.pull_request.base.sha }}
- LIBRARY: ${{ matrix.library }}
- run: |
- git diff --name-only "$BASE_SHA" HEAD > "$RUNNER_TEMP/docs-changed-files.txt"
- GENERATORS=$(node docs/node_modules/tsx/dist/cli.mjs scripts/docs-generators/runner.ts --changed-files-file "$RUNNER_TEMP/docs-changed-files.txt")
- if [[ " $GENERATORS " == *" $LIBRARY "* ]]; then
- echo "selected=true" >> "$GITHUB_OUTPUT"
- fi
+ - name: Test generator ownership
+ run: node docs/node_modules/tsx/dist/cli.mjs --test scripts/docs-generators/runner.test.ts scripts/docs-generators/cua-driver.test.ts scripts/docs-generators/cua-driver-platform.test.ts scripts/docs-generators/sandbox.test.ts
+ # Restore the release build that CI: cua-driver contract clients saves
+ # from main. Its MCP discovery job installs the same toolchain, so the
+ # cache key matches. Pull requests never save.
+ - uses: dtolnay/rust-toolchain@stable
+ if: matrix.library == 'cua-driver'
+ - uses: Swatinem/rust-cache@9d47c6ad4b02e050fd481d890b2ea34778fd09d6 # v2
+ if: matrix.library == 'cua-driver'
+ with:
+ workspaces: "libs/cua-driver/rust -> target"
+ shared-key: mcp-client-discovery
+ save-if: false
- name: Install Linux build dependencies
- if: steps.scope.outputs.selected == 'true' && matrix.platform == 'linux' && matrix.library == 'cua-driver'
+ if: matrix.platform == 'linux' && matrix.library == 'cua-driver'
run: |
sudo apt-get update
sudo apt-get install -y --no-install-recommends \
clang pkg-config libdbus-1-dev libpipewire-0.3-dev libspa-0.2-dev \
libei-dev libxkbcommon-dev libx11-dev libxi-dev libxtst-dev libxext-dev
- name: Check generated reference
- if: steps.scope.outputs.selected == 'true' && matrix.platform != 'windows'
+ if: matrix.platform != 'windows'
run: node docs/node_modules/tsx/dist/cli.mjs scripts/docs-generators/runner.ts --library ${{ matrix.library }} --check
- name: Check generated reference in PowerShell
- if: steps.scope.outputs.selected == 'true' && matrix.platform == 'windows'
+ if: matrix.platform == 'windows'
shell: pwsh
run: node docs/node_modules/tsx/dist/cli.mjs scripts/docs-generators/runner.ts --library cua-driver --check
- name: Verify docs extraction preserves policy-filtered discovery
- if: steps.scope.outputs.selected == 'true' && matrix.library == 'cua-driver'
+ if: matrix.library == 'cua-driver'
run: node docs/node_modules/tsx/dist/cli.mjs --test scripts/docs-generators/cua-driver-policy.test.ts scripts/docs-generators/cua-driver-policy-binary.test.ts
check-docs-sync:
name: Check Documentation Sync
if: always()
- needs: native-reference
+ needs: [scope, native-reference]
runs-on: ubuntu-latest
+ timeout-minutes: 5
steps:
- - name: Require native checks to pass
+ - name: Require routing and every selected check to pass
env:
+ SCOPE: ${{ needs.scope.result }}
+ SELECTED: ${{ needs.scope.outputs.selected }}
RESULT: ${{ needs.native-reference.result }}
- run: test "$RESULT" = success
+ run: |
+ test "$SCOPE" = success
+ if [ "$SELECTED" = true ]; then
+ test "$RESULT" = success
+ else
+ echo "No generated reference is affected by this change."
+ fi
diff --git a/.github/workflows/ci-platform-linux-portability.yml b/.github/workflows/ci-platform-linux-portability.yml
new file mode 100644
index 0000000000..ff578ed123
--- /dev/null
+++ b/.github/workflows/ci-platform-linux-portability.yml
@@ -0,0 +1,56 @@
+name: "CI: platform-linux off Linux"
+
+# `cargo test --workspace` must keep compiling on developer Macs, so the Linux
+# adapter and its tests are checked on macOS. Trigger on the adapter and the
+# workspace crates it depends on, not on unrelated platform code.
+on:
+ pull_request:
+ paths:
+ - "libs/cua-driver/rust/.cargo/**"
+ - "libs/cua-driver/rust/Cargo.toml"
+ - "libs/cua-driver/rust/Cargo.lock"
+ - "libs/cua-driver/rust/rust-toolchain.toml"
+ - "libs/cua-driver/rust/crates/cua-driver-contract/**"
+ - "libs/cua-driver/rust/crates/cua-driver-core/**"
+ - "libs/cua-driver/rust/crates/cursor-overlay/**"
+ - "libs/cua-driver/rust/crates/pip-preview/**"
+ - "libs/cua-driver/rust/crates/platform-linux/**"
+ - ".github/workflows/ci-platform-linux-portability.yml"
+ push:
+ branches: [main]
+ paths:
+ - "libs/cua-driver/rust/.cargo/**"
+ - "libs/cua-driver/rust/Cargo.toml"
+ - "libs/cua-driver/rust/Cargo.lock"
+ - "libs/cua-driver/rust/rust-toolchain.toml"
+ - "libs/cua-driver/rust/crates/cua-driver-contract/**"
+ - "libs/cua-driver/rust/crates/cua-driver-core/**"
+ - "libs/cua-driver/rust/crates/cursor-overlay/**"
+ - "libs/cua-driver/rust/crates/pip-preview/**"
+ - "libs/cua-driver/rust/crates/platform-linux/**"
+ - ".github/workflows/ci-platform-linux-portability.yml"
+ workflow_dispatch:
+
+permissions:
+ contents: read
+
+concurrency:
+ group: platform-linux-portability-${{ github.ref }}
+ cancel-in-progress: ${{ github.event_name == 'pull_request' }}
+
+jobs:
+ platform-linux-off-linux:
+ name: platform-linux compiles on macOS
+ runs-on: macos-latest
+ timeout-minutes: 20
+ steps:
+ - uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5
+ - uses: dtolnay/rust-toolchain@4716b85f2fac3e324e64fa2810f6b5c3905760a5 # 1.97.1
+ - uses: Swatinem/rust-cache@9d47c6ad4b02e050fd481d890b2ea34778fd09d6 # v2
+ with:
+ workspaces: "libs/cua-driver/rust -> target"
+ key: platform-linux-off-linux
+ save-if: ${{ github.ref == 'refs/heads/main' }}
+ - name: Check platform-linux and its tests off Linux
+ working-directory: libs/cua-driver/rust
+ run: cargo check --locked -p platform-linux --all-targets
diff --git a/.github/workflows/ci-swift-linker.yml b/.github/workflows/ci-swift-linker.yml
index 2b5c6665ed..7c3b07ad2c 100644
--- a/.github/workflows/ci-swift-linker.yml
+++ b/.github/workflows/ci-swift-linker.yml
@@ -3,13 +3,29 @@ name: "CI: macOS Swift linker"
on:
pull_request:
paths:
- - "libs/cua-driver/rust/**"
+ # The duplicate-symbol regression comes from native Swift/Objective-C
+ # bridges linked into the macOS binary. Rebuild only when the macOS
+ # adapter, a manifest, a build script, the lockfile, or the toolchain
+ # can change what the linker sees.
+ - "libs/cua-driver/rust/.cargo/**"
+ - "libs/cua-driver/rust/Cargo.toml"
+ - "libs/cua-driver/rust/Cargo.lock"
+ - "libs/cua-driver/rust/rust-toolchain.toml"
+ - "libs/cua-driver/rust/crates/*/Cargo.toml"
+ - "libs/cua-driver/rust/crates/*/build.rs"
+ - "libs/cua-driver/rust/crates/platform-macos/**"
- "scripts/ci/macos/test-swift-linker-symbols.sh"
- ".github/workflows/ci-swift-linker.yml"
push:
branches: [main]
paths:
- - "libs/cua-driver/rust/**"
+ - "libs/cua-driver/rust/.cargo/**"
+ - "libs/cua-driver/rust/Cargo.toml"
+ - "libs/cua-driver/rust/Cargo.lock"
+ - "libs/cua-driver/rust/rust-toolchain.toml"
+ - "libs/cua-driver/rust/crates/*/Cargo.toml"
+ - "libs/cua-driver/rust/crates/*/build.rs"
+ - "libs/cua-driver/rust/crates/platform-macos/**"
- "scripts/ci/macos/test-swift-linker-symbols.sh"
- ".github/workflows/ci-swift-linker.yml"
workflow_dispatch:
@@ -43,19 +59,3 @@ jobs:
${{ runner.temp }}/cua-swift-linker.*/environment.txt
${{ runner.temp }}/cua-swift-linker.*/build.log
${{ runner.temp }}/cua-swift-linker.*/duplicate-symbols.txt
-
- platform-linux-off-linux:
- name: platform-linux compiles on macOS
- runs-on: macos-latest
- timeout-minutes: 20
- steps:
- - uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5
- - uses: dtolnay/rust-toolchain@4716b85f2fac3e324e64fa2810f6b5c3905760a5 # 1.97.1
- - uses: Swatinem/rust-cache@9d47c6ad4b02e050fd481d890b2ea34778fd09d6 # v2
- with:
- workspaces: "libs/cua-driver/rust -> target"
- key: platform-linux-off-linux
- save-if: ${{ github.ref == 'refs/heads/main' }}
- - name: Check platform-linux and its tests off Linux
- working-directory: libs/cua-driver/rust
- run: cargo check --locked -p platform-linux --all-targets