跳转到内容

cnb-rs pr checks

cnb-rs pr checks <NUMBER>

列出指定 Pull Request 头 commit 的 CI 状态检查(在 CNB 里叫 commit-statuses,CLI 借用 gh pr checks 的命名让用户更直观)。Summary 行展示整体 state + sha + 各状态计数;表格展示每条 check 的 context / state / desc / url。

选项

  • <NUMBER>:PR 编号(必填)

继承的全局选项:

  • --repo <REPO>:指定仓库路径(格式:group/repo
  • --json:以 JSON 输出(含完整 CommitStatuses 对象)
  • --domain <DOMAIN>:指定目标域名(默认:cnb.cool

输出说明

Summary 行

PR #<N> CI 状态:<overall>(sha=<short_sha>) <state_counts>
  • <overall>:来自 CommitStatuses.state(CNB 聚合的整体状态)
  • <short_sha>CommitStatuses.sha 前 7 位
  • <state_counts>:按 state 桶计数,字典序,如 1 failure, 2 pending, 5 success

表格列

宽度说明
STATEfixed 10单条 check 的状态:success / pending / failure / error
CONTEXTflexcheck 的标识符(如 cnb/pull_request/ci-check
DESCflexcheck 的描述
URLflexcheck 详情链接

示例

bash
$ cnb-rs pr checks 271

PR #271 CI 状态:success(sha=f77df01) 2 success

STATE       CONTEXT                         DESC                  URL
success     cnb/pull_request/build-rust...  success [2m 5s]       https://cnb.cool/.../-/build/logs/...
success     cnb/pull_request/ci-check       success [2m 30s]      https://cnb.cool/.../-/build/logs/...

# JSON 给 CI 脚本消费
$ cnb-rs --json pr checks 271 | jq '.state'
"success"

# 等所有 check 通过再合(用 shell 轮询)
$ until cnb-rs --json pr checks 42 | jq -e '.state == "success"'; do sleep 30; done && cnb-rs pr merge 42 -t "ship it"

API 调用

步骤API方法说明
拉 CI 状态${API}/repos/{repo}/-/pulls/{n}/commit-statusesGETn 类型 i64,CLI 内部 parse

Known limitations

  • 不支持 --watch 定时轮询(gh pr checks 有此功能);要轮询请用 shell until ... done(见示例)
  • 当前不上色:success / pending / failure / error 都用同色文本展示。上色留到后续迭代

另请参阅

Released under the MIT License.