Skip to content

fix(ci): allow command replies on pull requests - #401

Merged
SigureMo merged 1 commit into
redai-studio:mainfrom
ShigureNyako:session/sess_dev_neko_fix_relax_workflow_pull_requests_write_permissio
Oct 1, 2026
Merged

SigureMo merged 1 commit into
redai-studio:mainfrom
ShigureNyako:session/sess_dev_neko_fix_relax_workflow_pull_requests_write_permissio

Conversation

@ShigureNyako

Copy link
Copy Markdown
Contributor

What

仅修改 .github/workflows/ci-commands.yml 的一行,将 pull-requests: read 改为 pull-requests: write,使 CI 评论指令的内置 GITHUB_TOKEN 具备创建和更新 PR 回复所需的权限。

Why

Relates to #400、#393。按 #400 中的维护者要求 单独提交修复,不修改测试 PR #400 或无关 PR #399。

#400 的 T02~T05 在发布初始回复时返回 403 Resource not accessible by integration,尚未进入 help、rerun 或 cancel 的主体逻辑。已读取 T02 失败 job 的实际日志:运行的是默认分支 e36db4b44afe6ac94283b3bd0a66ddc64591f1fe,实际权限为 Issues: write、PullRequests: read,失败位置为 .github/actions/ci-commands/index.mjs:72,请求为 POST /repos/redai-studio/Relax/issues/400/comments。T03 的 未知 target run 也有相同失败。创建前检查了现有开放 PR 与权限/CI 命令相关 PR,未发现等价修复。

How

  • 保留现有 actions: write、contents: read、issues: write,仅提升 PR 权限,不使用 write-all。
  • CI Commands 只有 command 一个 job,现有 workflow 级声明仅作用于该 job;无需引入覆盖其余权限的 job 级声明或修改其他 workflow。
  • 保持 issue_comment.created、PR 条件、默认分支 checkout、persist-credentials: false、授权校验和去重逻辑不变,不执行 PR head 的代码。
  • composite action 使用 actions/github-script@v8 默认的内置 GITHUB_TOKEN,不是欢迎评论所用的 WELCOME_BOT_TOKEN。不修改仓库/组织设置、secrets、token 配置或运行时代码。

Testing

  • uv run --no-project --python 3.10 --with pre-commit pre-commit run --all-files --show-diff-on-failure:全部 hooks 通过,未跳过检查。系统 Python 3.14 首次运行因既有 docformatter==1.3.1 构建时访问 Constant.s 失败,改用仓库 CI 的 Python 3.10 后通过;未修改依赖或 hook 配置。
  • actionlint 1.7.12:默认分支原文件和修改后的 .github/workflows/ci-commands.yml 均通过。
  • PyYAML 结构回归断言通过:与 origin/main 相比仅 permissions.pull-requests 从 read 变为 write,其他权限、事件、唯一 job、默认分支 checkout 及内置 token 边界不变。
  • git diff --check 通过;diff 仅一个文件、一行替换。

这只是权限声明与静态回归验证,尚未证明线上 PR 回复写入成功。issue_comment 使用默认分支 workflow,本 PR 的普通 CI 或本地检查不能验证合入后的实际 token 权限;仍需部署到默认分支后在获授权的测试 PR 上重新验证 T02~T05 及被阻塞的后续用例。本次未发布测试指令、重跑 CI 或修改 #400。未运行 pytest tests/(无 Python/训练逻辑变更);GPU/NPU 集成测试需要专用多节点硬件,本地不具备,未执行。

  • pre-commit run --all-files passes
  • Tests pass (pytest tests/)
  • New tests added (if applicable)
  • Documentation updated (if applicable)

新持久化测试及文档更新不适用于这一行声明修复;使用静态结构断言验证变更边界。

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Documentation update
  • Refactoring (no functional changes)
  • Performance improvement
  • CI/CD or build changes

Screenshots / Logs

T02 测试记录 · 首轮测试汇总

失败 job 中的关键日志:

GITHUB_TOKEN Permissions
  Actions: write
  Contents: read
  Issues: write
  PullRequests: read
RequestError [HttpError]: Resource not accessible by integration
  at async run (.../.github/actions/ci-commands/index.mjs:72:27)
  status: 403
  url: 'https://api.github.com/repos/redai-studio/Relax/issues/400/comments'

# 🐛 Bug Fix

- Grant pull-requests write permission to the CI Commands workflow's
  built-in GITHUB_TOKEN for creating and updating PR command replies.
- Preserve existing Actions, contents and issues permissions and trusted
  default-branch execution; no action logic or other workflow changes.
- Address the initial reply 403 observed during Relax redai-studio#400 smoke tests.
@rai-studio-bot

Copy link
Copy Markdown
Contributor

Thanks for contributing to Relax, @ShigureNyako! 感谢你为 Relax 做出贡献!

Contribution guide / 贡献指南

Describe the problem, your changes, and how you validated them. Keep each PR focused and run pre-commit run --all-files before submitting.

请说明问题、改动和验证方式,保持 PR 聚焦,并在提交前运行 pre-commit run --all-files。

English contribution guide · 中文贡献指南

CI commands / CI 指令
Command / 指令 Usage / 用途
/rerun Retry failed CI / 重跑失败的 CI
/rerun <target> Rerun a workflow or check / 重跑指定 workflow 或检查
/cancel <workflow> Cancel an entire workflow / 取消整个 workflow
/help Show commands and targets / 查看指令和 target
/review Request a code review / 请求代码 review

Put 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

@SigureMo SigureMo added the ci-bypass: all Exempt all configured CI workflows when applied by the CI team label Oct 1, 2026
@rai-studio-bot

rai-studio-bot commented Oct 1, 2026 •

Copy link
Copy Markdown
Contributor

Nyanpasu 审查看板

审查状态: ✅ 已通过

审查版本: 19ca869

目标分支: main

评审完成:PR #401 将 `.github/workflows/ci-commands.yml` 的 `pull-requests` 权限由 `read` 提升为 `write`。已从 T02/T03 失败 run 的实际日志确认根因(`issues.createComment` 在 PR 会话上 403,当时 token 已有 `issues: write` 而 `pull-requests: read`),并以本仓库 `remove-ci-bypass-labels.yml`(仅 `pull-requests: write`)成功执行 issues API 写入为对照,证明该权限即 PR 会话写入的正确作用域且在本仓库可正常授予。变更最小、与维护者要求一致,无已确认缺陷,结论:通过。合入后仍需按作者计划在授权测试 PR 上复验 T02~T05。

审查阶段进度范围与结果
常规审查 ✅ 已完成 已完整核对 PR 描述、单一文件 diff、CI Commands composite action 调用链(index.mjs:72/84 的 createComment/updateComment)、失败 run 日志与实际授权 scope、同仓库对照 workflow、CI 状态与仓库测试/文档覆盖面。未发现缺陷。
深度审查 ✅ 已完成 独立设计跳过(机械性单行修正,见评审计划);生产与测试必要性审计由主评审直接完成:生产结论 retain(该行即修复本身,备选方案均被证据排除),测试无适用范围(diff 无测试文件;线上复验为仓库规定机制并已列入作者计划)。

没有未解决的审查问题。

提交范围 · 接收 1 · 建议移出 0 · 待确认 0

接收 1 个文件 · 建议移出 0 个文件 · 待确认 0 个文件。移出与待确认部分暂停深审,不代表审查通过。

文件结论仓库维护必要性依据替代去向或方案
.github/workflows/ci-commands.yml
接收 The one-line permission elevation is the production fix itself: the CI Commands workflow is the deployed implementation that must reply to PR command comments, and its default-branch copy must ship this change for the 403 to be fixed. Maintainer request in #400 (https://github.com//pull/400#issuecomment-5938149162); failing T02-T05 runs show POST /repos//issues/400/comments returning 403 at .github/actions/ci-commands/index.mjs:72 with Issues: write and PullRequests: read granted (https://github.com/redai-studio/Relax/actions/runs/36906922608/job/110519677043). An external experiment or evidence-only artifact cannot change the deployed workflow permission; no smaller repository change implements the required reply behavior.
精简审查与验证依据
审查范围进度结论
生产代码 ✅ 已完成 检查范围:变更的 `pull-requests` 权限行。结论 retain:`issues: write` 单独不足以授权 PR 会话写入(T02~T05 实测 403);`write-all`、PAT/bot token、job 级声明等备选均被排除;移除现有 `issues: write` 属合入后可选优化,合入前不可证明安全。
测试 ➖ 无需执行 diff 中无测试文件,仓库也无针对 .github/workflows 权限声明的既有测试面;按仓库维护指引(skills/relax-github-ci/references/maintenance.md),此类修复以合入后在草稿 PR 上线上复验为机制,作者已计划复跑 T02~T05。

生产代码的必要性与替代方案

范围必须保留的契约更简单的方案结论依据与限制
`.github/workflows/ci-commands.yml` 的 `pull-requests` 权限声明 issue_comment.created 触发的 command job 必须通过 `.github/actions/ci-commands/index.mjs:72/84` 创建并更新 PR 会话评论;调用方为使用 /help、/rerun、/cancel 的 PR 评论者 仅保留 issues: write(实测 403);write-all(过度授权);改用 WELCOME_BOT_TOKEN 类 PAT(额外 secret 面,且无需);job 级 permissions(单 job 等价);移除 issues: write(合入前不可证明安全且超出最小修复范围) 保留 失败 run 36906922608 / 36906988761:token 实际持有 Issues: write + PullRequests: read 仍 403,响应头 `x-accepted-github-permissions: issues=write; pull_requests=write`;对照 `.github/workflows/remove-ci-bypass-labels.yml` 仅声明 pull-requests: write 即成功对同一 PR 会话执行 issues.removeLabel(run 36908195148 成功,T15 记录确认 4 个标签全部移除)。局限:createComment 路径需合入默认分支后线上复验(issue_comment 结构上只运行默认分支 workflow 文件)。
Powered by Nyanpasu with glm-5.3[1m] xhigh, please check the suggestions carefully.

@SigureMo SigureMo removed the ci-bypass: all Exempt all configured CI workflows when applied by the CI team label Oct 1, 2026

@rai-studio-bot rai-studio-bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

评审结论:通过(APPROVE)

PR #401 将 .github/workflows/ci-commands.yml 的 pull-requests 权限由 read 提升为 write,是修复 CI 指令在 PR 上回复 403 的正确且最小的变更。已核实根因:T02/T03 失败 run 的实际日志显示 token 持有 issues: write + pull-requests: read 时,issues.createComment(.github/actions/ci-commands/index.mjs:72)对 PR 会话写入仍返回 403,响应头 x-accepted-github-permissions: issues=write; pull_requests=write;同仓库 remove-ci-bypass-labels.yml 仅声明 pull-requests: write 即成功对同一 PR 会话执行 issues API 写入(run 36908195148),证明该权限在本仓库可正常授予且为 PR 会话写入的正确作用域。变更仅一行一文件,事件触发、默认分支 checkout、授权校验与去重逻辑均未改动;issues.updateComment 属同一权限族,同步被覆盖。无缺陷发现。合入后请按 PR 描述计划在授权测试 PR 上复验 T02~T05(issue_comment 结构上只运行默认分支 workflow 文件,合入前无法线上验证)。

完整评审看板:#401 (comment)

Powered by Nyanpasu with glm-5.3[1m] xhigh, please check the suggestions carefully.

@SigureMo
SigureMo merged commit 9b57fe6 into redai-studio:main Oct 1, 2026
22 of 29 checks passed
Mukayi added a commit to Mukayi/Relax that referenced this pull request Oct 4, 2026
…er-profiler

Brings in upstream/main 99a0b6a..653c43c (redai-studio#302, redai-studio#392-redai-studio#396, redai-studio#398, redai-studio#401,
redai-studio#403, redai-studio#405).

The only conflict is the guide sidebar in docs/.vitepress/config.mts:
redai-studio#398 reformatted it with oxfmt (trailing commas, long entries split), and
this branch adds the "Straggler Analysis" / "Straggler 分析" entries next
to the same lines. Resolved by taking upstream's formatting and keeping
the two straggler entries in their previous position.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants