mirror of
https://github.com/MacosPorters/betterxen.git
synced 2026-11-26 04:19:52 +00:00
agent queue: start runs only for commands and replay cancelled claims
Every pull request comment started the verify job, which gathered state and re-ran the pull request check, so ordinary review discussion re-ran verification. Gate the verify job on comments that start with /verified and the claim job on comments that start with /. Claim runs share one concurrency group with cancel-in-progress: false. GitHub keeps one waiting run per group and cancels it when a newer run queues, so with the run deciding only its own comment, a /claim posted while another claim was being decided could be dropped without a reply. Each run now replays every command of the last lease_hours that has no bot reply, oldest first, updating labels in memory between commands; the hourly audit does the same, so a cancelled run's command is answered by the run that replaced it at the latest within the hour. Replies carry a done marker that counts only from the Actions bot. The pull request check is advisory until a live smoke test and the migration of existing issues: problems are a warning and the job passes. Tests model the concurrency group (the old event-only design loses the cancelled claim; replay answers all four commands), in-order overlap decisions, bot-only markers and the workflow triggers. Signed-off-by: elforeign <324243036+elforeign@users.noreply.github.com>
This commit is contained in:
1 parent
98bbe57471
commit
e37c8566c6
10 files changed
+302
-16
No files matched your search
@@ -63,6 +63,43 @@ class Workflows(unittest.TestCase):
|
||||
self.assertNotRegex(text, r"github\.event\.pull_request\.head|ref:\s*\$\{\{")
|
||||
self.assertIn("pull_request_target", text)
|
||||
|
||||
def job(self, name, job):
|
||||
"""Text of one job block: from ` <job>:` to the next two-space-indented key."""
|
||||
m = re.search(r"(?ms)^ %s:\n(.*?)(?=^ \S|\Z)" % re.escape(job), self.read(name))
|
||||
self.assertIsNotNone(m, "%s: job %s" % (name, job))
|
||||
return m.group(1)
|
||||
|
||||
def job_if(self, name, job):
|
||||
return re.search(r"(?m)^ if: (.*)$", self.job(name, job)).group(1)
|
||||
|
||||
def test_only_command_comments_start_runs(self):
|
||||
# Ordinary comments must not start a claim run or a verification re-run.
|
||||
self.assertIn("startsWith(github.event.comment.body, '/verified')", self.job_if("agent-pr-checks.yml", "verify"))
|
||||
self.assertIn("startsWith(github.event.comment.body, '/')", self.job_if("agent-claims.yml", "command"))
|
||||
self.assertNotIn("issue_comment", self.job_if("agent-pr-checks.yml", "check"))
|
||||
|
||||
def test_claim_jobs_share_one_group_and_replay(self):
|
||||
for job in ("command", "audit"):
|
||||
text = self.job("agent-claims.yml", job)
|
||||
self.assertRegex(text, r"group: agent-queue\n\s+cancel-in-progress: false", job)
|
||||
# Pending runs can be cancelled by newer ones, so every run replays unanswered commands.
|
||||
self.assertIn("agent_queue replay", text, job)
|
||||
self.assertIn("--recent-commands", text, job)
|
||||
self.assertNotIn("agent_queue decide", self.job("agent-claims.yml", "command"))
|
||||
|
||||
def test_verify_runs_one_at_a_time_per_pull_request(self):
|
||||
text = self.job("agent-pr-checks.yml", "verify")
|
||||
self.assertRegex(text, r"group: agent-verify-\$\{\{ github\.event\.issue\.number \}\}\n\s+cancel-in-progress: false")
|
||||
|
||||
def test_pr_check_is_advisory(self):
|
||||
# Exit status 1 (problems found) only warns until the live smoke test and issue migration.
|
||||
text = self.job("agent-pr-checks.yml", "check")
|
||||
found = re.search(r'if \[ "\$status" -eq 1 \]; then\n(.*?)\n\s+elif \[ "\$status" -ne 0 \]; then\n\s+exit "\$status"', text, re.S)
|
||||
self.assertIsNotNone(found, text)
|
||||
self.assertIn("::warning title=Agent PR check (advisory)::", found.group(1))
|
||||
self.assertNotIn("exit", found.group(1))
|
||||
self.assertEqual(text.count("exit "), 1)
|
||||
|
||||
def test_actions_pinned_by_sha(self):
|
||||
for name in QUEUE_WORKFLOWS:
|
||||
for use in re.findall(r"uses:\s*(\S+)", self.read(name)):
|
||||
|
||||
Reference in new issue
Block a user