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: enforce staging-first in Spaces and Cua Driver publish (CUA-1907) (#5539)

Francesco Bonacci4e4f57f60ff1
diff --git a/.github/scripts/require_staging_smoke.sh b/.github/scripts/require_staging_smoke.sh
new file mode 100755
index 0000000000..80336601df
--- /dev/null
+++ b/.github/scripts/require_staging_smoke.sh
@@ -0,0 +1,71 @@
+#!/usr/bin/env bash
+# Staging-first gate (CUA-1907). Exits non-zero unless a green staging smoke is
+# recorded for this exact candidate, or the break-glass input is set.
+#
+# require_staging_smoke.sh <component> <sha>
+#
+# Evidence: a commit status on <sha> with context "staging-smoke/<component>"
+# and state "success", posted by the staging smoke runner. Its description
+# carries the candidate's artifact digest ("sha256:<hex> ..."), which is shown
+# in the summary. A status is bound to its commit, so a smoke of another SHA
+# 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:
+# 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
+# release jobs continue. For Cua Driver, the same command with
+# --post-status cua-driver (its smoke is the same staging smoke).
+# Driver has no workflow_dispatch bypass (its release job is tag-push only):
+# its break-glass is an admin posting the status by hand with the reason in the
+# description (the digest check still needs a "sha256:..." token).
+#
+# Break-glass (Spaces): SKIP_STAGING_GATE=true with a non-empty SKIP_REASON passes, with
+# an error-level annotation and a summary line; without a reason it fails.
+set -euo pipefail
+
+component="${1:?component}"
+sha="${2:?sha}"
+repo="${GITHUB_REPOSITORY:?}"
+summary="${GITHUB_STEP_SUMMARY:-/dev/null}"
+
+if [ "${SKIP_STAGING_GATE:-false}" = true ]; then
+ if [ -z "${SKIP_REASON// }" ]; then
+ echo "::error title=Staging gate::skip_staging_gate needs a reason (skip_staging_reason)"
+ exit 1
+ fi
+ msg="STAGING GATE BYPASSED for $component at $sha by ${GITHUB_ACTOR:-unknown}: $SKIP_REASON"
+ echo "::error title=BREAK-GLASS::$msg"
+ echo "### :rotating_light: $msg" >> "$summary"
+ exit 0
+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
+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)"
+ exit 1
+fi
+case "$desc" in
+ *sha256:*) ;;
+ *) echo "::error title=Staging gate::'$context' on $sha has no artifact digest in its description"; exit 1 ;;
+esac
+echo "Staging smoke green for $component at $sha: $desc ($url)"
+echo "Staging gate: $component $sha green ($desc) $url" >> "$summary"
diff --git a/.github/scripts/tests/test_cua_driver_release_wiring.py b/.github/scripts/tests/test_cua_driver_release_wiring.py
index 74c5de649a..c086ed5d60 100644
--- a/.github/scripts/tests/test_cua_driver_release_wiring.py
+++ b/.github/scripts/tests/test_cua_driver_release_wiring.py
@@ -1040,6 +1040,7 @@ fi
self.assertIn("ref: ${{ github.workflow_sha }}", workflow)
self.assertIn(
" needs:\n"
+ " - staging-gate\n"
" - build-linux\n"
" - build-windows\n"
" - build-macos-universal\n"
diff --git a/.github/scripts/tests/test_cua_spaces_release_wiring.py b/.github/scripts/tests/test_cua_spaces_release_wiring.py
index 4b7a3aa600..52567095be 100644
--- a/.github/scripts/tests/test_cua_spaces_release_wiring.py
+++ b/.github/scripts/tests/test_cua_spaces_release_wiring.py
@@ -103,7 +103,8 @@ class TestCuaSpacesReleaseWiring(unittest.TestCase):
self.assertIn("brew install osslsigncode", verify)
# installer-manifest publishes the release and the feeds only after it.
publish = workflow.split("\n installer-manifest:\n", 1)[1]
- self.assertIn("verify-release]", publish.split("\n", 3)[1])
+ self.assertIn("verify-release", publish.split("\n", 3)[1])
+ self.assertIn("staging-gate]", publish.split("\n", 3)[1])
self.assertIn("needs.verify-release.result == 'success'", publish)
# checksums.txt and release-artifacts.json cover every asset, the
# Electron Windows and Linux installers included (CUA-1507).
diff --git a/.github/workflows/cd-cua-spaces.yml b/.github/workflows/cd-cua-spaces.yml
index 1fb34bbd9a..d7ad317b6e 100644
--- a/.github/workflows/cd-cua-spaces.yml
+++ b/.github/workflows/cd-cua-spaces.yml
@@ -180,6 +180,14 @@ on:
description: "Sparkle cutover (once, see apps/cua-spaces-desktop/docs/sparkle-cutover.md): this release's Sparkle item is the Electron app"
type: boolean
default: false
+ skip_staging_gate:
+ description: "BREAK-GLASS: publish without a green staging smoke for this commit (needs skip_staging_reason; logged loudly)"
+ type: boolean
+ default: false
+ skip_staging_reason:
+ description: "Why the staging gate is skipped (required with skip_staging_gate)"
+ required: false
+ default: ""
permissions:
contents: write
@@ -1687,6 +1695,30 @@ 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.
+ # 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
+ # tag publishes, so only a tag run is gated. Break-glass: skip_staging_gate.
+ staging-gate:
+ name: Staging smoke is green
+ if: startsWith(github.ref, 'refs/tags/cua-spaces-v')
+ runs-on: ubuntu-latest
+ timeout-minutes: 5
+ defaults:
+ run:
+ working-directory: .
+ permissions:
+ contents: read
+ statuses: read
+ steps:
+ - uses: actions/checkout@v4
+ - name: Require a green staging smoke for this commit
+ env:
+ 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 || '' }}
+ run: .github/scripts/require_staging_smoke.sh cua-spaces "$GITHUB_SHA"
+
verify-release:
name: Verify the signed release
needs: [build-macos, electron-plan, electron-mac, electron-windows, electron-publish]
@@ -1745,6 +1777,12 @@ jobs:
run: |
set -euo pipefail
expect=()
+ # Production never skips verification: an unsigned artifact on the
+ # canonical repository's release tag is a failure, not a warning.
+ if [ "$REQUIRE_SIGNING" = true ] && [ "$SWIFT_SIGNED" != true ]; then
+ echo "::error::trycua/cua release tag with an unsigned SwiftUI build: refusing to verify-skip"
+ exit 1
+ fi
if [ "$SWIFT_SIGNED" = true ]; then
expect+=(swift)
else
@@ -1766,6 +1804,10 @@ jobs:
fi
[ "$APPCAST" = true ] && expect+=(appcast)
if [ ${#expect[@]} -eq 0 ]; then
+ if [ "$REQUIRE_SIGNING" = true ]; then
+ echo "::error::nothing signed on a trycua/cua release tag"
+ exit 1
+ fi
echo "::warning::nothing in this build is signed: no release verification"
exit 0
fi
@@ -1776,7 +1818,7 @@ jobs:
installer-manifest:
name: release-artifacts.json, latest.json, publish
- needs: [build-macos, build-linux-windows, electron-plan, electron-mac, electron-publish, verify-release]
+ needs: [build-macos, build-linux-windows, electron-plan, electron-mac, electron-publish, verify-release, staging-gate]
# Only a release tag publishes: the Sigstore identity the installers and
# the updater feed trust is cd-cua-spaces.yml at refs/tags/cua-spaces-v*.
# A manual run from a tag re-publishes; from a branch it only builds.
@@ -1788,6 +1830,7 @@ jobs:
!cancelled() && startsWith(github.ref, 'refs/tags/cua-spaces-v')
&& needs.build-macos.result == 'success'
&& needs.verify-release.result == 'success'
+ && needs.staging-gate.result == 'success'
&& (needs.build-linux-windows.result == 'success' || needs.build-linux-windows.result == 'skipped')
&& (needs.electron-plan.outputs.publish != 'true' || needs.electron-publish.result == 'success')
runs-on: ubuntu-latest
diff --git a/.github/workflows/cd-rust-cua-driver.yml b/.github/workflows/cd-rust-cua-driver.yml
index 21425e674d..7aa1e82e49 100644
--- a/.github/workflows/cd-rust-cua-driver.yml
+++ b/.github/workflows/cd-rust-cua-driver.yml
@@ -1240,8 +1240,30 @@ 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.
+ # 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).
+ # Break-glass: an admin posts the status by hand with the reason in its
+ # description (see .github/scripts/require_staging_smoke.sh); the Driver
+ # release job runs on a tag push only, so there is no manual-run bypass.
+ staging-gate:
+ 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
+ permissions:
+ contents: read
+ statuses: read
+ steps:
+ - uses: actions/checkout@v4
+ - name: Require a green staging smoke for this commit
+ env:
+ GH_TOKEN: ${{ github.token }}
+ run: .github/scripts/require_staging_smoke.sh cua-driver "$GITHUB_SHA"
+
release:
needs:
+ - staging-gate
- build-linux
- build-windows
- build-macos-universal