-
Notifications
You must be signed in to change notification settings - Fork 0
only pr review #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,13 +1,12 @@ | ||||||||||||||||||||||||||||
| # CR-template | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| 基于 Claude AI 的自动化代码审查模板,支持 PR Review 和 Commit Review,并通过飞书 Webhook 发送通知。 | ||||||||||||||||||||||||||||
| 基于 Claude AI 的自动化 PR 代码审查模板,通过飞书 Webhook 发送通知。 | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| ## 功能特性 | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| | 功能 | 说明 | | ||||||||||||||||||||||||||||
| |-----|------| | ||||||||||||||||||||||||||||
| | PR Review | PR 创建/更新时自动审查代码质量和架构设计 | | ||||||||||||||||||||||||||||
| | Commit Review | v* 分支 push 时自动审查最新 commit | | ||||||||||||||||||||||||||||
| | 飞书通知 | 审查完成后发送卡片消息到飞书群 | | ||||||||||||||||||||||||||||
| | 中文输出 | 所有审查报告和通知使用简体中文 | | ||||||||||||||||||||||||||||
| | Sticky Comment | PR 多次审查会更新同一条评论 | | ||||||||||||||||||||||||||||
|
|
@@ -20,8 +19,7 @@ | |||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| ``` | ||||||||||||||||||||||||||||
| .github/workflows/ | ||||||||||||||||||||||||||||
| ├── pr-review.yml # PR 审查工作流 | ||||||||||||||||||||||||||||
| └── commit-review.yml # Commit 审查工作流 | ||||||||||||||||||||||||||||
| └── pr-review.yml # PR 审查工作流 | ||||||||||||||||||||||||||||
| ``` | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| ### 2. 配置 GitHub Secrets | ||||||||||||||||||||||||||||
|
|
@@ -47,8 +45,6 @@ | |||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| ## 触发条件 | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| ### PR Review | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| 当 Pull Request 满足以下条件时触发: | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| | 事件 | 说明 | | ||||||||||||||||||||||||||||
|
|
@@ -60,16 +56,8 @@ | |||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| > **注意**: 草稿 PR 不会触发审查 | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| ### Commit Review | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| 当 push 到以下分支时触发: | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| - `v*` - 所有以 `v` 开头的分支(如 `v1.0`、`v2.0-beta`) | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| ## 审查维度 | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| ### PR Review | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| **代码质量** | ||||||||||||||||||||||||||||
| - 代码风格一致性 | ||||||||||||||||||||||||||||
| - 代码复杂度 | ||||||||||||||||||||||||||||
|
|
@@ -86,16 +74,8 @@ | |||||||||||||||||||||||||||
| - 模块化程度 | ||||||||||||||||||||||||||||
| - API 设计评估 | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| ### Commit Review | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| - Commit 信息是否清晰 | ||||||||||||||||||||||||||||
| - 代码变更是否合理 | ||||||||||||||||||||||||||||
| - 是否有明显问题 | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| ## 审查报告示例 | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| ### PR Review 报告 | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| ```markdown | ||||||||||||||||||||||||||||
| ## 🔍 PR 代码审查报告 | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
|
|
@@ -120,28 +100,10 @@ | |||||||||||||||||||||||||||
| 本次 PR 实现了用户认证的核心功能,代码结构清晰... | ||||||||||||||||||||||||||||
| ``` | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| ### Commit Review 报告 | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| ```markdown | ||||||||||||||||||||||||||||
| ## 📝 Commit 审查 - v1.0 | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| **Commit**: `abc1234` | ||||||||||||||||||||||||||||
| **信息**: feat: 添加登录功能 | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| ### 变更概要 | ||||||||||||||||||||||||||||
| - src/login.ts (+50) | ||||||||||||||||||||||||||||
| - tests/login.test.ts (+30) | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| ### 审查结果 | ||||||||||||||||||||||||||||
| ✅ PASS - 代码变更合理,无明显问题 | ||||||||||||||||||||||||||||
| ``` | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| ## 飞书通知 | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| 审查完成后会发送飞书卡片消息: | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| ### PR Review 通知 | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| ``` | ||||||||||||||||||||||||||||
| ┌──────────────────────────────────┐ | ||||||||||||||||||||||||||||
| │ ✅ PR Review - APPROVE │ (绿色卡片) | ||||||||||||||||||||||||||||
|
|
@@ -154,43 +116,16 @@ | |||||||||||||||||||||||||||
| └──────────────────────────────────┘ | ||||||||||||||||||||||||||||
| ``` | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| ### Commit Review 通知 | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| ``` | ||||||||||||||||||||||||||||
| ┌──────────────────────────────────┐ | ||||||||||||||||||||||||||||
| │ ✅ Commit Review - PASS │ (绿色卡片) | ||||||||||||||||||||||||||||
| ├──────────────────────────────────┤ | ||||||||||||||||||||||||||||
| │ 仓库: owner/repo 分支: v1.0 │ | ||||||||||||||||||||||||||||
| │ Commit: abc1234 │ | ||||||||||||||||||||||||||||
| │ 审查结果: 代码变更合理,无明显问题 │ | ||||||||||||||||||||||||||||
| │ [查看 Commit] │ | ||||||||||||||||||||||||||||
| └──────────────────────────────────┘ | ||||||||||||||||||||||||||||
| ``` | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| ### 卡片颜色说明 | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| | 审查结论 | 卡片颜色 | | ||||||||||||||||||||||||||||
| |---------|---------| | ||||||||||||||||||||||||||||
| | APPROVE / PASS | 🟢 绿色 | | ||||||||||||||||||||||||||||
| | REQUEST_CHANGES / FAIL | 🔴 红色 | | ||||||||||||||||||||||||||||
| | WARN | 🟠 橙色 | | ||||||||||||||||||||||||||||
| | APPROVE | 🟢 绿色 | | ||||||||||||||||||||||||||||
| | REQUEST_CHANGES | 🔴 红色 | | ||||||||||||||||||||||||||||
| | COMMENT / 其他 | 🔵 蓝色 | | ||||||||||||||||||||||||||||
|
Comment on lines
121
to
125
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 在“卡片颜色说明”表格中,为了保持术语的一致性,建议将
Suggested change
|
||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| ## 自定义配置 | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| ### 修改触发分支 | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| 编辑 `.github/workflows/commit-review.yml`: | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| ```yaml | ||||||||||||||||||||||||||||
| on: | ||||||||||||||||||||||||||||
| push: | ||||||||||||||||||||||||||||
| branches: | ||||||||||||||||||||||||||||
| - 'v*' # 所有 v 开头的分支 | ||||||||||||||||||||||||||||
| - 'release/*' # 添加 release 分支 | ||||||||||||||||||||||||||||
| - 'main' # 添加 main 分支 | ||||||||||||||||||||||||||||
| ``` | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| ### 修改审查 Prompt | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| 编辑 workflow 文件中的 `prompt` 字段: | ||||||||||||||||||||||||||||
|
|
@@ -219,16 +154,15 @@ claude_args: | | |||||||||||||||||||||||||||
| . | ||||||||||||||||||||||||||||
| ├── .github/ | ||||||||||||||||||||||||||||
| │ └── workflows/ | ||||||||||||||||||||||||||||
| │ ├── pr-review.yml # PR 审查工作流 | ||||||||||||||||||||||||||||
| │ └── commit-review.yml # Commit 审查工作流 | ||||||||||||||||||||||||||||
| │ └── pr-review.yml # PR 审查工作流 | ||||||||||||||||||||||||||||
| └── README.md | ||||||||||||||||||||||||||||
| ``` | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| ## 技术说明 | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| - 使用 [claude-code-action](https://github.com/anthropics/claude-code-action) v1 | ||||||||||||||||||||||||||||
| - 通过 `--json-schema` 获取结构化输出用于飞书通知 | ||||||||||||||||||||||||||||
| - PR Review 使用 `use_sticky_comment` 合并多次评论 | ||||||||||||||||||||||||||||
| - 使用 `use_sticky_comment` 合并多次评论 | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
| ## License | ||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍 很好的改进
新增了
Read,Glob,Grep,Task等工具到允许列表,这使得 Claude AI 审查时能够:这将显著提升代码审查的质量和准确性。