From 7801c163e4135db09d6fa76e4590413d46aa4cef Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=A7=9A=E7=AB=A0=E6=B5=A9?= Date: Wed, 25 Nov 2026 17:06:51 +0800 Subject: [PATCH] =?UTF-8?q?feat(qa):=20=E9=AA=8C=E6=94=B6=E5=9B=9E?= =?UTF-8?q?=E6=89=A7=E5=86=99=E6=98=8E=E7=BB=93=E8=AE=BA=E4=B8=8E=E7=94=A8?= =?UTF-8?q?=E4=BE=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/candidate_coordinator.py | 23 ++++++++++++++++++++++- scripts/test_candidate_release.py | 12 ++++++++++++ 2 files changed, 34 insertions(+), 1 deletion(-) diff --git a/scripts/candidate_coordinator.py b/scripts/candidate_coordinator.py index 617d17e..633d3c0 100644 --- a/scripts/candidate_coordinator.py +++ b/scripts/candidate_coordinator.py @@ -164,6 +164,27 @@ def summon_qa(plan, target, body): cd.record(path, {'state': 'sent', 'result': result}) +def acceptance_body(sha, bundle, tasks, reports, url_of, links): + """State the registered verdict and its counts on the task itself, not only in metadata.""" + lines = ['批次验收通过', '', f'提交 `{sha}`', '', f'归档 `{bundle}`', ''] + single = len(tasks) == 1 + for item in tasks: + row, result = reports[item] + if single: + lines.append(f'必测 {result["required"]} · 通过 {result["passed"]} · 失败 {result["failed"]} ' + f'· 阻塞 {result["blocked"]} · 结论 {result["verdict"]}') + if result.get('url'): + lines.append(f'候选地址 {result["url"]}') + cases = result.get('cases') or {} + for group, label in (('business', '业务用例'), ('regression', '回归用例')): + if isinstance(cases.get(group), list) and cases[group]: + lines.append(f'{label}({len(cases[group])}):' + '、'.join(cases[group])) + else: + lines.append(f'{url_of(item)}#comment-{row["id"]}') + lines += ['', '需求验收与批次回归报告', links] + return '\n'.join(lines) + + def register(task_id): plan = owner_plan(task_id) directory = STATE / cd.acceptance_digest(plan) @@ -203,7 +224,7 @@ def register(task_id): 'register QA before the owner moves the release task to 待发布') sha, bundle = receipt['sha'], receipt['bundle'] links = '\n'.join(f'- {task(item)["url"]}#comment-{reports[item][0]["id"]}' for item in tasks) - body = f'批次验收通过\n\n提交 `{sha}`\n\n归档 `{bundle}`\n\n需求验收与批次回归报告\n{links}' + body = acceptance_body(sha, bundle, tasks, reports, lambda item: task(item)['url'], links) comment = add_comment(task_id, 'acceptance ' + bundle, body) acceptance = {'verdict': 'passed', 'sha': sha, 'bundle': bundle, 'evidence': rel['url'] + '#comment-' + comment} if cd.metadata(task(task_id), 'cd_acceptance') != acceptance: diff --git a/scripts/test_candidate_release.py b/scripts/test_candidate_release.py index ba8d910..32bae01 100644 --- a/scripts/test_candidate_release.py +++ b/scripts/test_candidate_release.py @@ -46,6 +46,18 @@ class CandidateReleaseTest(unittest.TestCase): with self.assertRaises(runtime.cd.CDError): runtime.qa_binding_key('image') + def test_acceptance_comment_states_counts_and_cases(self): + import candidate_coordinator as coordinator + result = {'required': 10, 'passed': 10, 'failed': 0, 'blocked': 0, 'verdict': 'passed', + 'url': 'http://127.0.0.1:32789', + 'cases': {'business': ['KB-01', 'KB-07'], 'regression': ['RG-01']}} + body = coordinator.acceptance_body('a' * 40, 'b' * 64, ['t'], {'t': ({'id': 'c'}, result)}, + lambda item: 'u', '- u#comment-c') + self.assertIn('必测 10 · 通过 10 · 失败 0 · 阻塞 0 · 结论 passed', body) + self.assertIn('业务用例(2):KB-01、KB-07', body) + self.assertIn('回归用例(1):RG-01', body) + self.assertIn('候选地址 http://127.0.0.1:32789', body) + def test_one_requirement_owns_its_own_release(self): plan = dict(self.plan, items=[{'task': TASK, 'commit': B}], extra=[A]) candidate.check_scope(plan, self.prs.__getitem__, [A, B])