|
|
|
@@ -201,8 +201,16 @@ def release_approval(task, timeline, request):
|
|
|
|
|
require(bool(changes), 'missing HiFox status history')
|
|
|
|
|
approval = changes[-1]
|
|
|
|
|
approver = approval.get('actor') or {}
|
|
|
|
|
event_at = approval.get('createdAt') or ''
|
|
|
|
|
status_at = task.get('statusChangedAt') or ''
|
|
|
|
|
try:
|
|
|
|
|
difference = abs((datetime.fromisoformat(event_at.replace('Z', '+00:00'))
|
|
|
|
|
- datetime.fromisoformat(status_at.replace('Z', '+00:00'))).total_seconds())
|
|
|
|
|
except (ValueError, TypeError):
|
|
|
|
|
difference = float('inf')
|
|
|
|
|
# HiFox logs the status change after saving the task, sometimes across a second boundary.
|
|
|
|
|
require((approval.get('metadata') or {}).get('to') == '待发布'
|
|
|
|
|
and approval.get('createdAt') and approval['createdAt'] == task.get('statusChangedAt')
|
|
|
|
|
and difference <= 2
|
|
|
|
|
and approver.get('id') == RELEASE_OWNER and approver.get('type') == 'human'
|
|
|
|
|
and matches(UUID, approval.get('id')), 'the latest transition must be an approval by the release owner')
|
|
|
|
|
task_url = task.get('url', '')
|
|
|
|
@@ -215,13 +223,13 @@ def release_approval(task, timeline, request):
|
|
|
|
|
require(len(reports) == 1, 'acceptance report missing from task history')
|
|
|
|
|
report = reports[0]
|
|
|
|
|
body = report.get('content') or ''
|
|
|
|
|
require(report.get('createdAt') and (report.get('updatedAt') or report['createdAt']) < approval['createdAt']
|
|
|
|
|
require(report.get('createdAt') and (report.get('updatedAt') or report['createdAt']) < min(event_at, status_at)
|
|
|
|
|
and request['sha'] in body and request['bundle'] in body,
|
|
|
|
|
'the unchanged report must identify the candidate and predate approval')
|
|
|
|
|
binding = {'approval_event': approval['id'], 'acceptance_digest': acceptance_digest(evidence)}
|
|
|
|
|
require(all(request.get(key, value) == value for key, value in binding.items()),
|
|
|
|
|
'HiFox approval or acceptance changed after dispatch')
|
|
|
|
|
return binding, approval['createdAt']
|
|
|
|
|
return binding, min(event_at, status_at)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def accepted_task(host, request):
|
|
|
|
|