Skip to content

ci: PR 阶段格式检查并在合并后修复 - #515

Draft
Craun718 wants to merge 6 commits into
AUTO-MAS-Project:devfrom
Craun718:patch-fmt
Draft

ci: PR 阶段格式检查并在合并后修复#515
Craun718 wants to merge 6 commits into
AUTO-MAS-Project:devfrom
Craun718:patch-fmt

Conversation

@Craun718

@Craun718 Craun718 commented Sep 1, 2026

Copy link
Copy Markdown
Member
  • PR 阶段新增 Format Check,执行 Ruff、前端格式和 Markdown 检查。
  • PR 合并进 dev 后由 Format Fix 自动格式化并写回 dev。
  • 格式检查保持只读权限,自动修复工作流单独申请写权限。

Sourcery 摘要

统一整个项目的格式检查,并为 dev 自动化合并后的修复。

新功能:

  • 为 Python、前端代码和 Markdown 添加拉取请求格式检查,并仅授予仓库只读权限。
  • 自动格式化合并到 dev 的更改,并将修复内容写回该分支。

改进:

  • 使用 oxlint 和 oxfmt 替换前端 ESLint 和 Prettier 配置,并添加 Markdown lint 配置和脚本。

CI:

  • 将只读格式验证与启用写入权限的合并后格式化工作流分开。

文档:

  • 更新前端格式化和 lint 文档,以反映 oxlint 和 oxfmt。

维护:

  • 移除过时的 ESLint、Prettier 和编辑器配置,并更新前端依赖项。
Original summary in English

Sourcery 摘要

统一项目格式检查,并在更改合并到 dev 后自动执行修复。

新功能:

  • 添加针对 Python、前端和 Markdown 格式与代码检查的只读拉取请求检查。
  • 自动格式化合并到 dev 分支的更改,并将修复内容写回该分支。

增强功能:

  • 将验证与可写入的自动格式化分离,确保拉取请求检查保持只读。
  • 使用 oxlint、oxfmt 和 Markdown linting 替换前端格式化与代码检查配置。

构建:

  • 更新前端依赖,并移除已过时的 ESLint、Prettier 和编辑器配置。

CI:

  • 将定时格式化替换为针对 dev 的合并后格式化工作流,并添加拉取请求格式检查工作流。

文档:

  • 更新前端格式化与代码检查文档,以适配新工具。
Original summary in English

Sourcery 总结

添加只读的拉取请求格式验证,并在变更合并到 dev 后自动修复格式。

新功能:

  • 为 Python、前端和 Markdown 格式添加只读的拉取请求检查。
  • 在变更合并到 dev 分支后自动格式化,并将修复结果写回该分支。

增强功能:

  • 将验证与启用写入的自动格式化分离,以确保拉取请求检查保持只读。
  • 使用 oxlint 和 oxfmt 替换前端代码检查和格式化工具链,并添加 Markdown 代码检查。

构建:

  • 更新前端工具依赖,并移除弃用的 ESLint、Prettier 和编辑器配置。

CI:

  • 使用合并后 dev 格式化工作流替换定时格式化,并添加拉取请求格式检查。

文档:

  • 更新前端格式化和代码检查文档,以适配新工具。
Original summary in English

Sourcery 摘要

标准化项目格式检查,并自动修复 dev 分支合并后的格式问题。

新功能:

  • 添加针对 Python、前端和 Markdown 格式与代码检查的只读拉取请求检查。
  • 自动格式化合并到 dev 分支的更改,并将修复结果写回该分支。

改进:

  • 使用 oxlint 和 oxfmt 替换前端 ESLint 和 Prettier 工具链,并添加 Markdown 检查支持。
  • 将只读验证与支持写入的合并后格式化分离,以保护拉取请求检查。

构建:

  • 更新前端格式化和代码检查依赖,并移除过时的 ESLint、Prettier 和编辑器配置。

持续集成:

  • 使用合并后 dev 格式化工作流替换定时格式化,并添加拉取请求格式检查工作流。

文档:

  • 更新前端格式化和代码检查文档,以适配 oxlint 和 oxfmt。
Original summary in English

Summary by Sourcery

Standardize project formatting checks and automate post-merge fixes for the dev branch.

New Features:

  • Add read-only pull request checks for Python, frontend, and Markdown formatting and linting.
  • Automatically format merged changes on the dev branch and write fixes back to the branch.

Enhancements:

  • Replace the frontend ESLint and Prettier toolchain with oxlint and oxfmt, and add Markdown linting support.
  • Separate read-only validation from write-enabled post-merge formatting to protect pull request checks.

Build:

  • Update frontend formatting and linting dependencies and remove obsolete ESLint, Prettier, and editor configuration.

CI:

  • Replace scheduled formatting with a post-merge dev formatting workflow and add a pull request format-check workflow.

Documentation:

  • Update frontend formatting and linting documentation for oxlint and oxfmt.

@sourcery-ai

sourcery-ai Bot commented Sep 1, 2026

Copy link
Copy Markdown

审查者指南

该 PR 新增 PR 阶段的只读格式检查,覆盖 Python、前端代码和 Markdown,并将原定时格式化改为 dev 合并后的独立写权限自动修复流程;同时将前端格式与 lint 工具从 ESLint/Prettier 迁移到 oxlint/oxfmt,并加入 Markdownlint 及对应配置。

PR 格式检查与合并后修复的时序图

sequenceDiagram
    participant PR as PullRequest
    participant Check as FormatCheckWorkflow
    participant Repo as Repository
    participant Fix as FormatFixWorkflow

    PR->>Check: opened / synchronize / reopened
    Check->>Repo: actions/checkout
    Check->>Check: ruff format --check .
    Check->>Check: yarn oxfmt . --check
    Check->>Check: yarn lint:md
    PR->>Fix: merged into dev
    Fix->>Repo: checkout dev
    Fix->>Fix: yarn format
    Fix->>Fix: yarn lint:md:fix
    Fix->>Repo: commit and push formatting changes
Loading

文件级变更

变更 详情 文件
为 PR 增加只读的多语言格式检查流水线,并通过并发控制取消过时检查。
  • 在 PR 创建、更新和重新打开时运行检查
  • 使用 Ruff 检查 Python 格式,使用 oxfmt 和 Markdownlint 检查前端
  • 固定 Python、Node、Ruff、Yarn 及 Actions 版本,并采用不可变依赖安装
  • 将检查工作流权限限制为 contents: read
.github/workflows/format-check.yml
将定时格式化改为 dev 合并后的自动修复,并提交修复结果。
  • 监听 dev 分支 PR 关闭事件,仅对已合并且属于目标仓库的 PR 执行
  • 保留独立的 contents: write 权限与串行并发控制
  • 执行前端格式化及 Markdown 自动修复后提交并推送变更
.github/workflows/format-fix.yml
将前端代码质量工具链从 ESLint/Prettier 迁移至 oxlint/oxfmt,并加入 Markdownlint。
  • 更新 lint、format 及 Markdown 检查和修复脚本
  • 移除 ESLint、Prettier 及相关插件依赖,加入 oxlint、oxfmt 和 markdownlint-cli2
  • 新增各工具配置并删除旧的 Prettier、ESLint 和 VS Code 配置
  • 更新前端文档中的代码规范说明
frontend/package.json
frontend/yarn.lock
frontend/.markdownlint-cli2.jsonc
frontend/.oxfmtrc.json
frontend/.oxlintrc.json
frontend/README.md
frontend/eslint.config.mjs
frontend/.prettierignore
frontend/.prettierrc
frontend/.vscode/extensions.json
frontend/.vscode/settings.json
同步格式工具迁移产生的仓库忽略配置和格式化结果。
  • 调整 Git 忽略规则以配合新的格式化工具
  • 纳入前端格式配置及相关格式化变更
.gitignore

提示与命令

与 Sourcery 交互

  • 触发新的审查: 在拉取请求中评论 @sourcery-ai review
  • 继续讨论: 直接回复 Sourcery 的审查评论。
  • 根据审查评论生成 GitHub issue: 回复审查评论,请 Sourcery 根据该评论创建 issue。你也可以使用 @sourcery-ai issue 回复审查评论,以根据该评论创建 issue。
  • 生成拉取请求标题: 在拉取请求标题的任意位置写入 @sourcery-ai,即可随时生成标题。你也可以在拉取请求中评论 @sourcery-ai title,以随时生成或重新生成标题。
  • 生成拉取请求摘要: 在拉取请求正文中需要生成摘要的位置写入 @sourcery-ai summary,即可在指定位置随时生成 PR 摘要。你也可以在拉取请求中评论 @sourcery-ai summary,以随时生成或重新生成摘要。
  • 生成审查者指南: 在拉取请求中评论 @sourcery-ai guide,即可随时生成或重新生成审查者指南。
  • 解决所有 Sourcery 评论: 在拉取请求中评论 @sourcery-ai resolve,即可解决所有 Sourcery 评论。如果你已经处理完所有评论且不想再看到它们,此功能非常有用。
  • 忽略所有 Sourcery 审查: 在拉取请求中评论 @sourcery-ai dismiss,即可忽略所有现有的 Sourcery 审查。如果你想从头开始新的审查,此功能尤其有用——别忘了评论 @sourcery-ai review 以触发新的审查!

自定义你的使用体验

访问你的控制面板,即可:

  • 启用或禁用审查功能,例如 Sourcery 生成的拉取请求摘要、审查者指南等。
  • 更改审查语言。
  • 添加、移除或编辑自定义审查指令。
  • 调整其他审查设置。

获取帮助

Original review guide in English

Reviewer's Guide

该 PR 新增 PR 阶段的只读格式检查,覆盖 Python、前端代码和 Markdown,并将原定时格式化改为 dev 合并后的独立写权限自动修复流程;同时将前端格式与 lint 工具从 ESLint/Prettier 迁移到 oxlint/oxfmt,并加入 Markdownlint 及对应配置。

Sequence diagram for PR format checking and post-merge fixing

sequenceDiagram
    participant PR as PullRequest
    participant Check as FormatCheckWorkflow
    participant Repo as Repository
    participant Fix as FormatFixWorkflow

    PR->>Check: opened / synchronize / reopened
    Check->>Repo: actions/checkout
    Check->>Check: ruff format --check .
    Check->>Check: yarn oxfmt . --check
    Check->>Check: yarn lint:md
    PR->>Fix: merged into dev
    Fix->>Repo: checkout dev
    Fix->>Fix: yarn format
    Fix->>Fix: yarn lint:md:fix
    Fix->>Repo: commit and push formatting changes
Loading

File-Level Changes

Change Details Files
为 PR 增加只读的多语言格式检查流水线,并通过并发控制取消过时检查。
  • 在 PR 创建、更新和重新打开时运行检查
  • 使用 Ruff 检查 Python 格式,使用 oxfmt 和 Markdownlint 检查前端
  • 固定 Python、Node、Ruff、Yarn 及 Actions 版本,并采用不可变依赖安装
  • 将检查工作流权限限制为 contents: read
.github/workflows/format-check.yml
将定时格式化改为 dev 合并后的自动修复,并提交修复结果。
  • 监听 dev 分支 PR 关闭事件,仅对已合并且属于目标仓库的 PR 执行
  • 保留独立的 contents: write 权限与串行并发控制
  • 执行前端格式化及 Markdown 自动修复后提交并推送变更
.github/workflows/format-fix.yml
将前端代码质量工具链从 ESLint/Prettier 迁移至 oxlint/oxfmt,并加入 Markdownlint。
  • 更新 lint、format 及 Markdown 检查和修复脚本
  • 移除 ESLint、Prettier 及相关插件依赖,加入 oxlint、oxfmt 和 markdownlint-cli2
  • 新增各工具配置并删除旧的 Prettier、ESLint 和 VS Code 配置
  • 更新前端文档中的代码规范说明
frontend/package.json
frontend/yarn.lock
frontend/.markdownlint-cli2.jsonc
frontend/.oxfmtrc.json
frontend/.oxlintrc.json
frontend/README.md
frontend/eslint.config.mjs
frontend/.prettierignore
frontend/.prettierrc
frontend/.vscode/extensions.json
frontend/.vscode/settings.json
同步格式工具迁移产生的仓库忽略配置和格式化结果。
  • 调整 Git 忽略规则以配合新的格式化工具
  • 纳入前端格式配置及相关格式化变更
.gitignore

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

嘿——我发现了 1 个问题

已修复的安全问题

面向 AI Agent 的提示
请处理本次代码审查中的评论:

## 单独评论

### 评论 1
<location path=".github/workflows/format-check.yml" line_range="59" />
<code_context>
+
+      - name: 检查前端 Markdown Lint
+        working-directory: frontend
+        run: yarn lint:md
</code_context>
<issue_to_address>
**issue (broader_impact):** PR 工作流从未运行 `yarn lint`,因此即使合并后的工作流会运行 `yarn lint:fix` 并随后重写已合并的代码,oxlint 错误仍然可以通过 PR 检查。

**触发条件:** 当 PR 包含不会影响 Ruff、oxfmt 或 Markdown 检查的 oxlint 错误时。

**建议修复:** 在 PR 工作流中添加一个只读的 `yarn lint` 步骤;或者,如果 lint 有意不在此次检查范围内,则从合并后的格式化工作流中移除 `yarn lint:fix`。
</issue_to_address>

Sourcery 评估

需要人工审查。 首先需要处理 1 个发现的问题。此外,新的 pull_request_target 工作流授予了 contents: write 权限,并会在合并后自动运行格式化程序,将更改提交到 dev 分支。因此,工作流或工具错误可能会创建在还原此 PR 后仍然存在的仓库更改。这些提交的影响范围有限且可以还原,但 CI 信任边界的变化以及格式化程序/代码检查工具依赖的大范围迁移值得进行人工审查。

阻塞性发现:.github/workflows/format-check.yml:59


Sourcery 对开源项目免费——如果您喜欢我们的审查,请考虑分享它们 ✨
请帮助我变得更有用!请在每条评论上点击 👍 或 👎,我会利用反馈来改进审查结果。
Original comment in English

Hey - I've found 1 issue

Fixed security issues:

Prompt for AI Agents
Please address the comments from this code review:

## Individual Comments

### Comment 1
<location path=".github/workflows/format-check.yml" line_range="59" />
<code_context>
+
+      - name: 检查前端 Markdown Lint
+        working-directory: frontend
+        run: yarn lint:md
</code_context>
<issue_to_address>
**issue (broader_impact):** The PR workflow never runs `yarn lint`, so oxlint errors are allowed through PR checks even though the post-merge workflow runs `yarn lint:fix` and can subsequently rewrite the merged code.

**Triggers:** When a PR contains an oxlint error that does not affect Ruff, oxfmt, or Markdown checks.

**Suggested fix:** Add a read-only `yarn lint` step to the PR workflow, or remove `yarn lint:fix` from the post-merge formatter if lint is intentionally outside this check.
</issue_to_address>

Sourcery assessment

Needs a human reviewer. 1 finding to address first, and the new pull_request_target workflow grants contents: write and automatically runs formatting and commits changes to the dev branch after merges, so a workflow or tooling mistake can create repository changes that remain after reverting this PR. Those commits are bounded and can be reverted, but the changed CI trust boundary and broad formatter/linter dependency migration warrant human review.

Blocking findings: .github/workflows/format-check.yml:59


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.


- name: 检查前端 Markdown Lint
working-directory: frontend
run: yarn lint:md

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

issue (broader_impact): PR 工作流从未运行 yarn lint,因此即使合并后的工作流会运行 yarn lint:fix 并随后重写已合并的代码,oxlint 错误仍然可以通过 PR 检查。

触发条件: 当 PR 包含不会影响 Ruff、oxfmt 或 Markdown 检查的 oxlint 错误时。

建议修复: 在 PR 工作流中添加一个只读的 yarn lint 步骤;或者,如果 lint 有意不在此次检查范围内,则从合并后的格式化工作流中移除 yarn lint:fix

Original comment in English

issue (broader_impact): The PR workflow never runs yarn lint, so oxlint errors are allowed through PR checks even though the post-merge workflow runs yarn lint:fix and can subsequently rewrite the merged code.

Triggers: When a PR contains an oxlint error that does not affect Ruff, oxfmt, or Markdown checks.

Suggested fix: Add a read-only yarn lint step to the PR workflow, or remove yarn lint:fix from the post-merge formatter if lint is intentionally outside this check.

@Craun718
Craun718 changed the base branch from dev to main September 1, 2026 09:17
@Craun718
Craun718 marked this pull request as draft September 1, 2026 09:18
@HarcoChen

Copy link
Copy Markdown
Contributor

当前似乎ruff check过不了,等等吧()

@HarcoChen

Copy link
Copy Markdown
Contributor

自动format可以和签名放到一个工作流吧

@Craun718
Craun718 changed the base branch from main to dev September 1, 2026 10:08
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