feat: 同步构建真实状态并支持在列表停止在途任务
- Gitea 运行未结束时探测作业级结论,修复前置作业失败后可复用工作流父作业/等待标签作业长期挂起导致状态永远构建中 - 打开我的构建/管理仪表盘时主动向构建平台同步在途任务状态;创建超 6 小时仍在途的任务判超时 - 构建中任务列表增加停止按钮(Gitea 需 1.28+ 取消 API,旧版本提示去运行页手动 Cancel),终态任务保留删除 - GitHub/Gitea 后端统一 cancel_run 接口
This commit is contained in:
@@ -75,6 +75,21 @@ class GitHubBackend(BuildBackend):
|
||||
return RunInfo(finished=False, status=data.get('status') or 'in_progress',
|
||||
html_url=data.get('html_url') or self.log_url(run_id))
|
||||
|
||||
# ---- 取消运行 ----
|
||||
def cancel_run(self, run_id, *, timeout=15):
|
||||
user = app_settings.get_value('GHUSER')
|
||||
repo = app_settings.get_value('REPONAME')
|
||||
url = f'{API}/repos/{user}/{repo}/actions/runs/{run_id}/cancel'
|
||||
try:
|
||||
resp = ghnet.post(url, token=app_settings.get_value('GHBEARER'), timeout=timeout)
|
||||
except Exception as e:
|
||||
raise BackendError(f'无法连接 GitHub 构建服务:{e}', kind='network')
|
||||
if 200 <= resp.status_code < 300:
|
||||
return
|
||||
if resp.status_code == 409:
|
||||
raise BackendError('该构建运行已经结束,无法取消。', kind='finished')
|
||||
raise BackendError(f'GitHub 拒绝了取消请求(HTTP {resp.status_code})。')
|
||||
|
||||
# ---- 日志链接 ----
|
||||
def log_url(self, run_id):
|
||||
if not run_id:
|
||||
|
||||
Reference in New Issue
Block a user