跳转至

用 Agent 保持 CI 绿色

三种方式可以让 OpenSRE 在首份报告之后继续处理你的 CI。它们都从演示选择器(opensre,或 shell 中的 /demo)或一个普通请求开始。

可靠性 Agent

演示选项 B,“设置一个随时间推移持续提升 CI/CD 可靠性的 Agent”,会将 CI 可靠性分析 变成针对单个仓库的定期检查。

set up an agent that improves CI/CD reliability for Tracer-Cloud/opensre
  • 它会立即分析该仓库,然后将报告安排在本地时间工作日 08:00 运行。后续运行将覆盖最近 7 天。
  • 报告会进入 shell 收件箱:/loops messages。该 Agent 从不会发布到 Slack 或其他聊天频道。
  • 使用 /loops list、/loops run <id>、/loops stop <id> 和 /loops delete <id> 管理它。
  • 循环会在 shell 打开时触发。/loops service install 会在你关闭终端后仍保持其运行(macOS 上为 launchd,Linux 上为 systemd;Windows 则从 Task Scheduler 使用 opensre cron start --service)。

修复循环

修复循环会监视一个 PR,针对其失败的 GitHub Actions 检查进行编辑、测试并推送修复,然后自行停止:

规则 值
触发条件 活动期间每 30 秒
尝试次数 最多三次失败修复尝试
时间预算 从调度起十分钟
目标 一个处于打开状态的 PR,其分支位于同一仓库中

通过仓库和 PR 编号来请求它:

schedule a CI repair loop for Tracer-Cloud/opensre pull request 6054

OpenSRE 会在循环启动前请求批准,因为循环会推送到 PR 分支。已关闭的 PR 或从 fork 打开的 PR 会在任何调度发生前被拒绝,并说明原因以及应改选什么。

在它运行期间以及完成后:

/loops show <task-id>     the report: outcome, attempts, evidence links
/loops stop <task-id>     stop an active repair
what did the most recent CI repair run do

已完成的运行会保留其报告和尝试记录,并移除其检出目录。在某个循环处于活动状态时再次请求同一个 PR,会返回该循环及其原始截止时间。

Note

想在不接触真实 PR 的情况下端到端地查看该循环?请求演示修复:OpenSRE 会创建一个名为 opensre-ci-repair-demo- 加四个字母或数字的小型私有仓库,打开一个带有失败检查的 PR,并对其进行修复。之后该仓库及其 PR 会保留下来。它需要一个可创建私有仓库的 GitHub token 以及一个已登录的编码 Agent。

托管服务

演示选项 C,“远程运行 CI/CD 修复”,会在贵组织的托管网关上运行同一个修复循环,而不是在你的机器上运行,因此它在 shell 关闭后仍会继续运行,并使用组织的 GitHub 凭据而不是你的凭据。

你需要:

  • 在 app.opensre.com 上的一个组织,并已从 Agent Backend 设置 配置好托管网关。
  • 组织的 GitHub token 已在 Web 应用的 Integrations 页面连接。网关会在一分钟内获取到更改后的 token。

然后,在 shell 中:

Check whether my organization's hosted gateway is running.
run the CI repair loop for Tracer-Cloud/opensre pull request 6054 on my org's hosted gateway
what did the most recent CI repair run on the gateway do

网关会在循环启动前通过 shell 请求批准,并在修复运行期间回答有关其循环的问题。有关启动和停止网关的信息,请参阅部署。

本页原文 Markdown:在 AtomGit 查看·内容源自开源项目 op/opensre