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: add a release-hold label that blocks release PR auto-merge and ci-gate (#6788)

cua-agents[bot]288479063438
diff --git a/.github/scripts/release_pr_automerge.py b/.github/scripts/release_pr_automerge.py
index f599842bcf..e126e2e8b8 100644
--- a/.github/scripts/release_pr_automerge.py
+++ b/.github/scripts/release_pr_automerge.py
@@ -3,8 +3,10 @@
Every release-please PR (branch release-please--branches--*, opened by the release
App from this repository) gets `gh pr merge --auto --squash`. It then merges only
-when the required checks (ci-gate and the rest of the ruleset) are green. The `hold`
-label stops it: a held PR has auto-merge switched off, and ci-gate fails while the
+when the required checks (ci-gate and the rest of the ruleset) are green. The
+`release-hold` label (or the older `hold`) is the only hold it respects. Switching off
+auto-merge by hand is NOT a hold: the next run (on every PR update, and every 30 minutes)
+turns it back on, which is how #6749 (cua-spaces 0.22.0) merged while held. The label stops it: a held PR has auto-merge switched off, and ci-gate fails while the
label is on (ci-gate.yml), so a hold also wins a race with this script.
release_pr_automerge.py --repo trycua/cua # all open release PRs
@@ -39,7 +41,9 @@ sys.path.insert(0, os.path.dirname(os.path.abspath(__file__)))
import workflow_alerts # noqa: E402
BRANCH_PREFIX = "release-please--branches--"
-HOLD_LABEL = "hold"
+# `release-hold` is the documented label; `hold` is the older name and still works.
+# Keep this list in step with the label check in ci-gate.yml.
+HOLD_LABELS = ("release-hold", "hold")
GATE_CHECK = "ci-gate"
ALERTNAME = "ReleasePRStuck"
@@ -55,7 +59,7 @@ def is_release_pr(pr: dict, repo: str) -> bool:
def on_hold(pr: dict) -> bool:
- return any(label.get("name") == HOLD_LABEL for label in pr.get("labels", []))
+ return any(label.get("name") in HOLD_LABELS for label in pr.get("labels", []))
def parse_time(text: str) -> dt.datetime:
diff --git a/.github/scripts/tests/test_release_pr_automerge.py b/.github/scripts/tests/test_release_pr_automerge.py
index 1ef343cd1f..bc2001289d 100644
--- a/.github/scripts/tests/test_release_pr_automerge.py
+++ b/.github/scripts/tests/test_release_pr_automerge.py
@@ -151,3 +151,24 @@ class Wiring(unittest.TestCase):
if __name__ == "__main__":
unittest.main()
+
+
+class ReleaseHoldLabel(unittest.TestCase):
+ def test_release_hold_label_blocks_enable_and_disables_auto_merge(self):
+ with mock.patch.object(rp, "gh") as gh:
+ rp.reconcile(pr(labels=["release-hold"]), "trycua/cua")
+ gh.assert_not_called()
+ rp.reconcile(pr(6, labels=["release-hold"], auto={"mergeMethod": "SQUASH"}), "trycua/cua")
+ gh.assert_called_once_with("pr", "merge", "6", "--repo", "trycua/cua", "--disable-auto")
+
+ def test_manually_disabled_auto_merge_without_label_is_re_enabled(self):
+ with mock.patch.object(rp, "gh") as gh:
+ rp.reconcile(pr(8), "trycua/cua")
+ gh.assert_called_once_with("pr", "merge", "8", "--repo", "trycua/cua", "--auto", "--squash")
+
+ def test_ci_gate_fails_on_every_hold_label(self):
+ gate = (ROOT / ".github/workflows/ci-gate.yml").read_text()
+ for label in rp.HOLD_LABELS:
+ self.assertIn("contains(github.event.pull_request.labels.*.name, '%s')" % label, gate)
+ self.assertIn("labeled, unlabeled", gate)
+ self.assertIn("release-hold", (ROOT / ".github/workflows/release-pr-auto-merge.yml").read_text())
diff --git a/.github/workflows/ci-gate.yml b/.github/workflows/ci-gate.yml
index fde7e4b4a8..6dfe071256 100644
--- a/.github/workflows/ci-gate.yml
+++ b/.github/workflows/ci-gate.yml
@@ -20,12 +20,12 @@ jobs:
runs-on: ubuntu-latest
timeout-minutes: 180
steps:
- # A pull request labelled `hold` never merges, auto-merge or not (CUA-3559). The gate
+ # A pull request labelled `release-hold` (or the older `hold`) never merges, auto-merge or not (CUA-3559). The gate
# reruns when the label is added or removed (labeled/unlabeled above).
- name: Fail while the pull request is on hold
- if: ${{ github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'hold') }}
+ if: ${{ github.event_name == 'pull_request' && (contains(github.event.pull_request.labels.*.name, 'release-hold') || contains(github.event.pull_request.labels.*.name, 'hold')) }}
run: |
- echo "::error::This pull request has the hold label. Remove it to let the gate pass."
+ echo "::error::This pull request has a hold label (release-hold). Remove it to let the gate pass; see docs/release-hold.md"
exit 1
# Which workflows this gate may ignore, from the paths the PR changes, the area map
# (.github/ci-areas.json) and the package graph (.github/scripts/ci_graph.py); see
diff --git a/.github/workflows/release-pr-auto-merge.yml b/.github/workflows/release-pr-auto-merge.yml
index 9c428be19d..e66e1d8674 100644
--- a/.github/workflows/release-pr-auto-merge.yml
+++ b/.github/workflows/release-pr-auto-merge.yml
@@ -3,8 +3,12 @@ name: "Release: Auto-merge release PRs"
# CUA-3559. Release-please PRs wait for a human to merge them (median 8 h, p90 36 h; the
# driver and SDK PRs waited 15 days and 2 days). This turns on auto-merge (squash) for each
# one as it is opened or updated. It still merges only behind the required checks (ci-gate and
-# the rest of the main-safety-gates ruleset). The `hold` label stops it: a held PR gets
-# auto-merge switched off, and ci-gate fails while the label is on.
+# the rest of the main-safety-gates ruleset). The `release-hold` label (or the older `hold`)
+# stops it: a held PR gets auto-merge switched off, and ci-gate fails while the label is on.
+#
+# HOLD A RELEASE: add the `release-hold` label. Turning auto-merge off by hand is NOT a hold;
+# this workflow turns it back on at the next run (every PR update and every 30 minutes).
+# RELEASE: remove the label. See docs/release-hold.md.
#
# A merge made with the release App token starts the release pipeline (release-on-merge.yml);
# one made with GITHUB_TOKEN would not. Same App as release-please.yml.
diff --git a/docs/release-hold.md b/docs/release-hold.md
new file mode 100644
index 0000000000..cd8f9dbce4
--- /dev/null
+++ b/docs/release-hold.md
@@ -0,0 +1,19 @@
+# How to hold and release a release PR
+
+Release Please PRs merge themselves once ci-gate is green (`release-pr-auto-merge.yml`).
+To make one wait, for example for a real-Mac test gate, label it.
+
+## Hold
+
+Add the `release-hold` label to the release PR.
+
+- The auto-merge workflow switches GitHub auto-merge off and never turns it on while the label is present.
+- `ci-gate`, a required check, fails while the label is present, so nothing can merge the PR, including a person or a bot that enables auto-merge by hand.
+
+Turning auto-merge off by hand is not a hold. The workflow turns it back on at the next PR update or sweep (every 30 minutes). That is how #6749 (cua-spaces 0.22.0) merged while it was meant to wait.
+
+## Release
+
+Remove the label. ci-gate reruns and goes green, and auto-merge is enabled at the next run. To merge now, run the `Release: Auto-merge release PRs` workflow from the Actions tab, or merge the PR after ci-gate passes.
+
+`hold` is the older name of the label and still works.