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: post red release and scheduled workflows to Slack through Alertmanager (CUA-2227) (#5901)

cua-agents[bot]74568d60dc16
diff --git a/.github/scripts/tests/test_workflow_alerts.py b/.github/scripts/tests/test_workflow_alerts.py
new file mode 100644
index 0000000000..eb4515f4f4
--- /dev/null
+++ b/.github/scripts/tests/test_workflow_alerts.py
@@ -0,0 +1,209 @@
+"""Unit tests for .github/scripts/workflow_alerts.py (CUA-2227). Offline: no network, no PyYAML."""
+
+import datetime as dt
+import importlib.util
+import json
+import re
+import tempfile
+import unittest
+from pathlib import Path
+from unittest import mock
+
+ROOT = Path(__file__).resolve().parents[3]
+SPEC = importlib.util.spec_from_file_location("workflow_alerts", ROOT / ".github/scripts/workflow_alerts.py")
+wa = importlib.util.module_from_spec(SPEC)
+SPEC.loader.exec_module(wa)
+
+NOW = dt.datetime(2026, 10, 25, 1, 0, tzinfo=dt.timezone.utc)
+
+
+def run(conclusion="failure", name="Nightly: Cua Driver", event="schedule", branch="main", repo="trycua/cua", **extra):
+ return {
+ "name": name,
+ "conclusion": conclusion,
+ "event": event,
+ "head_branch": branch,
+ "head_repository": {"full_name": repo},
+ "head_sha": "0123456789abcdef0123456789abcdef01234567",
+ "run_number": 7,
+ "html_url": "https://github.com/%s/actions/runs/1" % repo,
+ "run_started_at": "2026-10-25T00:07:00Z",
+ "created_at": "2026-10-25T00:07:00Z",
+ **extra,
+ }
+
+
+class BuildAlert(unittest.TestCase):
+ def test_failure_is_a_firing_alert_that_expires(self):
+ alert = wa.build_alert(run("failure"), "Nightly: Cua Driver", "trycua/cua", "ci", NOW, 2)
+ self.assertEqual(alert["labels"], {
+ "alertname": "GitHubWorkflowFailed", "source": "github-actions", "severity": "warning",
+ "environment": "ci", "repo": "trycua/cua", "workflow": "Nightly: Cua Driver",
+ })
+ self.assertEqual(alert["endsAt"], "2026-10-25T03:00:00Z")
+ self.assertEqual(alert["startsAt"], "2026-10-25T00:07:00Z")
+ self.assertIn("is red", alert["annotations"]["summary"])
+ self.assertIn("a job failed", alert["annotations"]["description"])
+ self.assertEqual(alert["annotations"]["run_url"], "https://github.com/trycua/cua/actions/runs/1")
+
+ def test_startup_failure_explains_the_missing_log(self):
+ alert = wa.build_alert(run("startup_failure"), "Nightly: Cua Driver", "trycua/cua", "ci", NOW, 2)
+ self.assertIn("before any job started", alert["annotations"]["description"])
+
+ def test_success_resolves_now(self):
+ alert = wa.build_alert(run("success"), "Nightly: Cua Driver", "trycua/cua", "ci", NOW, 2)
+ self.assertEqual(alert["endsAt"], "2026-10-25T01:00:00Z")
+ self.assertIn("green again", alert["annotations"]["summary"])
+
+ def test_other_conclusions_change_nothing(self):
+ for conclusion in ("cancelled", "skipped", "neutral", "stale", "action_required", None):
+ self.assertIsNone(wa.build_alert(run(conclusion), "w", "trycua/cua", "ci", NOW, 2), conclusion)
+
+ def test_fingerprint_labels_ignore_the_run(self):
+ a = wa.build_alert(run("failure", run_number=1), "w", "trycua/cua", "ci", NOW, 2)
+ b = wa.build_alert(run("success", run_number=2), "w", "trycua/cua", "ci", NOW, 2)
+ self.assertEqual(a["labels"], b["labels"])
+
+ def test_runbook_is_optional(self):
+ self.assertNotIn("runbook", wa.build_alert(run(), "w", "r/r", "ci", NOW, 2)["annotations"])
+ self.assertEqual(wa.build_alert(run(), "w", "r/r", "ci", NOW, 2, "https://x/y")["annotations"]["runbook"], "https://x/y")
+
+ def test_the_workflow_name_is_not_the_run_name(self):
+ # A workflow with run-name: reports the run-name as the run's "name".
+ alert = wa.build_alert(run(name="Nightly: Cua Driver cua-spaces 709b18d"), "Nightly: Cua Driver", "trycua/cua", "ci", NOW, 2)
+ self.assertEqual(alert["labels"]["workflow"], "Nightly: Cua Driver")
+
+
+class Eligible(unittest.TestCase):
+ def test_default_branch_schedule_and_dispatch_count(self):
+ for event in ("schedule", "repository_dispatch", "workflow_dispatch"):
+ self.assertTrue(wa.eligible(run(event=event), "trycua/cua", "main"), event)
+
+ def test_a_branch_dispatch_does_not(self):
+ self.assertFalse(wa.eligible(run(event="workflow_dispatch", branch="agent/x"), "trycua/cua", "main"))
+
+ def test_a_dispatch_on_a_release_tag_counts(self):
+ # The release gate is re-run by dispatching the workflow on the tag.
+ self.assertTrue(wa.eligible(run(event="workflow_dispatch", branch="cua-spaces-v0.15.0", repo="trycua/cua"), "trycua/cua", "main"))
+
+ def test_a_branch_that_merely_contains_a_version_is_not_a_release_tag(self):
+ for branch in ("feature/fix-v1.2-tests", "agent/cua-2227-v1.2", "x/cua-spaces-v0.15.0"):
+ self.assertFalse(wa.eligible(run(event="workflow_dispatch", branch=branch), "trycua/cua", "main"), branch)
+ for tag in ("cua-spaces-v0.15.0", "cua-driver-rs-v0.38.0", "lume-v0.6.2-nightly.20261015"):
+ self.assertTrue(wa.eligible(run(event="workflow_dispatch", branch=tag), "trycua/cua", "main"), tag)
+
+ def test_pushes_count_on_any_ref_so_release_tags_alert(self):
+ self.assertTrue(wa.eligible(run(event="push", branch="cua-driver-rs-v0.3.1"), "trycua/cua", "main"))
+
+ def test_pull_requests_and_forks_never_alert(self):
+ self.assertFalse(wa.eligible(run(event="pull_request"), "trycua/cua", "main"))
+ self.assertFalse(wa.eligible(run(repo="someone/cua"), "trycua/cua", "main"))
+
+
+class Watch(unittest.TestCase):
+ def test_parse(self):
+ self.assertEqual(wa.parse_watch(["a=release", " b ", "", "c="]), {"a": "release", "b": "ci", "c": "ci"})
+
+
+class Event(unittest.TestCase):
+ def dry(self, payload, watch):
+ with tempfile.TemporaryDirectory() as tmp:
+ path = Path(tmp) / "event.json"
+ path.write_text(json.dumps(payload))
+ with mock.patch.object(wa, "post") as post:
+ rc = wa.main(["--repo", "trycua/cua", "--watch", watch, "--event", str(path)])
+ return rc, post.call_args[0][0] if post.call_args else None
+
+ def test_failed_watched_run_is_posted(self):
+ rc, alerts = self.dry({"workflow_run": run("failure", name="Nightly: Cua Driver cua-spaces 709b18d"),
+ "workflow": {"name": "Nightly: Cua Driver"},
+ "repository": {"full_name": "trycua/cua", "default_branch": "main"}},
+ "Nightly: Cua Driver=ci")
+ self.assertEqual(rc, 0)
+ self.assertEqual(len(alerts), 1)
+ self.assertEqual(alerts[0]["labels"]["environment"], "ci")
+
+ def test_unwatched_or_ineligible_runs_post_nothing(self):
+ repo = {"full_name": "trycua/cua", "default_branch": "main"}
+ _, alerts = self.dry({"workflow_run": run("failure", name="other"), "workflow": {"name": "other"}, "repository": repo}, "Nightly: Cua Driver")
+ self.assertEqual(alerts, [])
+ _, alerts = self.dry({"workflow_run": run("failure", event="pull_request"), "workflow": {"name": "Nightly: Cua Driver"}, "repository": repo}, "Nightly: Cua Driver")
+ self.assertEqual(alerts, [])
+
+
+class NewestRun(unittest.TestCase):
+ PAYLOAD = {"workflow": {"name": "Nightly: Cua Driver"}, "repository": {"full_name": "trycua/cua", "default_branch": "main"}}
+
+ def post_for(self, run_id, newest_id):
+ payload = dict(self.PAYLOAD, workflow_run=run("success", id=run_id, workflow_id=5))
+ with tempfile.TemporaryDirectory() as tmp:
+ path = Path(tmp) / "event.json"
+ path.write_text(json.dumps(payload))
+ with mock.patch.object(wa, "latest_run", return_value={"id": newest_id}), mock.patch.object(wa, "post") as post:
+ wa.main(["--repo", "trycua/cua", "--watch", "Nightly: Cua Driver", "--event", str(path)])
+ return post.call_args[0][0]
+
+ def test_a_late_success_does_not_clear_a_newer_failure(self):
+ self.assertEqual(self.post_for(run_id=1, newest_id=2), [])
+
+ def test_the_newest_run_is_reported(self):
+ self.assertEqual(len(self.post_for(run_id=2, newest_id=2)), 1)
+
+
+class Sweep(unittest.TestCase):
+ def test_an_eligible_failure_behind_a_page_of_pull_request_runs_is_found(self):
+ pr_runs = [run("failure", event="pull_request", created_at="2026-10-25T00:30:00Z")] * 100
+ pages = {1: pr_runs, 2: [run("failure", run_number=9, created_at="2026-10-24T22:00:00Z")]}
+
+ def fake(url, token="", data=None, attempts=3):
+ page = int(url.rsplit("page=", 1)[1])
+ return {"workflow_runs": pages[page]}
+
+ with mock.patch.object(wa, "http_json", fake):
+ found = wa.latest_run("trycua/cua", 1, "tok", "main", 14, NOW)
+ self.assertEqual(found["run_number"], 9)
+
+ def test_nothing_newer_than_the_age_limit_means_no_alert(self):
+ def fake(url, token="", data=None, attempts=3):
+ return {"workflow_runs": [run("failure", created_at="2026-09-01T00:00:00Z")]}
+
+ with mock.patch.object(wa, "http_json", fake):
+ self.assertIsNone(wa.latest_run("trycua/cua", 1, "tok", "main", 14, NOW))
+
+
+ def test_latest_eligible_finished_run_of_each_watched_workflow(self):
+ def fake(url, token="", data=None, attempts=3):
+ self.assertEqual(token, "tok")
+ if "/actions/workflows?" in url:
+ return {"workflows": [{"id": 1, "name": "a"}, {"id": 2, "name": "b"}, {"id": 3, "name": "unwatched"}]}
+ if "/workflows/1/runs" in url:
+ return {"workflow_runs": [
+ run("cancelled", name="a"), # skipped: no state
+ run("failure", name="a", event="pull_request"), # skipped: not eligible
+ run("failure", name="a", run_number=5), # the one
+ run("success", name="a", run_number=4),
+ ]}
+ if "/workflows/2/runs" in url:
+ return {"workflow_runs": [run("failure", name="b", created_at="2026-09-01T00:00:00Z")]} # too old
+ self.fail(url)
+
+ with mock.patch.object(wa, "http_json", fake):
+ found = wa.latest_runs("trycua/cua", {"a": "ci", "b": "ci", "missing": "ci"}, "tok", "main", 14, NOW)
+ self.assertEqual([(name, r["run_number"]) for name, r in found], [("a", 5)])
+
+
+class WatchListMatchesTheWorkflow(unittest.TestCase):
+ """The workflow lists each watched name twice: the workflow_run trigger and --watch."""
+
+ def test_trigger_and_watch_agree(self):
+ text = (ROOT / ".github/workflows/workflow-failure-alerts.yml").read_text()
+ trigger = re.search(r"workflow_run:\n\s+workflows:\n((?:\s+- .+\n)+)", text).group(1)
+ triggered = {line.strip()[2:].strip().strip("\"'") for line in trigger.splitlines()}
+ watch = re.search(r"WATCH: \|\n((?: {8,}\S.*\n)+)", text).group(1)
+ watched = {line.strip().partition("=")[0] for line in watch.splitlines()}
+ self.assertEqual(triggered, watched)
+ self.assertTrue(triggered)
+
+
+if __name__ == "__main__":
+ unittest.main()
diff --git a/.github/scripts/workflow_alerts.py b/.github/scripts/workflow_alerts.py
new file mode 100644
index 0000000000..83bced410e
--- /dev/null
+++ b/.github/scripts/workflow_alerts.py
@@ -0,0 +1,241 @@
+#!/usr/bin/env python3
+"""Post the state of watched GitHub workflows to Alertmanager (CUA-2227).
+
+A copy of trycua/cloud scripts/ci/workflow_alerts.py; keep the two in step.
+
+GitHub emails a failed scheduled workflow only to whoever last edited its cron
+line, so a red nightly can go unseen for weeks. This turns each watched
+workflow into one Alertmanager alert instead. Alertmanager routes
+source="github-actions" to #alerts-staging. It never pages.
+
+ workflow_alerts.py --watch "spaces-staging-smoke=staging" --event "$GITHUB_EVENT_PATH"
+ workflow_alerts.py --watch "spaces-staging-smoke=staging" --sweep
+
+--event reads a workflow_run event and reports that run. --sweep looks at the
+latest finished run of every watched workflow and reports it, which refreshes a
+red alert and posts the green one. Both build the same alert, so Alertmanager
+treats them as one.
+
+A failed run (failure, timed_out, startup_failure) is a firing alert that ends
+after --ttl-hours unless refreshed. A successful run is a resolved alert, and
+the Slack message for it is the "green again" note. Cancelled, skipped and other
+conclusions change nothing. Standard library only.
+"""
+
+from __future__ import annotations
+
+import argparse
+import datetime as dt
+import json
+import os
+import re
+import sys
+import time
+import urllib.error
+import urllib.request
+
+ALERTMANAGER_URL = "https://am.cua.ai/api/v2/alerts"
+API = "https://api.github.com"
+ALERTNAME = "GitHubWorkflowFailed"
+FIRING = {"failure", "timed_out", "startup_failure"}
+RESOLVED = {"success"}
+# Triggers nobody is watching live. A pull_request run (a fork's too) never alerts.
+EVENTS = {"schedule", "push", "repository_dispatch", "workflow_dispatch"}
+# A release gate is re-run by dispatching the workflow on its tag (cua-spaces-v0.15.0).
+RELEASE_REF = re.compile(r"[A-Za-z0-9_.]+(?:-[A-Za-z0-9_.]+)*-v\d+\.\d+[A-Za-z0-9._+-]*")
+WHY = {
+ "failure": "a job failed",
+ "timed_out": "the run timed out",
+ "startup_failure": "GitHub rejected the run before any job started (a workflow file or permissions error; the run has no log)",
+}
+
+
+def parse_watch(entries: list[str]) -> dict[str, str]:
+ """["name=environment", "name"] -> {name: environment}; environment defaults to ci."""
+ watch: dict[str, str] = {}
+ for entry in entries:
+ name, _, environment = entry.partition("=")
+ if name.strip():
+ watch[name.strip()] = environment.strip() or "ci"
+ return watch
+
+
+def state_of(conclusion: str | None) -> str | None:
+ if conclusion in FIRING:
+ return "firing"
+ if conclusion in RESOLVED:
+ return "resolved"
+ return None
+
+
+def eligible(run: dict, repo: str, default_branch: str) -> bool:
+ """A run of this repository: any push (tags included), a dispatch on a release tag, or any run on the default branch."""
+ head_repo = (run.get("head_repository") or {}).get("full_name")
+ if head_repo and head_repo != repo:
+ return False
+ event = run.get("event")
+ if event not in EVENTS:
+ return False
+ branch = run.get("head_branch") or ""
+ return event == "push" or branch == default_branch or (event == "workflow_dispatch" and RELEASE_REF.fullmatch(branch) is not None)
+
+
+def iso(moment: dt.datetime) -> str:
+ return moment.astimezone(dt.timezone.utc).strftime("%Y-%m-%dT%H:%M:%SZ")
+
+
+def build_alert(run: dict, name: str, repo: str, environment: str, now: dt.datetime, ttl_hours: float, runbook: str = "") -> dict | None:
+ """`name` is the workflow's name. A run's own "name" is its run-name when the workflow sets one."""
+ state = state_of(run.get("conclusion"))
+ if state is None:
+ return None
+ conclusion = run["conclusion"]
+ sha = (run.get("head_sha") or "")[:7]
+ where = "%s run %s (%s, %s)" % (name, run.get("run_number", "?"), run.get("event"), sha or "unknown commit")
+ labels = {
+ "alertname": ALERTNAME,
+ "source": "github-actions",
+ "severity": "warning",
+ "environment": environment,
+ "repo": repo,
+ "workflow": name,
+ }
+ annotations = {"run_url": run.get("html_url", "")}
+ if runbook:
+ annotations["runbook"] = runbook
+ if state == "firing":
+ annotations["summary"] = "%s is red in %s" % (name, repo)
+ annotations["description"] = "%s: %s." % (where, WHY[conclusion])
+ starts, ends = run.get("run_started_at") or run.get("created_at"), iso(now + dt.timedelta(hours=ttl_hours))
+ else:
+ annotations["summary"] = "%s is green again in %s" % (name, repo)
+ annotations["description"] = "%s succeeded." % where
+ starts, ends = run.get("run_started_at") or run.get("created_at"), iso(now)
+ return {"labels": labels, "annotations": annotations, "startsAt": starts, "endsAt": ends}
+
+
+def http_json(url: str, token: str = "", data: object = None, attempts: int = 3):
+ body = None if data is None else json.dumps(data).encode()
+ headers = {"Accept": "application/vnd.github+json", "User-Agent": "workflow-alerts"}
+ if body is not None:
+ headers["Content-Type"] = "application/json"
+ if token:
+ headers["Authorization"] = "Bearer " + token
+ for attempt in range(1, attempts + 1):
+ request = urllib.request.Request(url, data=body, headers=headers, method="POST" if body is not None else "GET")
+ try:
+ with urllib.request.urlopen(request, timeout=30) as response:
+ text = response.read().decode()
+ return json.loads(text) if text.strip() else None
+ except urllib.error.HTTPError as err:
+ if err.code < 500 and err.code != 429 or attempt == attempts:
+ raise
+ except urllib.error.URLError:
+ if attempt == attempts:
+ raise
+ time.sleep(2 * attempt)
+
+
+def workflow_ids(repo: str, watch: dict[str, str], token: str) -> dict[str, int]:
+ ids: dict[str, int] = {}
+ page = 1
+ while len(ids) < len(watch):
+ listing = http_json("%s/repos/%s/actions/workflows?per_page=100&page=%d" % (API, repo, page), token)
+ for workflow in listing.get("workflows", []):
+ if workflow["name"] in watch:
+ ids[workflow["name"]] = workflow["id"]
+ if len(listing.get("workflows", [])) < 100:
+ break
+ page += 1
+ for missing in sorted(set(watch) - set(ids)):
+ print("::warning::watched workflow %r not found in %s" % (missing, repo))
+ return ids
+
+
+def latest_run(repo: str, workflow_id: int, token: str, default_branch: str, max_age_days: float | None, now: dt.datetime) -> dict | None:
+ """The newest finished run of a workflow that can change its alert (eligible, failed or succeeded).
+ Pages through newer pull request and cancelled runs; None when there is none within max_age_days."""
+ for page in range(1, 6):
+ runs = http_json("%s/repos/%s/actions/workflows/%d/runs?status=completed&per_page=100&page=%d" % (API, repo, workflow_id, page), token)
+ batch = runs.get("workflow_runs", [])
+ for run in batch:
+ created = dt.datetime.fromisoformat(run["created_at"].replace("Z", "+00:00"))
+ if max_age_days is not None and (now - created).total_seconds() > max_age_days * 86400:
+ return None # newest first: everything after this is older still
+ if state_of(run.get("conclusion")) is not None and eligible(run, repo, default_branch):
+ return run
+ if len(batch) < 100:
+ return None
+ return None
+
+
+def latest_runs(repo: str, watch: dict[str, str], token: str, default_branch: str, max_age_days: float, now: dt.datetime) -> list[tuple[str, dict]]:
+ """(workflow name, newest finished eligible run) for each watched workflow, newer than max_age_days."""
+ found = []
+ for name, workflow_id in workflow_ids(repo, watch, token).items():
+ run = latest_run(repo, workflow_id, token, default_branch, max_age_days, now)
+ if run:
+ found.append((name, run))
+ return found
+
+
+def post(alerts: list[dict], url: str) -> None:
+ if alerts:
+ http_json(url, data=alerts)
+
+
+def main(argv: list[str] | None = None) -> int:
+ ap = argparse.ArgumentParser(description=__doc__.split("\n\n")[0])
+ ap.add_argument("--watch", action="append", default=[], metavar="NAME[=ENVIRONMENT]", help="workflow name; repeat")
+ mode = ap.add_mutually_exclusive_group(required=True)
+ mode.add_argument("--event", metavar="PATH", help="a workflow_run event payload ($GITHUB_EVENT_PATH)")
+ mode.add_argument("--sweep", action="store_true", help="report the latest finished run of every watched workflow")
+ ap.add_argument("--repo", default=os.environ.get("GITHUB_REPOSITORY", ""))
+ ap.add_argument("--default-branch", default=os.environ.get("DEFAULT_BRANCH", "main"))
+ ap.add_argument("--ttl-hours", type=float, default=2.0, help="a red alert ends this long after the last report")
+ ap.add_argument("--max-age-days", type=float, default=14.0, help="--sweep ignores runs older than this")
+ ap.add_argument("--runbook", default="")
+ ap.add_argument("--url", default=os.environ.get("ALERTMANAGER_URL", ALERTMANAGER_URL))
+ ap.add_argument("--dry-run", action="store_true", help="print the alerts instead of posting them")
+ args = ap.parse_args(argv)
+ watch = parse_watch(args.watch)
+ if not watch or not args.repo:
+ ap.error("--watch and --repo (or GITHUB_REPOSITORY) are required")
+ now = dt.datetime.now(dt.timezone.utc)
+
+ if args.event:
+ with open(args.event) as handle:
+ event = json.load(handle)
+ run = event.get("workflow_run") or {}
+ repo = (event.get("repository") or {}).get("full_name") or args.repo
+ default_branch = (event.get("repository") or {}).get("default_branch") or args.default_branch
+ workflow = (event.get("workflow") or {}).get("name") or run.get("name")
+ runs = [(workflow, run)] if workflow in watch and eligible(run, repo, default_branch) else []
+ if runs and run.get("workflow_id"):
+ # An older run can finish after a newer one (a re-run, a long build). Only the newest finished run may
+ # change the alert, or a late success would clear a newer failure until the next sweep.
+ token = os.environ.get("GH_TOKEN") or os.environ.get("GITHUB_TOKEN") or ""
+ newest = latest_run(repo, run["workflow_id"], token, default_branch, None, now)
+ if newest and newest["id"] != run.get("id"):
+ print("run %s of %s is not the newest finished run (%s); the sweep reports that one" % (run.get("id"), workflow, newest["id"]))
+ runs = []
+ else:
+ token = os.environ.get("GH_TOKEN") or os.environ.get("GITHUB_TOKEN") or ""
+ runs = latest_runs(args.repo, watch, token, args.default_branch, args.max_age_days, now)
+ repo = args.repo
+
+ alerts = [a for a in (build_alert(r, n, repo, watch[n], now, args.ttl_hours, args.runbook) for n, r in runs) if a]
+ for alert in alerts:
+ state = "firing" if alert["endsAt"] > iso(now) else "resolved"
+ print("%s %s: %s" % (state, alert["labels"]["workflow"], alert["annotations"]["description"]))
+ if not alerts:
+ print("nothing to report")
+ if args.dry_run:
+ print(json.dumps(alerts, indent=2))
+ return 0
+ post(alerts, args.url)
+ return 0
+
+
+if __name__ == "__main__":
+ sys.exit(main())
diff --git a/.github/workflows/workflow-failure-alerts.yml b/.github/workflows/workflow-failure-alerts.yml
new file mode 100644
index 0000000000..e9d18516ef
--- /dev/null
+++ b/.github/workflows/workflow-failure-alerts.yml
@@ -0,0 +1,88 @@
+name: "Alerts: Workflow failures"
+
+# CUA-2227. GitHub emails a failed scheduled workflow only to whoever last edited
+# its cron line, so Nightly: Cua Driver ended as startup_failure for five nights
+# (20 to 24 Oct 2026) and nobody was told. This posts the state of the release
+# and scheduled workflows below to Alertmanager (label source=github-actions),
+# which sends it to the private Slack channel #alerts-staging. It never pages.
+#
+# - workflow_run: reports a run the moment it finishes.
+# - schedule: every 15 minutes, reports the latest finished run of each watched
+# workflow (at most 3 days old). It refreshes a red alert, posts the first
+# green after a red, and covers a run that ended as startup_failure (no job,
+# no log) in case GitHub does not send the workflow_run event for it.
+#
+# To watch another workflow, add its name in both places: the workflow_run
+# trigger and WATCH below (a unit test checks they match), as name=label.
+# trycua/cloud has the same notifier for the staging workflows.
+
+on:
+ workflow_run:
+ workflows:
+ - "Nightly: Cua Driver"
+ - "Nightly: Lume"
+ - "E2E: Cua Driver release gate"
+ - "CI: Cua Driver installer compatibility"
+ - "Monitor branded installer endpoints"
+ - "Release: Pipeline guard"
+ - "Security: push watch"
+ - "CD: Cua Driver (cross-platform)"
+ - "CD: Cua Driver SDK packages"
+ - "CD: Cua Spaces"
+ - "CD: cua-spacesd"
+ - "CD: Lume (macOS)"
+ - "Release: Prepare component releases"
+ - "Release: installer scripts feed"
+ types: [completed]
+ schedule:
+ - cron: "*/15 * * * *"
+ workflow_dispatch:
+
+permissions:
+ contents: read
+ actions: read
+
+concurrency:
+ group: workflow-failure-alerts
+ cancel-in-progress: false
+
+jobs:
+ alert:
+ runs-on: ubuntu-latest
+ timeout-minutes: 5
+ env:
+ WATCH: |
+ Nightly: Cua Driver=ci
+ Nightly: Lume=ci
+ E2E: Cua Driver release gate=release
+ CI: Cua Driver installer compatibility=release
+ Monitor branded installer endpoints=release
+ Release: Pipeline guard=release
+ Security: push watch=ci
+ CD: Cua Driver (cross-platform)=release
+ CD: Cua Driver SDK packages=release
+ CD: Cua Spaces=release
+ CD: cua-spacesd=release
+ CD: Lume (macOS)=release
+ Release: Prepare component releases=release
+ Release: installer scripts feed=release
+ DEFAULT_BRANCH: ${{ github.event.repository.default_branch }}
+ GH_TOKEN: ${{ github.token }}
+ steps:
+ - uses: actions/checkout@v4
+ with:
+ sparse-checkout: .github/scripts/workflow_alerts.py
+ persist-credentials: false
+ - name: Post workflow state to Alertmanager
+ run: |
+ set -euo pipefail
+ args=()
+ while IFS= read -r entry; do
+ [ -n "$entry" ] && args+=(--watch "$entry")
+ done <<< "$WATCH"
+ if [ "$GITHUB_EVENT_NAME" = workflow_run ]; then
+ mode=(--event "$GITHUB_EVENT_PATH")
+ else
+ mode=(--sweep --max-age-days 3)
+ fi
+ python3 .github/scripts/workflow_alerts.py "${args[@]}" "${mode[@]}"