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: start the staging smoke from the release tag run (#5706)

Francesco Bonaccie4b361e8e7ef
diff --git a/.github/scripts/request_staging_smoke.sh b/.github/scripts/request_staging_smoke.sh
new file mode 100755
index 0000000000..18264e0258
--- /dev/null
+++ b/.github/scripts/request_staging_smoke.sh
@@ -0,0 +1,30 @@
+#!/usr/bin/env bash
+# Starts the staging smoke for a release candidate (CUA-1993). Sends a
+# repository_dispatch of type cua-release-candidate to trycua/cloud, whose
+# spaces-staging-smoke workflow runs the smoke and posts the commit status
+# "staging-smoke/<component>" that require_staging_smoke.sh waits for.
+#
+# 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
+# (gh workflow run spaces-staging-smoke.yml -R trycua/cloud ...).
+set -uo pipefail
+
+component="${1:?component}"
+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
+fi
+if gh api repos/trycua/cloud/dispatches \
+ -f event_type=cua-release-candidate \
+ -f "client_payload[component]=$component" \
+ -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"
+fi
+exit 0
diff --git a/.github/scripts/require_staging_smoke.sh b/.github/scripts/require_staging_smoke.sh
index 80336601df..7252d8b2c3 100755
--- a/.github/scripts/require_staging_smoke.sh
+++ b/.github/scripts/require_staging_smoke.sh
@@ -11,8 +11,12 @@
# never satisfies the gate. Missing, pending, failed or older than MAX_AGE_HOURS
# (default 336) evidence fails.
#
-# How to satisfy it (the smoke lives in trycua/cloud and is run by hand; no
-# workflow runs it for you). After the release PR merges and the tag exists:
+# How it is satisfied: the tag run sends a cua-release-candidate dispatch to
+# trycua/cloud (request_staging_smoke.sh), which runs the staging smoke and
+# posts the status; this gate waits for it (WAIT_MINUTES, 30 in the CD jobs).
+# By hand, for a rerun or when the dispatch could not be sent:
+# gh workflow run spaces-staging-smoke.yml -R trycua/cloud -f component=<c> -f sha=<tag sha>
+# or, after the release PR merges and the tag exists:
# GH_TOKEN=<statuses:write on trycua/cua> python3 scripts/spaces-staging/smoke.py \
# --post-status <component> --sha <tag commit> --digest sha256:<artifact set>
# then re-run the failed "staging smoke is green" job on the tag run; the
@@ -44,20 +48,40 @@ fi
context="staging-smoke/$component"
max_age=$(( ${MAX_AGE_HOURS:-336} * 3600 ))
-# Newest status per context first (combined status API).
-row="$(gh api "repos/$repo/commits/$sha/status" --paginate \
- --jq ".statuses[] | select(.context == \"$context\") | [.state, .updated_at, .description, .target_url] | @tsv" \
- | head -n1 || true)"
-
-if [ -z "$row" ]; then
- echo "::error title=Staging gate::no '$context' status on $sha. Run the staging smoke for this commit first."
- exit 1
-fi
-IFS=$'\t' read -r state updated desc url <<<"$row"
-if [ "$state" != success ]; then
- echo "::error title=Staging gate::'$context' on $sha is '$state', not success ($url)"
- exit 1
-fi
+# The smoke is started by the tag run (request_staging_smoke.sh) and takes a
+# while, so a missing or pending status is waited for up to WAIT_MINUTES
+# (default 0 = check once). A failed or errored status, a stale one or one
+# without a digest still fails at once.
+deadline=$(( $(date -u +%s) + ${WAIT_MINUTES:-0} * 60 ))
+while :; do
+ # Newest status per context first (combined status API).
+ row="$(gh api "repos/$repo/commits/$sha/status" --paginate \
+ --jq ".statuses[] | select(.context == \"$context\") | [.state, .updated_at, .description, .target_url] | @tsv" \
+ | head -n1 || true)"
+ state=missing
+ if [ -n "$row" ]; then
+ IFS=$'\t' read -r state updated desc url <<<"$row"
+ fi
+ case "$state" in
+ success) break ;;
+ missing|pending)
+ if [ "$(date -u +%s)" -ge "$deadline" ]; then
+ if [ "$state" = missing ]; then
+ echo "::error title=Staging gate::no '$context' status on $sha. Run the staging smoke for this commit first."
+ else
+ echo "::error title=Staging gate::'$context' on $sha is still pending ($url)"
+ fi
+ exit 1
+ fi
+ echo "Waiting for '$context' on $sha ($state); next check in 60 s"
+ sleep 60
+ ;;
+ *)
+ echo "::error title=Staging gate::'$context' on $sha is '$state', not success ($url)"
+ exit 1
+ ;;
+ esac
+done
age=$(( $(date -u +%s) - $(date -u -d "$updated" +%s) ))
if [ "$age" -gt "$max_age" ]; then
echo "::error title=Staging gate::'$context' on $sha is stale ($updated)"
diff --git a/.github/workflows/cd-cua-spaces.yml b/.github/workflows/cd-cua-spaces.yml
index b19eed4130..db91a185dd 100644
--- a/.github/workflows/cd-cua-spaces.yml
+++ b/.github/workflows/cd-cua-spaces.yml
@@ -1705,6 +1705,38 @@ jobs:
# version, this repository, the files' sha512). installer-manifest publishes
# only after it passes; a manual run from a branch runs it on the build.
# Unsigned parts (allowed off trycua/cua) are skipped with a warning.
+ # Start the staging smoke for this tag (CUA-1993): trycua/cloud's
+ # spaces-staging-smoke workflow runs it and posts the commit status that
+ # `staging-gate` waits for. Needs the release app installed on trycua/cloud
+ # (RELEASE_APP_ID / RELEASE_APP_PRIVATE_KEY). Never fails the run: without it
+ # the gate times out and the smoke is started by hand as before.
+ request-staging-smoke:
+ name: Request the staging smoke
+ if: startsWith(github.ref, 'refs/tags/cua-spaces-v')
+ runs-on: ubuntu-latest
+ timeout-minutes: 5
+ defaults:
+ run:
+ working-directory: .
+ permissions:
+ contents: read
+ steps:
+ - uses: actions/checkout@v4
+ - name: Mint a token to dispatch on trycua/cloud
+ id: app-token
+ continue-on-error: true
+ uses: actions/create-github-app-token@v1
+ with:
+ app-id: ${{ secrets.RELEASE_APP_ID }}
+ private-key: ${{ secrets.RELEASE_APP_PRIVATE_KEY }}
+ owner: trycua
+ repositories: cloud
+ permission-contents: write
+ - name: Send the cua-release-candidate dispatch
+ env:
+ GH_TOKEN: ${{ steps.app-token.outputs.token }}
+ run: .github/scripts/request_staging_smoke.sh cua-spaces "$GITHUB_SHA"
+
# Staging first (CUA-1907): customers get nothing unless the staging smoke
# (cloud scripts/spaces-staging/smoke.py) is recorded green for this exact
# commit as the commit status "staging-smoke/cua-spaces". Only a release
@@ -1713,7 +1745,8 @@ jobs:
name: Staging smoke is green
if: startsWith(github.ref, 'refs/tags/cua-spaces-v')
runs-on: ubuntu-latest
- timeout-minutes: 5
+ # Waits up to 30 minutes for the smoke that request-staging-smoke starts.
+ timeout-minutes: 40
defaults:
run:
working-directory: .
@@ -1727,6 +1760,7 @@ jobs:
GH_TOKEN: ${{ github.token }}
SKIP_STAGING_GATE: ${{ github.event_name == 'workflow_dispatch' && inputs.skip_staging_gate }}
SKIP_REASON: ${{ github.event_name == 'workflow_dispatch' && inputs.skip_staging_reason || '' }}
+ WAIT_MINUTES: "30"
run: .github/scripts/require_staging_smoke.sh cua-spaces "$GITHUB_SHA"
verify-release:
diff --git a/.github/workflows/cd-rust-cua-driver.yml b/.github/workflows/cd-rust-cua-driver.yml
index 7aa1e82e49..dbc592da3d 100644
--- a/.github/workflows/cd-rust-cua-driver.yml
+++ b/.github/workflows/cd-rust-cua-driver.yml
@@ -1240,6 +1240,35 @@ jobs:
# the GitHub release (and therefore the PyPI/npm SDK packages) never becomes
# public before that evidence exists. Nightly and manual build-only runs skip
# it.
+ # Start the staging smoke for this tag (CUA-1993): trycua/cloud's
+ # spaces-staging-smoke workflow runs it and posts the commit status that
+ # `staging-gate` waits for. Needs the release app installed on trycua/cloud
+ # (RELEASE_APP_ID / RELEASE_APP_PRIVATE_KEY). Never fails the run: without it
+ # the gate times out and the smoke is started by hand as before.
+ request-staging-smoke:
+ name: Request the staging smoke
+ if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/cua-driver-rs-v')
+ runs-on: ubuntu-latest
+ timeout-minutes: 5
+ permissions:
+ contents: read
+ steps:
+ - uses: actions/checkout@v4
+ - name: Mint a token to dispatch on trycua/cloud
+ id: app-token
+ continue-on-error: true
+ uses: actions/create-github-app-token@v1
+ with:
+ app-id: ${{ secrets.RELEASE_APP_ID }}
+ private-key: ${{ secrets.RELEASE_APP_PRIVATE_KEY }}
+ owner: trycua
+ repositories: cloud
+ permission-contents: write
+ - name: Send the cua-release-candidate dispatch
+ env:
+ GH_TOKEN: ${{ steps.app-token.outputs.token }}
+ run: .github/scripts/request_staging_smoke.sh cua-driver "$GITHUB_SHA"
+
# Staging first (CUA-1907): a release publishes only when the staging smoke
# is recorded green for this exact commit as the commit status
# "staging-smoke/cua-driver" (description carries the artifact digest).
@@ -1250,7 +1279,8 @@ jobs:
name: staging smoke is green
if: github.event_name == 'push' && startsWith(github.ref, 'refs/tags/cua-driver-rs-v')
runs-on: ubuntu-latest
- timeout-minutes: 5
+ # Waits up to 30 minutes for the smoke that request-staging-smoke starts.
+ timeout-minutes: 40
permissions:
contents: read
statuses: read
@@ -1259,6 +1289,7 @@ jobs:
- name: Require a green staging smoke for this commit
env:
GH_TOKEN: ${{ github.token }}
+ WAIT_MINUTES: "30"
run: .github/scripts/require_staging_smoke.sh cua-driver "$GITHUB_SHA"
release: