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.

cd-cua-spaces: post-publish gate, cua.ai must serve the new release (CUA-3128) (#6356)

cua-agents[bot]060fde4e31c4
diff --git a/.github/scripts/check_spaces_site_follows_release.py b/.github/scripts/check_spaces_site_follows_release.py
new file mode 100644
index 0000000000..f5cf34b437
--- /dev/null
+++ b/.github/scripts/check_spaces_site_follows_release.py
@@ -0,0 +1,112 @@
+#!/usr/bin/env python3
+"""Post-publish gate: cua.ai must follow a stable Cua Spaces release (CUA-3128).
+
+Waits up to --timeout seconds (the site rebuild and CDN take minutes) for all of:
+ - the release is published (not draft, not prerelease)
+ - cua.ai/download and cua.ai/download/info show the version
+ - cua.ai/download/{mac,windows,linux} redirect to an asset of that version that answers 200
+ - the in-app updater feeds (Sparkle appcast, electron latest.yml / latest-linux.yml) advertise it
+Exits 1 with the remaining mismatches when the time runs out.
+"""
+import argparse
+import json
+import re
+import sys
+import time
+import urllib.error
+import urllib.request
+
+
+class _NoRedirect(urllib.request.HTTPRedirectHandler):
+ def redirect_request(self, *a, **k):
+ return None
+
+
+_plain = urllib.request.build_opener(_NoRedirect)
+_follow = urllib.request.build_opener()
+
+
+def fetch(url, method="GET", follow=True, headers=None):
+ req = urllib.request.Request(url, method=method, headers={"User-Agent": "cua-spaces-release-gate/1", **(headers or {})})
+ try:
+ with (_follow if follow else _plain).open(req, timeout=30) as r:
+ return r.status, r.headers.get("Location", ""), r.read(1 << 20) if method == "GET" else b""
+ except urllib.error.HTTPError as e:
+ return e.code, e.headers.get("Location", ""), b""
+
+
+FEEDS = {
+ "sparkle": ("cua-spaces-appcast.xml", r"<sparkle:shortVersionString>([^<]+)<"),
+ "electron-win": ("latest.yml", r"(?m)^version:\s*(\S+)"),
+ "electron-linux": ("latest-linux.yml", r"(?m)^version:\s*(\S+)"),
+}
+
+
+def mismatches(repo, ver, tag, feeds, token):
+ bad = []
+ gh = {"Authorization": "Bearer " + token} if token else {}
+ s, _, b = fetch("https://api.github.com/repos/%s/releases/tags/%s" % (repo, tag), headers=gh)
+ rel = json.loads(b) if s == 200 else {}
+ if s != 200 or rel.get("draft") or rel.get("prerelease"):
+ bad.append("release %s is not published as stable (status %s, prerelease=%s)" % (tag, s, rel.get("prerelease")))
+ s, _, b = fetch("https://cua.ai/download")
+ shown = sorted(set(re.findall(r"data-dl-version[^>]*>([^<]+)<", b.decode("utf-8", "replace"))))
+ if s != 200 or shown != [ver]:
+ bad.append("cua.ai/download shows %s (status %s)" % (",".join(shown) or "no version", s))
+ s, _, b = fetch("https://cua.ai/download/info")
+ try:
+ v = json.loads(b).get("version")
+ except ValueError:
+ v = None
+ if s != 200 or v != ver:
+ bad.append("cua.ai/download/info status %s version %s" % (s, v))
+ for osn in ("mac", "windows", "linux"):
+ s, loc, _ = fetch("https://cua.ai/download/" + osn, follow=False)
+ if s not in (301, 302, 307, 308) or "/%s/cua-spaces-%s-" % (tag, ver) not in loc:
+ bad.append("cua.ai/download/%s -> %s %s" % (osn, s, loc.split("?")[0][-70:] or "no redirect"))
+ continue
+ s = fetch(loc, method="HEAD")[0]
+ if s != 200:
+ bad.append("cua.ai/download/%s asset answers %s" % (osn, s))
+ base = "https://github.com/%s/releases/download/cua-spaces-latest/" % repo
+ for name in feeds:
+ fname, rx = FEEDS[name]
+ s, _, b = fetch(base + fname)
+ m = re.search(rx, b.decode("utf-8", "replace"))
+ if not m or m.group(1) != ver:
+ bad.append("updater feed %s advertises %s (status %s)" % (name, m.group(1) if m else None, s))
+ return bad
+
+
+def main():
+ ap = argparse.ArgumentParser()
+ ap.add_argument("--version", required=True)
+ ap.add_argument("--repo", default="trycua/cua")
+ ap.add_argument("--feeds", default=",".join(FEEDS), help="comma list; a platform the release skipped keeps its old feed")
+ ap.add_argument("--timeout", type=int, default=900)
+ ap.add_argument("--interval", type=int, default=30)
+ a = ap.parse_args()
+ import os
+ token = os.environ.get("GH_TOKEN", "")
+ tag = "cua-spaces-v" + a.version
+ feeds = [f for f in a.feeds.split(",") if f]
+ deadline = time.time() + a.timeout
+ while True:
+ try:
+ bad = mismatches(a.repo, a.version, tag, feeds, token)
+ except Exception as e: # network blip: retry until the deadline
+ bad = ["check error: %s" % e]
+ if not bad:
+ print("ok: cua.ai/download, /download/info, 3 download links and %d updater feeds all serve %s" % (len(feeds), a.version))
+ return 0
+ print("waiting (%ds left): %s" % (max(0, deadline - time.time()), "; ".join(bad)), flush=True)
+ if time.time() >= deadline:
+ for b in bad:
+ print("::error::%s" % b)
+ print("::error::Cua Spaces %s is published but cua.ai does not serve it. Fix the site or links now." % a.version)
+ return 1
+ time.sleep(a.interval)
+
+
+if __name__ == "__main__":
+ sys.exit(main())
diff --git a/.github/workflows/cd-cua-spaces.yml b/.github/workflows/cd-cua-spaces.yml
index 71a0975085..3f6e4441cc 100644
--- a/.github/workflows/cd-cua-spaces.yml
+++ b/.github/workflows/cd-cua-spaces.yml
@@ -2388,3 +2388,40 @@ jobs:
gh release upload cua-install-latest assets/release-artifacts.json \
stamped/install.sh stamped/install.ps1 stamped/uninstall.sh stamped/uninstall.ps1 \
--clobber --repo "$GITHUB_REPOSITORY"
+
+ # CUA-3128: a stable release must never ship without cua.ai following it.
+ # Waits up to 15 minutes for the download page, the three download links
+ # and the in-app updater feeds to serve this version; fails loudly if not.
+ # A feed for a platform a patch release skipped keeps its previous version.
+ site-follows-release:
+ name: cua.ai serves the new release
+ needs: [installer-manifest, electron-plan]
+ if: >-
+ !cancelled() && needs.installer-manifest.result == 'success'
+ && startsWith(github.ref, 'refs/tags/cua-spaces-v')
+ && github.repository == 'trycua/cua'
+ && needs.electron-plan.outputs.prerelease != 'true'
+ runs-on: ubuntu-latest
+ timeout-minutes: 20
+ permissions:
+ contents: read
+ defaults:
+ run:
+ working-directory: .
+ steps:
+ - uses: actions/checkout@v4
+ - name: Check cua.ai/download, the download links and the updater feeds
+ env:
+ GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
+ VERSION: ${{ needs.electron-plan.outputs.version }}
+ MACOS: ${{ needs.electron-plan.outputs.macos }}
+ WINDOWS: ${{ needs.electron-plan.outputs.windows }}
+ LINUX: ${{ needs.electron-plan.outputs.linux }}
+ run: |
+ set -euo pipefail
+ feeds=()
+ [ "$MACOS" = true ] && feeds+=(sparkle)
+ [ "$WINDOWS" = true ] && feeds+=(electron-win)
+ [ "$LINUX" = true ] && feeds+=(electron-linux)
+ python3 .github/scripts/check_spaces_site_follows_release.py \
+ --version "$VERSION" --timeout 900 --feeds "$(IFS=,; echo "${feeds[*]}")"