返回资讯中心
外部精选
软件工程
#开发者实时流

开发者发布 GitHub Action,用后台 AI Agent 自动修复依赖更新引发的测试失败

来源标题:Show HN: A Background Agent to Fix Breaking Changes in Dependency Updates

GitHub Action arnaudrenaud/fix-with-agent 可在依赖更新导致测试套件失败时自动修复代码。该工具针对 Dependabot、Renovate 等自动更新机器人提交的 PR,在测试失败时触发 AI Agent 修复。审查和合并 PR 仍需人工完成。

Hacker News 最新frrdinand2026/11/17 · 今天12 分钟阅读

以下正文由 AI 翻译自 Hacker News 最新(原文版权归原站所有),可能存在偏差,重要内容请以原文为准。

使用 GitHub Action arnaudrenaud/fix-with-agent,在依赖更新导致测试套件失败时自动修复你的代码:

你是否依赖一套足够可靠的测试套件,以至于可以放心地盲目合并 Dependabot 或 Renovate 这类自动依赖更新机器人发来的 pull request?如果是,那你相比手动更新和回归测试,已经在节省时间了。

不过,你可能仍然积压着一批未合并的 pull request,因为大版本更新(有时甚至只是小版本更新……)带来了破坏性变更。

如今 AI 能帮助攻击者更快地利用漏洞,你最好也让 AI 帮你尽快打上补丁,并在这些年里跟上大版本升级的步伐。

当然,拉取出问题的分支,然后让本地 agent“在依赖更新后修复测试”,稍微盯一下应该就能搞定。

但这一操作仍会带来摩擦:

让我们把除最后两步之外的一切都自动化:审查和合并仍然由你来做。

既然 agent 的边界可以这样定义,就没必要手动编排它了:

每当依赖更新机器人提交的 pull request 上测试失败时:

下面是一个 Node.js、由 NPM 管理的项目的工作流示例:它使用 action arnaudrenaud/fix-with-agent 修复 Renovate pull request 中失败的测试。

name: "Fix breaking changes in Renovate PRs" on: workflow_run: workflows:

  • "Build and test" # TODO: Replace by the name of the workflow whose failure should trigger the action types:
  • completed branches:
  • "renovate/**" # TODO: Replace by the name pattern of the branches you want to monitor concurrency: group: fix-tests-${{ github.event.workflow_run.head_branch }} cancel-in-progress: true permissions: contents: write pull-requests: write actions: read jobs: fix-tests: name: Fix tests if: github.event.workflow_run.conclusion == 'failure' runs-on: ubuntu-latest steps:
  • name: Generate GitHub App token to re-trigger test run after fix is pushed

A push made with the default GITHUB_TOKEN would not trigger any CI check

id: app-token uses: actions/create-github-app-token@v3 with: client-id: ${{ secrets.AUTO_FIX_APP_CLIENT_ID }} private-key: ${{ secrets.AUTO_FIX_APP_PRIVATE_KEY }}

  • name: Checkout branch uses: actions/checkout@v5 with: ref: ${{ github.event.workflow_run.head_branch }} fetch-depth: 0 token: ${{ steps.app-token.outputs.token }}
  • name: Setup Node uses: actions/setup-node@v5 with: node-version: "22"
  • name: Install dependencies run: npm ci --ignore-scripts # Prevent a malicious update from, e.g., reading your secrets
  • name: Fix tests uses: arnaudrenaud/fix-with-agent@v1.0.1 with: success-check: npm run build && npm run test # TODO: Replace by your own success check failed-workflow-run-id: ${{ github.event.workflow_run.id }} branch: ${{ github.event.workflow_run.head_branch }} github-token: ${{ secrets.GITHUB_TOKEN }} task-description: >- Fix the failed test run, probably following a breaking change in a dependency upgrade in latest commit. If applicable, mention URLs of documentation and discussions that support the chosen fix. Do not delete or disable tests unless a test is obsolete because of this change, and explain why. commit-title: "fix(auto): ⚠️ Auto-fix tests following breaking change in dependency" add-prefix-to-pr: "⚠️ [auto-fixed] " # Optional arg: to discourage hasty merge after auto-fix, add a prefix to pull request title

TODO: Replace the following args by your own agent setup if you don't use claude

agent-install-command: npm install -g @anthropic-ai/claude-code agent-env: | CLAUDE_CODE_OAUTH_TOKEN=${{ secrets.CLAUDE_CODE_OAUTH_TOKEN }} agent-command: | # Agent command must be non-interactive and take stdin for its query claude
-p
--permission-mode bypassPermissions
--max-budget-usd 2.00
--output-format json agent-cost-attribute: total_cost_usd # Optional arg: in the agent's JSON output, attribute total_cost_usd will be read to report cost agent-timeout-minutes: 10

有了这个工作流,如果你的测试套件在 Renovate 的 pull request 之后失败,而 agent 设法修复了它,你会在该 pull request 中看到以下变化:

已发布一条评论,报告遇到的障碍和所做的决策(同一份报告也会出现在 commit 正文和 action 输出中):

这只是一个范围小、边界清晰的任务示例,可以用自主后台 agent 来完成。

让我们花点时间找出那些反复出现、定义明确的任务,它们可以在后台执行,既可以按固定计划,也可以在特定事件之后触发。这样,我们不仅能清掉任务的核心部分,还能卸下“收到通知、再腾出时间处理”的心理负担。

正文由 探How 从来源站点 RSS 同步,内容未经改写;遇到排版缺失或需要图片、视频时请以原文为准。

打开原文
去社区讨论 →