mirror of
https://github.com/MacosPorters/betterxen.git
synced 2026-11-26 19:30:43 +00:00
agent queue: re-run the check only after an accepted verification
The verify job re-ran the pull request check after any /verified comment, including refused ones: the author's own, a non-verifier's, a stale or unknown head or a malformed SHA. decide now marks only an accepted verification of the current head, and the job re-runs the check only when should-rerun confirms it. A test checks that what re-runs the check is exactly what the check counts. Replay decides a comment listed twice only once. Tests cover duplicate and out-of-order listings, and every arrival order of a five-claim burst grants exactly one of two overlapping claims. Fixes #210, fixes #211 Signed-off-by: elforeign <324243036+elforeign@users.noreply.github.com>
This commit is contained in:
1 parent
e37c8566c6
commit
9fda5aab18
8 files changed
+96
-5
No files matched your search
@@ -38,6 +38,7 @@ def main(argv):
|
||||
s.add_argument("--recent-commands", action="store_true", help="include comments from the last lease_hours for replay")
|
||||
s = sub.add_parser("replay"); s.add_argument("--state", required=True)
|
||||
s = sub.add_parser("decide"); s.add_argument("--event", required=True); s.add_argument("--state", required=True)
|
||||
s = sub.add_parser("should-rerun"); s.add_argument("--actions", required=True)
|
||||
s = sub.add_parser("apply"); s.add_argument("--repo", required=True); s.add_argument("--actions", required=True)
|
||||
s = sub.add_parser("audit"); s.add_argument("--state", required=True)
|
||||
s = sub.add_parser("summary"); s.add_argument("--state", required=True); s.add_argument("--text", action="store_true")
|
||||
@@ -79,6 +80,9 @@ def main(argv):
|
||||
_out(decide(_load(a.event), _load(a.state), cfg))
|
||||
elif a.cmd == "replay":
|
||||
_out(replay.replay(_load(a.state), cfg, _now(a.now)))
|
||||
elif a.cmd == "should-rerun":
|
||||
# exit 0 only for an accepted /verified of the current head
|
||||
return 0 if decide_mod.rerun_check(_load(a.actions)) else 1
|
||||
elif a.cmd == "apply":
|
||||
ghio.apply_actions(a.repo, _load(a.actions))
|
||||
elif a.cmd == "audit":
|
||||
|
||||
@@ -150,4 +150,10 @@ def _verified(event, state, cfg, arg):
|
||||
return _reply(n, "%s may not verify: only maintainers and qa contributors can." % actor)
|
||||
if len(sha) < 7 or not head.startswith(sha):
|
||||
return _reply(n, "Verification refused: `%s` is not the current head %s." % (sha or "(none)", head[:12]))
|
||||
return _reply(n, "Verification of %s recorded for %s." % (head[:12], actor))
|
||||
# Only an accepted verification of the current head re-runs the pull request check.
|
||||
return [dict(_act(n, comment="Verification of %s recorded for %s." % (head[:12], actor)), rerun_check=True)]
|
||||
|
||||
|
||||
def rerun_check(actions):
|
||||
"""True when the decided actions record an accepted verification of the current head."""
|
||||
return any(a.get("rerun_check") for a in actions)
|
||||
@@ -45,6 +45,7 @@ def replay(state, cfg, now, bots=L.BOT):
|
||||
if (c.get("pull_request") or c["id"] in done or c["user"] in bots
|
||||
or parse_time(c["created_at"]) < since):
|
||||
continue
|
||||
done.add(c["id"]) # a comment listed twice is decided once
|
||||
actions = decide({"kind": "issue", "number": c["issue"], "actor": c["user"], "body": c["body"]}, state, cfg)
|
||||
if not actions:
|
||||
continue
|
||||
|
||||
Reference in new issue
Block a user