-
Notifications
You must be signed in to change notification settings - Fork 0
doc: format #1
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
doc: format #1
Changes from all commits
71edbe9
455554e
11f6be6
f0022d9
61d69b1
b34ff47
5e17741
eb11e32
74b212e
0ebb0b1
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -21,13 +21,45 @@ jobs: | |
| - name: Review Commits with Claude | ||
| id: review | ||
| uses: anthropics/claude-code-action@v1 | ||
| env: | ||
| ANTHROPIC_BASE_URL: ${{ secrets.ANTHROPIC_BASE_URL }} | ||
| with: | ||
| github_token: ${{ secrets.CUSTOM_GITHUB_TOKEN }} | ||
| anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }} | ||
| anthropic_base_url: ${{ secrets.ANTHROPIC_BASE_URL }} | ||
| prompt: | | ||
| /review-commit REPO: ${{ github.repository }} SHA: ${{ github.sha }} BRANCH: ${{ github.ref_name }} | ||
| 你是一个代码审查助手。请对最新的 commit 进行简单审查。 | ||
|
|
||
| ## 审查信息 | ||
| - 仓库: ${{ github.repository }} | ||
| - 分支: ${{ github.ref_name }} | ||
| - Commit SHA: ${{ github.sha }} | ||
|
|
||
| ## 审查步骤 | ||
|
|
||
| 1. 使用 git show 查看 commit 详情和变更 | ||
| 2. 检查 commit 信息是否清晰、代码变更是否合理、是否有明显问题 | ||
|
|
||
| ## 输出格式(简体中文) | ||
|
|
||
| ## 📝 Commit 审查 - ${{ github.ref_name }} | ||
|
|
||
| **Commit**: {short_sha} | ||
| **信息**: {commit message} | ||
|
|
||
| ### 变更概要 | ||
| {变更文件列表} | ||
|
|
||
| ### 审查结果 | ||
| ✅/⚠️/❌ {简要评价} | ||
|
|
||
| {如有问题,列出1-3个要点} | ||
|
|
||
| ## 注意事项 | ||
| 1. 保持简洁 | ||
| 2. 只关注明显问题 | ||
| 3. 使用简体中文 | ||
| claude_args: | | ||
| --allowedTools "Bash(gh *)" "Bash(git *)" "Read" "Glob" "Grep" | ||
| --allowedTools "mcp__github_inline_comment__create_inline_comment,Bash(gh pr comment:*),Bash(gh pr diff:*),Bash(gh pr view:*)" --json-schema '{"type":"object","properties":{"conclusion":{"type":"string","enum":["PASS","WARN","FAIL"]},"summary":{"type":"string","maxLength":50}},"required":["conclusion","summary"]}' | ||
|
Member
Author
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. 相同的可读性问题: 与
Member
Author
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. 配置不一致问题: Commit Review 的 当前工具包括:
建议: Commit Review 应该使用不同的工具集,移除 PR 相关工具,可能需要添加
Member
Author
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. ❌ 工具权限配置错误 Commit Review 不涉及 PR 操作,但配置中包含了 PR 相关的工具:
建议修改为: --allowedTools "Bash(git show:*),Bash(git diff:*),Bash(git log:*),Read,Glob,Grep"
Member
Author
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. 🟠 重要问题:allowedTools 配置不匹配实际需求 Commit Review 工作流使用了 建议修改为: --allowedTools "Bash(git *)"Commit Review 只需要 Git 操作工具即可完成审查任务。 |
||
|
|
||
| - name: Notify Feishu | ||
| if: always() | ||
|
|
@@ -36,13 +68,14 @@ jobs: | |
| SHORT_SHA="${{ github.sha }}" | ||
| SHORT_SHA="${SHORT_SHA:0:7}" | ||
|
|
||
| # 读取审查摘要 | ||
| if [ -f /tmp/review-summary.json ]; then | ||
| CONCLUSION=$(jq -r '.conclusion // "UNKNOWN"' /tmp/review-summary.json) | ||
| SUMMARY=$(jq -r '.summary // "审查完成"' /tmp/review-summary.json) | ||
| # 解析结构化输出 | ||
| STRUCTURED_OUTPUT='${{ steps.review.outputs.structured_output }}' | ||
| if [ -n "$STRUCTURED_OUTPUT" ] && [ "$STRUCTURED_OUTPUT" != "null" ]; then | ||
| CONCLUSION=$(echo "$STRUCTURED_OUTPUT" | jq -r '.conclusion // "UNKNOWN"') | ||
| SUMMARY=$(echo "$STRUCTURED_OUTPUT" | jq -r '.summary // "审查完成"') | ||
| else | ||
| CONCLUSION="UNKNOWN" | ||
| SUMMARY="未获取到审查摘要" | ||
| SUMMARY="未获取到审查结果" | ||
| fi | ||
|
|
||
| # 根据结论设置样式 | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,7 +7,6 @@ on: | |
| jobs: | ||
| review: | ||
| runs-on: ubuntu-latest | ||
| # 跳过 draft PR | ||
| if: github.event.pull_request.draft == false | ||
| permissions: | ||
| contents: read | ||
|
|
@@ -22,29 +21,78 @@ jobs: | |
| - name: PR Review with Claude | ||
| id: review | ||
| uses: anthropics/claude-code-action@v1 | ||
| env: | ||
| ANTHROPIC_BASE_URL: ${{ secrets.ANTHROPIC_BASE_URL }} | ||
|
Member
Author
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. 需要确认 如果不确定,建议保留原有方式: with:
anthropic_base_url: ${{ secrets.ANTHROPIC_BASE_URL }}
Member
Author
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. 🟠 重要问题:环境变量配置方式需要验证
在之前的版本中使用的是 |
||
| with: | ||
| github_token: ${{ secrets.CUSTOM_GITHUB_TOKEN }} | ||
|
Member
Author
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. 🟠 重要问题:github_token 配置缺少回退机制 如果 建议添加回退机制: github_token: ${{ secrets.CUSTOM_GITHUB_TOKEN || github.token }}这样在没有自定义 token 时会自动使用默认的 |
||
| anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }} | ||
| anthropic_base_url: ${{ secrets.ANTHROPIC_BASE_URL }} | ||
| use_sticky_comment: true | ||
| show_full_output: true | ||
| prompt: | | ||
| /review-pr REPO: ${{ github.repository }} PR_NUMBER: ${{ github.event.pull_request.number }} | ||
| claude_args: | | ||
| --allowedTools "Bash(gh pr *)" "Bash(git *)" "Read" "Glob" "Grep" "Task" "WebFetch" | ||
| 请对当前 PR 进行全面审查. | ||
|
|
||
| ## 审查维度 | ||
|
|
||
| **代码质量**:代码风格、复杂度、重复代码、命名规范、错误处理、潜在 bug | ||
|
|
||
| **架构设计**:项目结构一致性、依赖合理性、设计模式、关注点分离 | ||
|
|
||
| ## 输出格式(简体中文) | ||
|
|
||
| 请按以下格式输出审查报告, 作为: | ||
|
|
||
| ## 🔍 PR 代码审查报告 | ||
|
|
||
| ### 📋 概要 | ||
| - **变更文件数**: {changedFiles} | ||
| - **新增/删除行数**: +{additions} / -{deletions} | ||
|
|
||
| ### 🎯 审查结论 | ||
| {APPROVE/REQUEST_CHANGES/COMMENT 及简要说明} | ||
|
|
||
| ### 🔴 严重问题 (Critical) | ||
| {严重问题列表,如无则显示"无"} | ||
|
|
||
| ### 🟠 重要问题 (Important) | ||
| {重要问题列表,如无则显示"无"} | ||
|
|
||
| ### 🟢 改进建议 (Suggestions) | ||
| {改进建议列表,如无则显示"无"} | ||
|
|
||
| ### 💡 总体评价 | ||
| {对本次 PR 的整体评价} | ||
|
|
||
| ## 注意事项 | ||
| 1. 所有评论使用简体中文 | ||
| 2. 给出具体的文件名和行号 | ||
| 3. 对好的实践也要给予肯定 | ||
| 4. 保持客观、专业 | ||
|
|
||
| Note: The PR branch is already checked out in the current working directory. | ||
|
|
||
| Use `gh pr comment` for top-level feedback. | ||
| Use `mcp__github_inline_comment__create_inline_comment` to highlight specific code issues. | ||
| Only post GitHub comments - don't submit review text as messages. | ||
|
|
||
| ALWAYS Answer in 简体中文. | ||
| claude_args: | | ||
| --allowedTools "mcp__github_inline_comment__create_inline_comment,Bash(gh pr comment:*),Bash(gh pr diff:*),Bash(gh pr view:*)" --json-schema '{"type":"object","properties":{"conclusion":{"type":"string","enum":["APPROVE","REQUEST_CHANGES","COMMENT"]},"summary":{"type":"string","maxLength":50},"critical_count":{"type":"integer"},"important_count":{"type":"integer"},"suggestion_count":{"type":"integer"}},"required":["conclusion","summary","critical_count","important_count","suggestion_count"]}' | ||
|
Member
Author
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. 代码可读性问题: 这一行的
建议改进: claude_args: |
--allowedTools "mcp__github_inline_comment__create_inline_comment,Bash(gh pr comment:*),Bash(gh pr diff:*),Bash(gh pr view:*)"
--json-schema '{
"type": "object",
"properties": {
"conclusion": {"type": "string", "enum": ["APPROVE", "REQUEST_CHANGES", "COMMENT"]},
"summary": {"type": "string", "maxLength": 50},
"critical_count": {"type": "integer"},
"important_count": {"type": "integer"},
"suggestion_count": {"type": "integer"}
},
"required": ["conclusion", "summary", "critical_count", "important_count", "suggestion_count"]
}'或者考虑使用 YAML 的多行格式提高可读性。
Member
Author
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. 🟢 改进建议:JSON Schema 格式可读性差 单行的 JSON Schema 难以维护和阅读。建议使用更清晰的格式: claude_args: |
--allowedTools "mcp__github_inline_comment__create_inline_comment,Bash(gh pr comment:*),Bash(gh pr diff:*),Bash(gh pr view:*)"
--json-schema '{
"type": "object",
"properties": {
"conclusion": {"type": "string", "enum": ["APPROVE", "REQUEST_CHANGES", "COMMENT"]},
"summary": {"type": "string", "maxLength": 50},
"critical_count": {"type": "integer"},
"important_count": {"type": "integer"},
"suggestion_count": {"type": "integer"}
},
"required": ["conclusion", "summary", "critical_count", "important_count", "suggestion_count"]
}'或者将 schema 定义在单独的文件中引用。 |
||
| - name: Notify Feishu | ||
| if: always() | ||
| run: | | ||
| STATUS="${{ job.status }}" | ||
|
|
||
| # 读取审查摘要 | ||
| if [ -f /tmp/review-summary.json ]; then | ||
| CONCLUSION=$(jq -r '.conclusion // "UNKNOWN"' /tmp/review-summary.json) | ||
| SUMMARY=$(jq -r '.summary // "审查完成"' /tmp/review-summary.json) | ||
| CRITICAL=$(jq -r '.critical_count // 0' /tmp/review-summary.json) | ||
| IMPORTANT=$(jq -r '.important_count // 0' /tmp/review-summary.json) | ||
| SUGGESTION=$(jq -r '.suggestion_count // 0' /tmp/review-summary.json) | ||
| # 解析结构化输出 | ||
| STRUCTURED_OUTPUT='${{ steps.review.outputs.structured_output }}' | ||
| if [ -n "$STRUCTURED_OUTPUT" ] && [ "$STRUCTURED_OUTPUT" != "null" ]; then | ||
| CONCLUSION=$(echo "$STRUCTURED_OUTPUT" | jq -r '.conclusion // "UNKNOWN"') | ||
| SUMMARY=$(echo "$STRUCTURED_OUTPUT" | jq -r '.summary // "审查完成"') | ||
| CRITICAL=$(echo "$STRUCTURED_OUTPUT" | jq -r '.critical_count // 0') | ||
| IMPORTANT=$(echo "$STRUCTURED_OUTPUT" | jq -r '.important_count // 0') | ||
| SUGGESTION=$(echo "$STRUCTURED_OUTPUT" | jq -r '.suggestion_count // 0') | ||
| else | ||
| CONCLUSION="UNKNOWN" | ||
| SUMMARY="未获取到审查摘要" | ||
| SUMMARY="未获取到审查结果" | ||
| CRITICAL=0 | ||
| IMPORTANT=0 | ||
| SUGGESTION=0 | ||
|
|
||
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.
与 PR review workflow 相同的问题,需要确认
claude-code-action@v1是否支持通过env.ANTHROPIC_BASE_URL传递。