feat(ci): 添加 OpenCodeReview PR 自动审查工作流#12
Merged
Conversation
|
Note Gemini is unable to generate a review for this pull request due to the file types involved not being currently supported. |
- 仅允许 OWNER/MEMBER/COLLABORATOR/CONTRIBUTOR 触发 - PR 创建触发不受影响
There was a problem hiding this comment.
🔍 OpenCodeReview found 10 issue(s) in this PR.
- ✅ 8 posted as inline comment(s)
- 📝 2 posted as summary (missing line info)
📄 .github/workflows/ocr-review.yml
安全风险:ocr review命令的输出直接写入文件并cat显示,如果OCR输出包含敏感信息,可能会在GitHub Actions日志中泄露。建议:1) 对输出文件进行加密或混淆处理;2) 或者只记录必要的错误信息,避免完整输出日志;3) 考虑使用::add-mask::来掩码敏感信息。
💡 Suggested Change
Before:
# Run OCR in range mode with JSON output
ocr review \
--from "origin/${BASE_REF}" \
--to "origin/${HEAD_REF}" \
--format json \
> /tmp/ocr-result.json 2>/tmp/ocr-stderr.log || true
echo "OCR review completed. Output:"
cat /tmp/ocr-result.json
echo "OCR review completed. Error log:"
cat /tmp/ocr-stderr.log
After:
# Run OCR in range mode with JSON output
ocr review \
--from "origin/${BASE_REF}" \
--to "origin/${HEAD_REF}" \
--format json \
> /tmp/ocr-result.json 2>/tmp/ocr-stderr.log || true
echo "OCR review completed. Check /tmp/ocr-result.json for details."
📄 .github/workflows/ocr-review.yml
代码重复:formatComment和formatCommentMarkdown函数有重复的代码逻辑,特别是处理suggestion_code的部分。建议:1) 提取公共逻辑到辅助函数;2) 或者使用统一的格式化函数;3) 减少代码重复,提高可维护性。
💡 Suggested Change
Before:
function formatComment(comment) {
let body = comment.content || '';
// Add code suggestion if available
if (comment.suggestion_code && comment.existing_code) {
body += '\n\n**Suggestion:**\n';
body += '```suggestion\n';
body += comment.suggestion_code;
if (!comment.suggestion_code.endsWith('\n')) body += '\n';
body += '```';
}
return body;
}
function formatCommentMarkdown(comment) {
let md = `### 📄 \`${comment.path}\``;
if (comment.start_line && comment.end_line) {
md += ` (L${comment.start_line}-L${comment.end_line})`;
}
md += '\n\n';
md += comment.content || '';
if (comment.suggestion_code && comment.existing_code) {
md += '\n\n<details><summary>💡 Suggested Change</summary>\n\n';
md += '**Before:**\n```\n' + comment.existing_code + '\n```\n\n';
md += '**After:**\n```\n' + comment.suggestion_code + '\n```\n\n';
md += '</details>';
}
return md;
}
After:
function formatSuggestion(comment) {
if (!comment.suggestion_code || !comment.existing_code) return '';
let md = '\n\n<details><summary>💡 Suggested Change</summary>\n\n';
md += '**Before:**\n```\n' + comment.existing_code + '\n```\n\n';
md += '**After:**\n```\n' + comment.suggestion_code + '\n```\n\n';
md += '</details>';
return md;
}
function formatComment(comment) {
let body = comment.content || '';
// Add code suggestion if available
if (comment.suggestion_code && comment.existing_code) {
body += '\n\n**Suggestion:**\n';
body += '```suggestion\n';
body += comment.suggestion_code;
if (!comment.suggestion_code.endsWith('\n')) body += '\n';
body += '```';
}
return body;
}
function formatCommentMarkdown(comment) {
let md = `### 📄 \`${comment.path}\``;
if (comment.start_line && comment.end_line) {
md += ` (L${comment.start_line}-L${comment.end_line})`;
}
md += '\n\n';
md += comment.content || '';
md += formatSuggestion(comment);
return md;
}
Owner
Author
|
实测效果可能不是很好,可能是因为模型使用了 MiMo2.5-Pro,但 opus 的渠道不太稳定,先用着吧。 同时这个技术对我来说还是挺新颖的,给了我一些思路。 目前主要存在两个问题:
|
Owner
Author
|
同时项目本身存在的审查体系已经能做到充分的审查了,所以这些只是兜底 |
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Uh oh!
There was an error while loading. Please reload this page.