This is an automated email from the ASF dual-hosted git repository.
hello-stephen pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/doris.git
The following commit(s) were added to refs/heads/master by this push:
new d063acebc89 [fix](build) Record cloud review verdicts after the
Actions poller exits (#70983)
d063acebc89 is described below
commit d063acebc8922f50da7bf301f0d2ff81dbe17ebb
Author: shuke <[email protected]>
AuthorDate: Wed Nov 25 20:01:16 2026 +0800
[fix](build) Record cloud review verdicts after the Actions poller exits
(#70983)
### Background
Maintainers can run a cloud review on a PR with `run debugreview`. The
cloud publisher verifies the GitHub review and its inline comments. A
GitHub Actions job polls for that result and normally contributes it to
the required `code-review` status.
### What problem does this PR solve?
Issue Number: None
Related PR: #70973 (introduced the cloud review command), #70901 (manual
dismissal)
PR Type: Bugfix
Problem Summary: If polling stops after dispatch, a later `/review` can
pass before the cloud service publishes a P1 on the same head and base.
The gate can then stay green. This change lets the publisher record its
verified verdict directly. The receipt triggers the existing aggregate
workflow even when the original job has exited.
### Details
- **Frequency:** Requires an interrupted poller and overlapping results
on the same PR snapshot. Reproduced locally. Production frequency is
unknown.
- **Root cause:** The cloud publisher persisted its result outside
GitHub. Only the original polling job connected that result to the
aggregate status.
- **Why existing tests missed it:** The Actions tests covered poll
responses and source ordering separately. They did not deliver a cloud
blocker after the polling job had stopped. Database regression suites do
not execute GitHub workflows.
- **Fix:** The publisher records a commit status scoped to the run, PR
and base after verifying delivery on the head commit. Retries reuse the
first receipt. The resolver checks its author and review link, preserves
the order of subsequent verdicts and accepts a dismissal through the
existing verified Actions receipt.
- **Other paths and branches:** The default-branch workflow serves PRs
targeting release branches too. Existing publishers keep using polling
until upgraded. Previews produce no receipts. Local PASS and authorized
skip keep their existing precedence.
- **Behavior change:** A late cloud P0/P1 updates the gate even after
Actions stops polling. For rollout, configure `DORIS_REVIEW_APP_BOT`,
grant the publishing App Commit statuses write access, and deploy the
controller with the updated helper and the original workflow run ID in
`cloud_receipt_run_id`.
### Testing
- On the parent commit, the late-P1 regression returned `success` where
it expected `failure`. It passes on this branch, including dismissal,
stale base, replay and a later automated pass.
- Ran the Actions Python suite locally: 466 passed, 22 skipped. Both
changed workflows passed `actionlint`.
- Ran the companion controller tests with the pinned candidate helpers:
28 passed, three optional dependency tests skipped. The offline
integration published one P1, simulated a restart and verified one
review and one status receipt.
### Release note
A verified cloud review can update the merge gate after its GitHub
Actions polling job exits.
### Check List (For Author)
- Behavior changed: Yes (see Details)
- Does this need documentation: No
- Pre-submission status: Partially verified: live App delivery and
status-event aggregation require a default-branch rollout.
### AI Disclosure
- Tool: OpenAI Codex (GPT-6)
- Generated: Implementation, tests and PR description.
- Human review: Pending.
---
.github/scripts/debug_review.py | 34 +++++++++++++++
.github/scripts/resolve_code_review_status.py | 51 ++++++++++++++++++++--
.github/scripts/submit_review.py | 10 ++++-
.github/scripts/test_debug_review.py | 31 +++++++++++++
.github/scripts/test_resolve_code_review_status.py | 37 ++++++++++++++++
.github/scripts/test_submit_review.py | 10 +++++
.github/workflows/code-review-cloud-receipt.yml | 18 ++++++++
.github/workflows/reviewer-assignment-check.yml | 11 +++++
8 files changed, 197 insertions(+), 5 deletions(-)
diff --git a/.github/scripts/debug_review.py b/.github/scripts/debug_review.py
index 6446ebea327..ca5b725bb80 100644
--- a/.github/scripts/debug_review.py
+++ b/.github/scripts/debug_review.py
@@ -20,6 +20,7 @@
import http.client
import json
import os
+import re
import time
from pathlib import Path
from urllib.parse import urlencode, urlsplit
@@ -95,6 +96,32 @@ def verdict(result, pr_url, run_url, pr):
return state, summary, link if state == "failure" and converged else
run_url
+def publish_receipt(repo, run, pr, head, base, result, bot):
+ """Called by the cloud controller after exact GitHub review and inline
readback."""
+ if not re.fullmatch(r"[1-9][0-9]*", run) or not bot:
+ raise ValueError("Expected a workflow run ID and a publishing App
login")
+ pr_url = f"https://github.com/{repo}/pull/{pr}"
+ state, summary, _ = verdict(result, pr_url,
f"https://github.com/{repo}/actions/runs/{run}", pr)
+ fields = dict(context=f"code-review/cloud/{run}/pr-{pr}/base-{base}",
state=state,
+ description=summary, target_url=result["review_url"])
+ root = f"repos/{repo}"
+ # A lost POST response or controller restart must keep this result's
original order.
+ pages = gh(f"{root}/commits/{head}/statuses?per_page=100", "--paginate",
"--slurp")
+ for page in pages:
+ for row in page:
+ if row["context"] == fields["context"] and row["creator"]["login"]
== bot:
+ if any(row[key] != value for key, value in fields.items()):
+ raise ValueError("Conflicting cloud receipt for this run")
+ return
+ live = gh(f"{root}/pulls/{pr}")
+ if live["state"] != "open" or (live["head"]["sha"], live["base"]["sha"])
!= (head, base):
+ raise ValueError("Cloud review snapshot changed before recording the
verdict")
+ args = []
+ for key, value in fields.items():
+ args.extend(("-f", f"{key}={value}"))
+ gh(f"{root}/statuses/{head}", "-X", "POST", *args)
+
+
def review(pr, head, base):
repo = os.environ["GITHUB_REPOSITORY"]
run = os.environ["GITHUB_RUN_ID"]
@@ -136,6 +163,13 @@ def review(pr, head, base):
if state == "superseded":
print("PR changed during review")
return
+ if state == "completed" and not row["preview_only"] and
row["result"].get("gate_receipt") is True:
+ verdict(row["result"], pr_url, run_url, pr)
+ if not pending:
+ with Path(os.environ["GITHUB_OUTPUT"]).open("a") as
outputs:
+ print(f"aggregate_head={head}", file=outputs)
+ print(f"Cloud publisher recorded the verdict for
{row['result']['review_url']}")
+ return
if not row["preview_only"] and not pending:
if not current():
return
diff --git a/.github/scripts/resolve_code_review_status.py
b/.github/scripts/resolve_code_review_status.py
index 4702a2d3fdf..f23366e5ac1 100644
--- a/.github/scripts/resolve_code_review_status.py
+++ b/.github/scripts/resolve_code_review_status.py
@@ -37,6 +37,44 @@ def list_reviews(helper, repository, number):
return [review for page in pages for review in page]
+def completed_counts(pr, description):
+ return re.fullmatch(rf"Review completed for PR #{pr}: P0=(0|[1-9][0-9]*),
P1=(0|[1-9][0-9]*)\.",
+ description)
+
+
+def cloud_sources(statuses, repo_url):
+ # Replayed POSTs keep their first status ID, so an older run cannot
displace a later verdict.
+ bot = os.getenv("DORIS_REVIEW_APP_BOT")
+ receipts = {}
+ for item in statuses:
+ if not isinstance(item, dict) or not bot or (item.get("creator") or
{}).get("login") != bot:
+ continue
+ match =
re.fullmatch(r"code-review/cloud/([1-9][0-9]*)/pr-([1-9][0-9]*)/base-([0-9a-f]{40})",
+ item.get("context") or "")
+ if not match or item.get("state") not in ("failure", "success"):
+ continue
+ run, pr, base = match.groups()
+ if not
re.fullmatch(re.escape(f"{repo_url}/pull/{pr}#pullrequestreview-") +
r"[1-9][0-9]*",
+ item.get("target_url") or ""):
+ continue
+ description = item.get("description") or ""
+ counts = completed_counts(pr, description)
+ if counts:
+ expected = "success" if counts.groups() == ("0", "0") else
"failure"
+ elif re.fullmatch(rf"Review did not converge after 3 rounds for PR
#{pr}: "
+ r"P0=(0|[1-9][0-9]*), P1=(0|[1-9][0-9]*)\.",
description):
+ expected = "failure"
+ else:
+ continue
+ if item["state"] != expected:
+ continue
+ context = f"code-review/source/automated/pr-{pr}/base-{base}"
+ key = (context, f"{repo_url}/actions/runs/{run}")
+ if key not in receipts or item["id"] < receipts[key]["id"]:
+ receipts[key] = dict(item, context=context)
+ return receipts
+
+
def resolve_status(
pulls: list[object], statuses: list[object], *, head_sha: str, repo_url:
str = "", reviews_for_pr=None
) -> Resolution:
@@ -67,8 +105,10 @@ def resolve_status(
"pending", f"No open pull request currently uses {head_sha[:12]}."
)
+ receipts = cloud_sources(statuses, repo_url)
+ receipt_ids = {receipt["id"] for receipt in receipts.values()}
latest_by_context: dict[str, dict[str, object]] = {}
- for item in statuses:
+ for item in [*statuses, *receipts.values()]:
if not isinstance(item, dict):
raise ResolutionError("commit status entry is invalid")
context = item.get("context")
@@ -78,6 +118,9 @@ def resolve_status(
raise ResolutionError("commit status context or id is invalid")
if not isinstance(state, str):
raise ResolutionError("commit status state is invalid")
+ # A cached running response may arrive after this run's terminal
receipt.
+ if state == "pending" and (context, item.get("target_url")) in
receipts:
+ continue
previous = latest_by_context.get(context)
if previous is None or status_id > int(previous["id"]):
latest_by_context[context] = item
@@ -105,11 +148,11 @@ def resolve_status(
key = (int(match.group(1)), match.group(2).casefold())
url = item.get("target_url")
description = item.get("description") or ""
- counts = re.fullmatch(rf"Review completed for PR #{key[0]}:
P0=(0|[1-9][0-9]*), P1=(0|[1-9][0-9]*)\.",
- description)
+ counts = completed_counts(key[0], description)
if (key in open_contexts and (key[0], url) in dismissed
and counts and counts.groups() != ("0", "0")
- and (item.get("creator") or {}).get("login") ==
"github-actions[bot]"):
+ and ((item.get("creator") or {}).get("login") ==
"github-actions[bot]"
+ or item["id"] in receipt_ids)):
accepted_dismissals[key] = url
continue
blocked_contexts.add(key)
diff --git a/.github/scripts/submit_review.py b/.github/scripts/submit_review.py
index 27e159a8f26..d097f61d01e 100644
--- a/.github/scripts/submit_review.py
+++ b/.github/scripts/submit_review.py
@@ -459,13 +459,21 @@ def _verify_completion(context, run, remaining, *,
submit=False, submission=None
verify_inline_comments(root, review, payload, run, remaining)
# Recheck after the API reads so a moving PR cannot pass an obsolete
review.
check_target(run, remaining)
- return {
+ result = {
"state": "failure" if counts[0] + counts[1] or not
submission["converged"] else "success",
"converged": submission["converged"], "rounds": submission["rounds"],
"incomplete_reason": submission["incomplete_reason"],
"p0": counts[0], "p1": counts[1], "review_id": review["id"],
"review_url": review["html_url"],
}
+ # Only the cloud controller supplies this run ID. Receipt recovery is
allowed to
+ # repair the status after a lost response, including on review-only
readback.
+ if "cloud_receipt_run_id" in run:
+ from debug_review import publish_receipt
+ publish_receipt(run["repository"], run["cloud_receipt_run_id"],
run["pr_number"],
+ run["head_sha"], run["base_sha"], result,
review["user"]["login"])
+ return dict(result, gate_receipt=True)
+ return result
def main():
diff --git a/.github/scripts/test_debug_review.py
b/.github/scripts/test_debug_review.py
index ae22816e62b..f8a58adf962 100644
--- a/.github/scripts/test_debug_review.py
+++ b/.github/scripts/test_debug_review.py
@@ -62,6 +62,37 @@ class DebugReviewTest(unittest.TestCase):
self.assertIn("state=failure", final)
self.assertIn("target_url=" + self.url, final)
+ def test_publisher_records_verified_result_once_after_lost_ack(self):
+ run, bot = "27", "cloud[bot]"
+ records = []
+ def github(path, *args):
+ if "/commits/" in path:
+ return [[], records]
+ if "/pulls/" in path:
+ return self.pr
+ self.assertEqual("repos/apache/doris/statuses/" + "a"*40, path)
+ fields = dict(field.split("=", 1) for field in args[3::2])
+ records.append(dict(fields, creator={"login": bot}))
+ raise TimeoutError("response lost after write")
+ self.api.side_effect = github
+ def publish():
+ debug.publish_receipt("apache/doris", run, 42, "a"*40, "b"*40,
self.result, bot)
+ with self.assertRaises(TimeoutError):
+ publish()
+ publish()
+ self.assertEqual(1, len(records))
+ self.assertEqual(("code-review/cloud/27/pr-42/base-" + "b"*40,
"failure", self.url),
+ tuple(records[0][k] for k in ("context", "state",
"target_url")))
+ self.run_review(dict(self.row, state="completed",
result=dict(self.result, gate_receipt=True)))
+ self.assertEqual(1, len(self.posts()))
+
+ def test_publisher_rejects_stale_snapshot_and_invalid_verdict(self):
+ self.api.side_effect = [[], dict(self.pr, base={"sha": "c"*40})]
+ for result in (self.result, dict(self.result, state="success")):
+ with self.assertRaises(ValueError):
+ debug.publish_receipt("apache/doris", "27", 42, "a"*40,
"b"*40, result, "cloud[bot]")
+ self.assertEqual([], self.posts())
+
def test_each_fc_request_uses_a_fresh_review_audience_token(self):
values = [(200, {"value": "first"}), (202, self.receipt),
(200, {"value": "next"}), (200, self.row)]
diff --git a/.github/scripts/test_resolve_code_review_status.py
b/.github/scripts/test_resolve_code_review_status.py
index 1f1f4f30ce2..cb5e829c97b 100644
--- a/.github/scripts/test_resolve_code_review_status.py
+++ b/.github/scripts/test_resolve_code_review_status.py
@@ -1,6 +1,7 @@
#!/usr/bin/env python3
import unittest
+from unittest.mock import patch
from resolve_code_review_status import ResolutionError, resolve_status
@@ -167,6 +168,42 @@ class ResolveCodeReviewStatusTest(unittest.TestCase):
result = resolve_status([pull(123), pull(124)], [status(1,
source="automated", state="failure")], head_sha=HEAD_SHA)
self.assertEqual("failure", result.state)
+ @patch.dict("os.environ", DORIS_REVIEW_APP_BOT="cloud[bot]")
+ def
test_late_cloud_blocker_survives_poll_loss_and_reconciles_dismissal(self):
+ repo = "https://github.com/apache/doris"
+ url = repo + "/pull/123#pullrequestreview-89"
+ actor = {"login": "cloud[bot]"}
+ receipt = dict(id=4, state="failure", creator=actor, target_url=url,
+ context=f"code-review/cloud/27/pr-123/base-{BASE_SHA}",
+ description="Review completed for PR #123: P0=0, P1=1.")
+ passed = status(3, source="automated")
+ late_poll = dict(status(5, source="automated", state="pending"),
+ target_url=repo + "/actions/runs/27")
+ dismissal = dict(id=6, state="success", creator={"login":
"github-actions[bot]"},
+ target_url=url,
context="code-review/dismissal/pr-123/review-89")
+ review = dict(commit_id=HEAD_SHA, user=actor, body="<!--
code-review-completion:t -->",
+ id=89, state="DISMISSED")
+
+ def resolve(*entries):
+ return resolve_status([pull(123)], list(entries),
head_sha=HEAD_SHA, repo_url=repo,
+ reviews_for_pr=lambda number: [review]).state
+
+ self.assertEqual("success", resolve(passed))
+ self.assertEqual("failure", resolve(passed, receipt))
+ self.assertEqual("failure", resolve(late_poll, receipt, passed))
+ self.assertEqual("success", resolve(late_poll, receipt, passed,
dismissal))
+ self.assertEqual("success", resolve(receipt, status(7,
source="automated"), dict(receipt, id=8)))
+ self.assertEqual("success", resolve(receipt, status(7, source="skip")))
+ clean = dict(receipt, state="success", description="Review completed
for PR #123: P0=0, P1=0.")
+ self.assertEqual("success", resolve(clean))
+ self.assertEqual("pending", resolve(dict(clean,
description=receipt["description"])))
+ incomplete = dict(receipt, description="Review did not converge after
3 rounds for PR #123: P0=0, P1=0.")
+ self.assertEqual("failure", resolve(incomplete, dismissal))
+ self.assertEqual("failure", resolve(receipt, dict(dismissal,
creator=actor)))
+ for fields in (dict(creator={"login": "unrelated[bot]"}),
dict(target_url=repo + "/pull/124"),
+ dict(context=receipt["context"].replace(BASE_SHA,
OTHER_BASE_SHA))):
+ self.assertEqual("success", resolve(passed, dict(receipt,
**fields)))
+
def test_rejects_malformed_api_data(self) -> None:
with self.assertRaisesRegex(ResolutionError, "base SHA"):
resolve_status([pull(123, base="short")], [], head_sha=HEAD_SHA)
diff --git a/.github/scripts/test_submit_review.py
b/.github/scripts/test_submit_review.py
index ef073bb50de..0983d0746cd 100644
--- a/.github/scripts/test_submit_review.py
+++ b/.github/scripts/test_submit_review.py
@@ -127,6 +127,16 @@ class FinalReviewTest(unittest.TestCase):
def verify(self):
return submitter.verify_completion(self.context, self.run,
self.remaining)
+ def test_cloud_receipt_can_recover_without_resubmitting_the_review(self):
+ self.run["cloud_receipt_run_id"] = "27"
+ with mock.patch("debug_review.publish_receipt",
side_effect=[TimeoutError(), None]) as receipt:
+ with self.assertRaises(TimeoutError):
+ self.submit()
+ self.assertTrue(self.verify()["gate_receipt"])
+ self.assertEqual(1, len(self.reviews))
+ self.assertEqual(2, receipt.call_count)
+ self.assertEqual(receipt.call_args_list[0], receipt.call_args_list[1])
+
def gh_response(self, command, **kwargs):
payload = json.loads(kwargs["input"]) if kwargs.get("input") is not
None else None
paginated = "--paginate" in command
diff --git a/.github/workflows/code-review-cloud-receipt.yml
b/.github/workflows/code-review-cloud-receipt.yml
new file mode 100644
index 00000000000..aa2a4e117a6
--- /dev/null
+++ b/.github/workflows/code-review-cloud-receipt.yml
@@ -0,0 +1,18 @@
+name: Cloud Review Receipt
+
+on: status
+
+permissions: {}
+
+jobs:
+ aggregate-cloud-receipt:
+ if: >-
+ vars.DORIS_REVIEW_APP_BOT != '' && github.event.sender.login ==
vars.DORIS_REVIEW_APP_BOT &&
+ startsWith(github.event.context, 'code-review/cloud/')
+ permissions:
+ contents: read
+ pull-requests: read
+ statuses: write
+ uses: ./.github/workflows/code-review-aggregate-status.yml
+ with:
+ head_sha: ${{ github.event.sha }}
diff --git a/.github/workflows/reviewer-assignment-check.yml
b/.github/workflows/reviewer-assignment-check.yml
index daa07762191..c84b3ed88cf 100644
--- a/.github/workflows/reviewer-assignment-check.yml
+++ b/.github/workflows/reviewer-assignment-check.yml
@@ -13,6 +13,11 @@ on:
- '.github/scripts/test_review_checkout_workflow.py'
- '.github/scripts/resolve_code_review_status.py'
- '.github/scripts/test_resolve_code_review_status.py'
+ - '.github/scripts/debug_review.py'
+ - '.github/scripts/test_debug_review.py'
+ - '.github/scripts/submit_review.py'
+ - '.github/scripts/test_submit_review.py'
+ - '.github/workflows/code-review-cloud-receipt.yml'
- '.github/workflows/pull-request-events.yml'
- '.github/workflows/resolve-pr-event.yml'
- '.github/workflows/lfs-warning.yml'
@@ -31,6 +36,11 @@ on:
- '.github/scripts/test_review_checkout_workflow.py'
- '.github/scripts/resolve_code_review_status.py'
- '.github/scripts/test_resolve_code_review_status.py'
+ - '.github/scripts/debug_review.py'
+ - '.github/scripts/test_debug_review.py'
+ - '.github/scripts/submit_review.py'
+ - '.github/scripts/test_submit_review.py'
+ - '.github/workflows/code-review-cloud-receipt.yml'
- '.github/workflows/pull-request-events.yml'
- '.github/workflows/resolve-pr-event.yml'
- '.github/workflows/lfs-warning.yml'
@@ -67,3 +77,4 @@ jobs:
-s .github/scripts -p test_review_checkout_workflow.py
PYTHONDONTWRITEBYTECODE=1 python3 -m unittest discover \
-s .github/scripts -p test_resolve_code_review_status.py
+ (cd .github/scripts && python3 -B -m unittest test_debug_review
test_submit_review)
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]