SuperAPI AI 工具集

flake

部署与运维

查看项目

更新于 10-15 20:21

技能介绍

Flake 是一个用于跟踪 Remotion CI 偶发失败(flake)的技能。当 Remotion 的 CI 检查失败且看起来是偶发问题时,或者被要求运行 /flake 时使用它。其跟踪 issue 为 https://github.com/remotion-dev/remotion/issues/8375。

用途

该技能的目标是把偶发的 CI 失败记录到 issue #8375,并让受影响的测试套件重新运行起来。对于每一个已确认或疑似偶发的失败,需要识别 PR、工作流运行、作业、失败步骤以及简洁的失败签名;然后更新 issue #8375:如果签名已存在,则递增其 Count;如果是新签名,则追加一行,包含计数 1、工作流/作业、首次出现日期和证据 URL;最后重新运行偶发作业或失败的作业。

查找失败

优先使用 gh,因为 GitHub 应用可能无法暴露所有 Actions 日志或写入权限。

如果用户提供了 PR,可运行: gh pr view <pr-number> --repo remotion-dev/remotion --json number,title,headRefName,statusCheckRollup gh pr checks <pr-number> --repo remotion-dev/remotion --watch=false

如果用户提供了工作流运行或作业 URL,可运行: gh run view <run-id> --repo remotion-dev/remotion --json databaseId,attempt,displayTitle,event,headBranch,headSha,status,conclusion,workflowName,createdAt,updatedAt,url,jobs gh api repos/remotion-dev/remotion/actions/jobs/<job-id>/logs

如果没有 PR 上下文,则检查最近打开的 PR 和最近的失败运行: gh pr list --repo remotion-dev/remotion --state open --limit 30 --json number,title,headRefName,statusCheckRollup gh run list --repo remotion-dev/remotion --workflow "Install and Test" --status failure --limit 20 --json databaseId,displayTitle,event,headBranch,headSha,conclusion,createdAt,url,workflowName

对于重跑尝试,在判断失败是否为偶发之前,先检查原始尝试: gh api repos/remotion-dev/remotion/actions/runs/<run-id>/attempts/1/jobs --paginate gh api repos/remotion-dev/remotion/actions/jobs/<failed-job-id>/logs

判定偶发失败

当至少满足以下一项时,将失败视为偶发:同一次运行、作业或失败步骤在未更改代码的情况下重跑后成功;失败与基础设施/网络相关,例如 fetch failed、连接重置、包管理器下载失败、缓存服务失败或运行器配置错误;测试失败是超时、竞态、浏览器断开、端口冲突或间歇性外部服务失败,且 PR 的更改不太可能触及该区域。

不要记录由源代码行为变更导致的确定性类型错误、lint 错误、快照或测试断言,除非有证据表明它们在重试后通过。

签名规则

使用稳定的签名来归并重复项,同时保持足够具体以便采取行动:在可用时包含包或套件,例如 @remotion/it-tests#testssr;在可用时包含测试名称;包含根错误文本,并去除时间戳、路径、随机 ID、端口、行号和 ANSI 代码;在工作流/作业列中单独包含工作流/作业,而不是放在签名内,除非需要消歧。

良好示例: oven-sh/setup-bun@v2.1.2 failed with TypeError: fetch failed delayRender() timeout while running Render video with browser instance not open in @remotion/it-tests#testssr

更新跟踪器

读取 issue 正文: gh issue view 8375 --repo remotion-dev/remotion --json body --jq .body

编辑完整的 issue 正文,保留表格。始终将替换用的 Markdown 写入临时文件并使用 --body-file;不要内联传递多行 Markdown。

表格格式:

Count Signature Workflow / job First seen Evidence
1 signature Workflow / Job YYYY-MM-DD https://github.com/remotion-dev/remotion/actions/runs/...

递增现有行时:除非证据链接失效或不如新链接有用,否则只更改 Count;保持 First seen 为已知最早日期。

追加新行时:尽可能使用 GitHub Actions 作业 URL;如果日志时间戳与本地机器日期不同,使用日志时间戳中的当前日期。

编辑后验证: gh issue view 8375 --repo remotion-dev/remotion --json body --jq .body

重新运行

优先只重跑失败的作业: gh run rerun <run-id> --repo remotion-dev/remotion --failed

如果只需要重跑一个已知的偶发作业且运行已完成: gh api --method POST repos/remotion-dev/remotion/actions/jobs/<job-id>/rerun

如果偶发套件仍在进行中且等待会阻塞任务,则中止该工作流运行,并在取消可见后重跑失败的作业: gh run cancel <run-id> --repo remotion-dev/remotion gh run watch <run-id> --repo remotion-dev/remotion --exit-status gh run rerun <run-id> --repo remotion-dev/remotion --failed

如果 gh run watch 因取消导致运行失败而以非零退出,继续重跑失败的作业。

汇报

总结:添加或递增的跟踪 issue 行;所采取的重跑操作,包括运行或作业 URL;以及任何被有意保留未处理的仍在运行的检查。

适用场景与限制

该技能适用于 Remotion 仓库 CI 出现偶发失败时的记录与恢复流程,依赖 gh 命令行工具和 GitHub Actions 日志。它不适用于由代码变更导致的确定性失败,也不应记录没有重试通过证据的断言类失败。