@@ -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:
|
||||
|
||||
@@ -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])
|
||||
|
||||
Reference in New Issue
Block a user