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(release): the staging smoke request fails loudly when it cannot reach trycua/cloud (#6064)

ddupontf5d31f719aec
diff --git a/.github/scripts/request_staging_smoke.sh b/.github/scripts/request_staging_smoke.sh
index 18264e0258..16e19510d3 100755
--- a/.github/scripts/request_staging_smoke.sh
+++ b/.github/scripts/request_staging_smoke.sh
@@ -6,8 +6,11 @@
#
# GH_TOKEN=<contents:write on trycua/cloud> request_staging_smoke.sh <component> <sha>
#
-# Never fails the release run: if the dispatch cannot be sent it warns, and the
-# gate then waits until someone starts the smoke by hand
+# Fails (its job, not the release: publishing waits on the staging gate,
+# not on this job) when the dispatch cannot be sent, so a release app that
+# cannot reach trycua/cloud shows as a red job instead of a warning nobody
+# reads. The gate then waits for the smoke trycua/cloud's own tag poller
+# starts, or one started by hand
# (gh workflow run spaces-staging-smoke.yml -R trycua/cloud ...).
set -uo pipefail
@@ -16,8 +19,8 @@ sha="${2:?sha}"
summary="${GITHUB_STEP_SUMMARY:-/dev/null}"
if [ -z "${GH_TOKEN:-}" ]; then
- echo "::warning title=Staging smoke::no token for trycua/cloud; start the smoke by hand: gh workflow run spaces-staging-smoke.yml -R trycua/cloud -f component=$component -f sha=$sha"
- exit 0
+ echo "::error title=Staging smoke::no token for trycua/cloud (the release app could not mint one: is it installed on trycua/cloud with contents:write?); start the smoke by hand: gh workflow run spaces-staging-smoke.yml -R trycua/cloud -f component=$component -f sha=$sha"
+ exit 1
fi
if gh api repos/trycua/cloud/dispatches \
-f event_type=cua-release-candidate \
@@ -25,6 +28,6 @@ if gh api repos/trycua/cloud/dispatches \
-f "client_payload[sha]=$sha" >/dev/null; then
echo "Requested the staging smoke for $component at $sha" | tee -a "$summary"
else
- echo "::warning title=Staging smoke::could not send the dispatch to trycua/cloud; start the smoke by hand: gh workflow run spaces-staging-smoke.yml -R trycua/cloud -f component=$component -f sha=$sha"
+ echo "::error title=Staging smoke::could not send the cua-release-candidate dispatch to trycua/cloud (the release app needs contents:write there); start the smoke by hand: gh workflow run spaces-staging-smoke.yml -R trycua/cloud -f component=$component -f sha=$sha"
+ exit 1
fi
-exit 0
diff --git a/.github/scripts/tests/test_request_staging_smoke.py b/.github/scripts/tests/test_request_staging_smoke.py
new file mode 100644
index 0000000000..2f489fce26
--- /dev/null
+++ b/.github/scripts/tests/test_request_staging_smoke.py
@@ -0,0 +1,42 @@
+"""The staging smoke request fails loudly when it cannot reach trycua/cloud.
+
+v0.17.0-beta.6 waited two hours at its staging gate while this script only
+warned: the release app could not mint a token for trycua/cloud, so the
+cua-release-candidate dispatch was never sent and the job showed green.
+"""
+
+from __future__ import annotations
+
+import os
+import pathlib
+import subprocess
+
+import pytest
+
+REPO_ROOT = pathlib.Path(__file__).resolve().parents[3]
+SCRIPT = REPO_ROOT / ".github/scripts/request_staging_smoke.sh"
+
+
+def run(tmp_path: pathlib.Path, token: str, gh_ok: bool) -> subprocess.CompletedProcess:
+ bin_dir = tmp_path / "bin"
+ bin_dir.mkdir(exist_ok=True)
+ gh = bin_dir / "gh"
+ gh.write_text(f"#!/bin/sh\necho \"$@\" >> {tmp_path}/gh.log\nexit {0 if gh_ok else 1}\n")
+ gh.chmod(0o755)
+ env = {**os.environ, "PATH": f"{bin_dir}:{os.environ['PATH']}", "GH_TOKEN": token, "GITHUB_STEP_SUMMARY": str(tmp_path / "summary")}
+ return subprocess.run(["bash", str(SCRIPT), "cua-spaces", "abc123"], env=env, capture_output=True, text=True)
+
+
+def test_a_sent_dispatch_passes(tmp_path):
+ r = run(tmp_path, "t", gh_ok=True)
+ assert r.returncode == 0, r.stdout + r.stderr
+ assert "event_type=cua-release-candidate" in (tmp_path / "gh.log").read_text()
+ assert "Requested the staging smoke for cua-spaces at abc123" in r.stdout
+
+
[email protected]("token,gh_ok", [("", True), ("t", False)])
+def test_no_dispatch_fails_with_an_error(tmp_path, token, gh_ok):
+ r = run(tmp_path, token, gh_ok)
+ assert r.returncode == 1
+ assert "::error title=Staging smoke::" in r.stdout
+ assert "gh workflow run spaces-staging-smoke.yml -R trycua/cloud -f component=cua-spaces -f sha=abc123" in r.stdout