loop-on-ci

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Loop on CI

循环处理CI

Trigger

触发条件

Need to watch a branch or pull request and iterate on CI failures until all required checks are green.
Use
gh pr checks
as the source of truth. It includes all PR-attached checks, while
gh run list
only covers GitHub Actions.
需要监控分支或拉取请求(PR),反复处理CI失败项,直至所有必要检查全部通过。
gh pr checks
作为权威数据源。它包含所有与PR关联的检查,而
gh run list
仅覆盖GitHub Actions。

Workflow

工作流程

  1. Resolve the PR for the current branch.
  2. Inspect current PR checks before waiting.
  3. If checks already failed, diagnose those failures first.
  4. If checks are pending, watch with
    gh pr checks --watch --fail-fast
    .
  5. After each push, re-check the full PR check set and repeat until green.
  1. 解析当前分支对应的PR。
  2. 在等待前先检查当前PR的检查状态。
  3. 如果检查已失败,先诊断这些失败原因。
  4. 如果检查处于待处理状态,使用
    gh pr checks --watch --fail-fast
    进行监控。
  5. 每次推送后,重新检查完整的PR检查集,重复操作直至全部通过。

Commands

命令

bash
undefined
bash
undefined

Resolve the active PR

解析当前活跃的PR

gh pr view --json number,url,headRefName
gh pr view --json number,url,headRefName

Inspect all attached checks

检查所有关联的检查项

gh pr checks --json name,bucket,state,workflow,link
gh pr checks --json name,bucket,state,workflow,link

Watch pending checks and fail fast

监控待处理检查项并快速失败

gh pr checks --watch --fail-fast
gh pr checks --watch --fail-fast

GitHub Actions logs, when the failing check links to a GHA run

GitHub Actions日志,当失败检查项链接到GHA运行时使用

gh run view <run-id> --log-failed
undefined
gh run view <run-id> --log-failed
undefined

Guardrails

防护措施

  • Keep each fix scoped to a single failure cause when possible.
  • Do not bypass hooks (
    --no-verify
    ) to force progress.
  • If the failure is clearly unrelated to the PR and appears fixed on main, merge latest main instead of bloating the PR with unrelated fixes.
  • If failures are flaky, retry once and report flake evidence.
  • Re-run
    gh pr checks --json name,bucket,state,workflow,link
    after every push; the check set can change.
  • 尽可能将每个修复限定为单一失败原因。
  • 不要绕过钩子(
    --no-verify
    )来强行推进。
  • 如果失败明显与PR无关且在主分支上已修复,合并最新的主分支即可,不要在PR中添加无关修复内容。
  • 如果失败是偶发的,重试一次并报告偶发故障的证据。
  • 每次推送后重新运行
    gh pr checks --json name,bucket,state,workflow,link
    ;检查集可能会发生变化。

Output

输出

  • Current CI status
  • Failure summary and fixes applied
  • PR URL once checks are green
  • 当前CI状态
  • 失败总结及已应用的修复
  • 检查全部通过后的PR URL