Compare commits

...

3 Commits

Author SHA1 Message Date
zheromiku 8c76c54d8e Merge pull request 'fix(deploy): 兼容 HiFox 确认事件跨秒写入' (#22) from fix/hifox-approval-timestamps into main
build / build (push) Successful in 1m28s
2026-11-23 03:03:32 +08:00
姚章浩 084ee1b176 fix(deploy): 兼容 HiFox 确认事件跨秒写入
build / build (push) Successful in 1m29s
任务更新时间与状态事件分别写入,允许小幅时间偏差。
仍以最近事件验证操作者,并要求验收证据早于两条时间记录。
2026-11-23 03:01:42 +08:00
zheromiku 71971e8164 Merge pull request 'feat(deploy): 接通 HiFox 待发布自动触发' (#21) from feat/hifox-release-trigger into main
build / build (push) Successful in 1m28s
2026-11-23 02:59:40 +08:00
2 changed files with 12 additions and 3 deletions
+11 -3
View File
@@ -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):
+1
View File
@@ -150,6 +150,7 @@ class ProductionCD(unittest.TestCase):
def test_hifox_dispatch_claims_one_transition(self):
task, timeline = self.hifox_fixture()
timeline[-1]['createdAt'] = '2026-11-22T18:00:01Z'
cd.atomic_write(self.root / 'active-since', b'2026-11-22T17:55:00Z\n')
with patch.object(trigger, 'hifox', side_effect=[task, timeline, task, timeline]), \
patch.object(trigger, 'forge', return_value={'workflow_run_id': 42}) as dispatch: