Repository navigation
ci: show live PR merge requirements - #427
Conversation
# ⭐ Feature - Refresh the existing welcome comment with live rules, team reviewers, approvals and required checks. - Relay all review state changes through an unprivileged Review Signal workflow and publish from trusted default-branch code. - Resolve fork workflow runs and serialize updates per PR without rewriting identical comments. # ✅ Tests - Cover eligible approvals, review dismissal, check sources, fork resolution and comment update behavior with Node.js tests. - Run the behavior tests in the existing pre-commit CI job and document API visibility limits. Co-authored-by: Codex <[email protected]>
|
Thanks for contributing to Relax, @SigureMo! 感谢你为 Relax 做出贡献! Contribution guide / 贡献指南Describe the problem, your changes, and how you validated them. Keep each PR focused and run 请说明问题、改动和验证方式,保持 PR 聚焦,并在提交前运行 CI commands / CI 指令
Put one command on the first line of a new PR comment. Rerun/cancel require PR authorship or repository write access. 在新 PR 评论的首行写一条指令。PR 作者或有仓库写权限的贡献者可以重跑、取消 CI。 |
Nyanpasu 审查看板审查状态: 🚧 需要修改 审查版本: d3c8da9 目标分支: main 第六轮审查完成(head d3c8da9):条件表收敛为审批人数、团队审批、CI 三行的删减复核为正确简化,维护文档同步一致,端到端渲染正常,CI 当前无失败。确认并发布 P1(F2):reviewQuery 在同一 GraphQL 查询中请求 mergeStateStatus 与 latestOpinionatedReviews 时后者恒返回空节点(本 PR 与仓库另 5 个 PR 复现,今日 ~12:05 UTC 前同查询尚正常;拆分为两个查询并行请求已验证可恢复),审批人数行在任何有 write 及以上权限用户 Approve 时失真为 0/1。已提交 REQUEST_CHANGES 并附行级评论与已验证的修复方案。
审查发现待处理
已解决或已取代
提交范围 · 接收 8 · 建议移出 0 · 待确认 0接收 8 个文件 · 建议移出 0 个文件 · 待确认 0 个文件。移出与待确认部分暂停深审,不代表审查通过。
精简审查与验证依据
生产代码的必要性与替代方案
测试的必要性与替代方案
Powered by Nyanpasu with glm-5.3-flash max, please check the suggestions carefully.
|
This comment was marked as spam.
This comment was marked as spam.
rai-studio-bot
left a comment
There was a problem hiding this comment.
审查结论:已完成,一条非阻塞精简建议
在 8501a1ad 上完成范围判定与常规审查:9 个文件全部接收(7 个自动化、1 个测试、1 个文档),无延期项。node --test .github/actions/pr-welcome/index.test.mjs 在 Node 24 实测 7/7 通过(与 Pre-commit Checks 中的 CI 接线一致);当前 CI 无失败。审批资格过滤、评论复用与无变化不写入、fork run 定位、bot 身份校验与并发推送防护均有测试覆盖;rulesets 与 classic branch protection 的读取边界处理一致,无法从 API 单独确认的条件均明确标注「GitHub 判定」。未发现阻塞缺陷,一条 P3 精简建议见行内评论;最终合入资格以 GitHub 为准。
| on: | ||
| pull_request_review: | ||
| types: [submitted, edited, dismissed] |
There was a problem hiding this comment.
非阻塞精简建议:目前 Review Signal 的唯一消费者是 Welcome Contributors。每个评审事件经中继会触发 3 个 workflow run(本信号 1 个 + 欢迎 in_progress/completed 各 1 个,共 5 个 job),其中 completed 那次通常重复加载同样的快照且不写入。若在 pr-welcome.yml 直接声明 pull_request_review: types: [submitted, edited, dismissed],同样的刷新行为只需 1 个 run(resolve + welcome 共 2 个 job);pullRequestNumbers 增加一个 pull_request_review 分支(直接取 context.payload.pull_request.number)即可,run.event 白名单里的 pull_request_review 与相应匹配路径也可移除。
若近期确有其他 workflow 计划订阅该信号(maintenance.md 已按信号总线记录该设计),保留现状也合理,以维护者取舍为准。
There was a problem hiding this comment.
笨啊,pull_request_review 能拿到 secrets 么?
There was a problem hiding this comment.
确实是我漏掉了这一点,该建议不成立,撤回。PR 来自 fork 时,pull_request_review 触发的运行按文档规则拿不到 GITHUB_TOKEN 之外的 secrets(且 GITHUB_TOKEN 只读):https://docs.github.com/en/actions/reference/workflows-and-actions/events-that-trigger-workflows。欢迎评论需要用 WELCOME_BOT_TOKEN 写入,而中继后的 workflow_run 运行在 base 仓库上下文、可以使用 secrets,从而让 fork PR 也能统一刷新。我的建议只对同仓库 PR 成立,无法覆盖外部贡献流程,是我错判了前提。
# 🐛 Bug Fix - Fold merge requirements into one details block alongside the guide and CI commands - Add summary emojis and render usernames as inline code without mentions - Summarize required CI and omit disabled review options and duplicate merge constraints - Keep unrecognized active rules visible and document the limits of API-based eligibility # ✅ Tests - Verify CI aggregation, unknown rules, disabled requirements and mention-free comments - Pass eight Node.js 24 behavior tests and all pre-commit checks Co-authored-by: Codex <[email protected]>
rai-studio-bot
left a comment
There was a problem hiding this comment.
审查结论:通过
增量提交 38ba9859 在已接受范围内重构了合入条件展示:合并状态汇总为「GitHub」一行、必需 CI 汇总为单行状态、用户名改为行内代码避免 @ 通知、未知规则类型保持可见、重复的团队审批条目去重,测试同步更新并新增对应断言;写入路径(评论复用、无变化不写入、身份校验、并发推送防护)与本提交未改动。上一轮的 P3 建议 F1 已按维护者指正撤回(fork PR 的 pull_request_review 运行拿不到自定义 secrets,中继设计保留),review-signal.yml 在本提交中未改动,与该结论一致。Node 24 实测 node --test .github/actions/pr-welcome/index.test.mjs 8/8 通过,当前 CI 无失败,未发现新的阻塞或非阻塞代码问题。
非行级 PR 描述小提示:描述中「预计评论样式」示例仍为重构前的渲染输出(双语行、必检 CI 明细表),可随新渲染更新或注明基于旧快照,避免与实际评论样式不一致。
# 🐛 Bug Fix - Show the contribution guide first, CI commands second and merge requirements last Co-authored-by: Codex <[email protected]>
rai-studio-bot
left a comment
There was a problem hiding this comment.
审查结论:增量重排已复核,维持通过
在 4331fbab 上完成第三轮增量审查:fix(ci): reorder welcome comment sections 仅将 .github/actions/pr-welcome/comment.md 的合入条件区块移到评论末尾(贡献指南、CI 指令在前),+2/-2,为纯展示层改动;{{mergeStatus}} 占位符与 Agents 注释位置正确,渲染与写入路径对区块顺序无结构依赖。9 个变更文件的范围判定不变(全部接收),无新增发现。
复核证据:Node 24 实测 node --test .github/actions/pr-welcome/index.test.mjs 8/8 通过;当前 CI 无失败;前两轮结论(F1 已按维护者指正撤回、无阻塞问题)在本头仍然成立。最终合入资格以 GitHub 为准。
# 🐛 Bug Fix - Restore the author mention in the greeting while keeping reviewer names in inline code - State the minimum approval count and repository write-access requirement - Remove merge-method guidance and footer links from the merge requirements block - Document the limits of per-condition status evaluation Co-authored-by: Codex <[email protected]>
# 🐛 Bug Fix - Report latest-push approval as pending when no eligible approval exists - Keep existing approvals unknown until GitHub confirms their push coverage and pusher relationship - Validate the missing-approval state alongside existing eligibility checks Co-authored-by: Codex <[email protected]>
rai-studio-bot
left a comment
There was a problem hiding this comment.
审查结论:两个增量提交已复核,维持通过
在 171573f 上完成第四轮增量审查(覆盖被范围变更中断的 5546b53d 与本次 171573f):
5546b53d:问候语改为@{{author}}提及作者(评论原位更新、首次创建仅通知一次;测试改为精确断言正文中唯一 mention 为@author,合入条件内的用户名仍保持行内代码不 ping);审批行标签注明「至少 N 位有仓库 write 或更高权限的人 Approve」,与authorCanPushToRepository过滤语义一致;允许合入方式行与页脚链接连同其计算一并移除,无悬挂引用,maintenance.md 已同步该取舍。171573f:最新推送审批行改为两态——无合格审批时⏳ 等待推送者以外的人 Approve(此时必然未满足,状态准确),已有合格审批时保持❔ GitHub 判定(审批是否覆盖最近一次可审推送、审批者与推送者关系均无法从 API 单独确认,交由 GitHub 判定是诚实的处理);两种状态均有测试覆盖,maintenance.md 同步。
复核证据:9 个变更文件范围判定不变(全部接收);Node 24 实测 node --test .github/actions/pr-welcome/index.test.mjs 8/8 通过;当前 CI 无失败。前几轮结论(F1 已撤回、无阻塞问题)在本头仍然成立。
一条非阻塞提示:PR 描述与示例评论仍是 10:09 版本,未同步这两个提交的渲染变化(问候语提及、合入方式行与页脚链接已移除、最新推送审批行在无审批时显示 ⏳);仓库内 maintenance.md 已与新行为一致,仅描述文本滞后,不影响合入判断。最终合入资格以 GitHub 为准。
# ♻️ Refactor - Read required CI contexts through GitHub GraphQL isRequired instead of manually matching check apps and commit status sources. - Share GraphQL connection pagination and remove catch-all API fallbacks. - Keep explicit handling for absent classic branch protection and inaccessible Team membership. # 🔩 Chore - Remove the welcome test file, its CI step and its documented invocation. Co-authored-by: Codex <[email protected]>
# 🐛 Bug Fix - Read the head branch activity actor and timestamp, and include review commit and submission time. - Show satisfied latest-push approval for a qualified current-head review submitted after a linear code-changing push by a different actor. - Keep merge-containing and force pushes for GitHub to determine. - Document the supported approval check and its API evidence. Co-authored-by: Codex <[email protected]>
rai-studio-bot
left a comment
There was a problem hiding this comment.
审查结论:4522db42 重构复核通过,维持通过
第五轮增量审查覆盖 4522db42(refactor(ci): simplify welcome merge status):
- 数据源重写:
merge-status.mjs改用 GraphQLstatusCheckRollup.contexts+isRequired(pullRequestNumber)——必需检查直接由 GitHub 对该 PR 判定并过滤,替代旧的双 REST 调用与本地名称/app 匹配。实测该字段在真实 API 上存在且标志正确(必需检查为 true、bypass/信号类检查为 false);ciStatus优先取 test merge commit 上的同名 context,缺失视为 pending,失败优先于通过。classic 分支保护经classicRules归一,本仓库无 classic 保护(404 → 空规则)已实测;Team 读取 403/404 显式降级为提示行;其余 API 错误改为刷新失败,属 maintenance.md 已记录的取舍。 - 端到端实测:以与 action 相同权限档位的真实 token 走通
loadMergeStatus+renderMergeStatus全链路,当前 PR 输出为 审批 ✅ 1/1(DrRyanHuang)、团队relax-block-reviewers⏳ 0/1(含可联系成员)、最近一次推送审批 ❔、CI ✅ 已通过、整体 ⏳ 合入条件未满足——与规则集要求(团队审批 1、dismiss stale reviews、last-push approval)及mergeStateStatus=BLOCKED一致,六种规则类型均在处理清单内,无多余 ❔ 行。 - 周边:
ci.yml净变更为 Pre-commit job 增加permissions: contents: read权限加固;maintenance.md与新语义一致;index.mjs、评论模板与 workflow 本轮未改动。
一条非阻塞提示:本轮删除了 index.test.mjs(8 个在上一 head 全部通过的用例)与对应 CI 步骤。其中覆盖 index.mjs 写入防护(bot 身份不匹配、并发推送后重新定位、内容相同不写入)与 fork 匹配的用例针对的是本轮未改动的代码,删除后这些路径与新的 ciStatus 逻辑不再有自动化回归保护,仅剩部署默认分支后的人工验证(显示层改动、下次事件重渲染自愈,故非阻塞)。如后续改动这些路径,建议恢复防护类用例——它们不依赖本次重写的内部实现。
CI 当前无失败(head 4522db42)。前几轮结论(F1 已被后续变更取代、无阻塞问题)在本头仍成立。最终合入资格以 GitHub 为准。
# ♻️ Refactor - Limit the welcome requirement table to approval count, required Team approvals and CI. - Put the minimum approval count and write-access requirement in the status column, and label Team approvals explicitly. - Keep requests for changes in the approval-count row. - Remove latest-push, review-thread and unused rule rendering logic together with their API queries and fields. - Update CI maintenance documentation to match the displayed scope. Validation: pre-commit, Node.js 24 syntax and actual API/GitHub Markdown rendering checks passed. Co-authored-by: Codex <[email protected]>
rai-studio-bot
left a comment
There was a problem hiding this comment.
需要修改
本轮(head d3c8da9)复核了条件表收敛为审批人数、团队审批、CI 三行的删减:方向正确,维护文档已同步,端到端渲染正常,CI 当前无失败。但存在一个阻塞缺陷:merge-status.mjs 的 reviewQuery 在同一 GraphQL 查询中同时请求 mergeStateStatus 与 latestOpinionatedReviews,在 GitHub 当前服务端行为下后者恒返回空节点,审批人数行会在任何有 write 及以上权限用户 Approve 时失真为 0/1——这恰好是收敛后表格的核心行。修复方案(拆分查询并行请求)已在本 PR 验证有效,详见行级评论。
| const reviewQuery = `query($owner: String!, $repo: String!, $number: Int!, $cursor: String) { | ||
| repository(owner: $owner, name: $repo) { | ||
| pullRequest(number: $number) { | ||
| headRefOid baseRefName mergeable mergeStateStatus |
There was a problem hiding this comment.
mergeStateStatus 与 latestOpinionatedReviews 同时出现在一个 GraphQL 查询中时,后者恒返回空节点(GitHub 当前服务端行为)。reviewQuery 同时请求两者,因此 latestOpinionatedReviews.nodes 恒为空,审批人数行在任何有 write 及以上权限用户 Approve 的 PR 上都会显示 ⏳ 0/1,且已审批人列表不会出现;团队审批与 CI 两行不受影响。
复现与证据(均为今日真实 API 实测):
- 用本模块 reviewQuery 原样查询本 PR 返回
reviews: [];仅删去mergeStateStatus的同一查询返回 1 条APPROVED(rai-studio-bot,authorCanPushToRepository: false)。 - 同样复现于仓库其余 5 个 PR(426/425/423/407/404);今日 ~12:05 UTC 前同一查询仍正常,属 GitHub 行为变化而非本 PR 数据特例。
建议把状态字段与审批分页拆成两个查询并行请求(已在本 PR 验证可恢复正常输出):
const stateQuery = `query($owner: String!, $repo: String!, $number: Int!) {
repository(owner: $owner, name: $repo) {
pullRequest(number: $number) {
headRefOid baseRefName mergeable mergeStateStatus
potentialMergeCommit { oid }
}
}
}`
const reviewQuery = `query($owner: String!, $repo: String!, $number: Int!, $cursor: String) {
repository(owner: $owner, name: $repo) {
pullRequest(number: $number) {
latestOpinionatedReviews(first: 100, after: $cursor) {
nodes { author { login } authorCanPushToRepository state }
pageInfo { hasNextPage endCursor }
}
}
}
}`
const [stateResult, reviewResult] = await Promise.all([
github.graphql(stateQuery, variables),
readConnection(
github,
reviewQuery,
variables,
(data) => data.repository.pullRequest.latestOpinionatedReviews
),
])
const state = { ...stateResult.repository.pullRequest, ...reviewResult.data.repository.pullRequest }
const reviews = reviewResult.nodesstate.headRefOid/state.baseRefName 的过期校验(下方 PR changed while collecting reviews.)与 state.potentialMergeCommit 的使用不受拆分影响;mergeStateStatus 仅用于整体状态行文案,可一并迁入 stateQuery。
…er-profiler Brings in upstream/main 653c43c..dce533b (redai-studio#257, redai-studio#258, redai-studio#285, redai-studio#323, redai-studio#330, redai-studio#335, redai-studio#408, redai-studio#409, redai-studio#412, redai-studio#414, redai-studio#416, redai-studio#417, redai-studio#419-redai-studio#421, redai-studio#424, redai-studio#426, redai-studio#427, redai-studio#430, and 42 commits synced on 10-12 without PR numbers). The only conflict is relax/utils/env.py: cc4b052 adds the DeepSeek-V4 MXFP4 QAT variables at the same spot where this branch adds the straggler profiler variables. Resolved by keeping both blocks, straggler first.


What
复用 welcome bot,在原有贡献指南和 CI 指令旁增加一个「🔎 合入条件」
<details>。所有折叠标题加 emoji;欢迎语 mention 作者,审批区域的用户名使用反引号包裹。条件表仅展示「审批人数」「团队审批(relax-block-reviewers)」「CI」三类。审批人数的最低要求和仓库 write 或更高权限要求放在右侧状态列;修改意见也并入这一行。指定 Team 尚未审批时列出可联系成员,满足后显示已审批者。CI 仅显示整体是否通过。Approve、Request changes、撤销审批、PR 更新和 CI 状态变化都会原位刷新同一条评论。Why
Team 审批门禁会阻止合入,但贡献者不容易知道该找谁审批。评论需要根据当前规则和 Team 成员明确展示要求,同时保持欢迎评论简洁。
How
Review Signal,监听pull_request_review的submitted、edited、dismissed,权限为空。其他 workflow 可通过workflow_run订阅;welcome 同时监听CI、GPU Unit Tests、Integration Tests的开始和结束。WELCOME_BOT_TOKEN并核对账号身份;内容不变时不写入,发布前再次校验 PR head/base。read:org,或细粒度 token 的 Members read 权限。isRequired(pullRequestNumber)标记,省去手工比对检查来源;同名检查优先使用 test merge 结果,缺失的必需检查保持等待。非预期 API 错误直接让刷新失败,仅保留未配置 classic branch protection、Team 权限不足的处理。API 覆盖范围
分页调用
GET /repos/{owner}/{repo}/rules/branches/{branch}获取目标分支全部 active rules,包含仓库和组织层级;另查 classic branch protection。接口的范围见 GitHub 文档。规则读取是全量;评论只逐项展示审批人数、团队审批和 CI。行名称与状态映射由脚本实现,最低人数、write 资格、Team 成员、审批状态和必需检查使用当前 API 数据。其余条件由 GitHub 的整体合入状态体现。
条件式 Team 文件匹配尚未实现完整的逐项判定,团队行显示“GitHub 判定”。
整体状态使用 GraphQL
mergeStateStatus,最终合入资格及 bypass 权限以 GitHub 合入区域为准。Testing
pre-commit run --all-files全部通过;actionlint v1.7.12 校验修改后的 CI workflow 通过。rai-studio-botgh 凭据,对 ci: show live PR merge requirements #427 调用实际读取/渲染逻辑生成只读预览,并用 GitHub Markdown API 校验折叠块、表格和用户名渲染。未运行 Python/GPU/NPU 集成测试:本次仅修改 GitHub 自动化,没有训练代码变更。端到端 review 信号和 bot 评论发布需要合入默认分支后验证。
Type of Change
Screenshots / Logs — 预计评论样式
以下由本 PR 的实际模板和渲染逻辑对 #427 生成,快照时间为
2026-10-10T20:28:31+08:00,head 为d3c8da9。后续审批和 CI 变化会刷新状态。Thanks for contributing to Relax, @SigureMo! 感谢你为 Relax 做出贡献!
📚 Contribution guide / 贡献指南
Describe the problem, your changes, and how you validated them. Keep each PR focused and run
pre-commit run --all-filesbefore submitting.请说明问题、改动和验证方式,保持 PR 聚焦,并在提交前运行
pre-commit run --all-files。English contribution guide · 中文贡献指南
🛠️ CI commands / CI 指令
/rerun/rerun <target>/cancel <workflow>/help/reviewPut one command on the first line of a new PR comment. Rerun/cancel require PR authorship or repository write access.
在新 PR 评论的首行写一条指令。PR 作者或有仓库写权限的贡献者可以重跑、取消 CI。
CI usage and targets · CI 用法与 target
🔎 Merge requirements / 合入条件
GitHub:⏳ 合入条件未满足
write或更高权限的人 Approverelax-block-reviewers)Aurelius84,Yangruipis,yuanlehome,NINGBENZHE当指定 Team 的有效成员 Approve 后,团队行变为
✅ 1/1,用反引号显示已审批者,并收起候选人名单。CI 保留一行整体状态。