Skip to content

将 PR Checkstyle 报告同步至 Pull Request 审查评论 - #6692

Open
neveler wants to merge 5 commits into
HMCL-dev:mainfrom
neveler:reviewdog
Open

将 PR Checkstyle 报告同步至 Pull Request 审查评论#6692
neveler wants to merge 5 commits into
HMCL-dev:mainfrom
neveler:reviewdog

Conversation

@neveler

@neveler neveler commented Aug 16, 2026

Copy link
Copy Markdown
Contributor

通过 pull_request 事件触发的工作流是没有发布 review comment 的权限的,因此额外添加了一个 Check Codes Comment 工作流用于将 reviewdog 生成的 jsonl 报告转为 review comment


https://github.com/reviewdog/reviewdog
https://github.com/reviewdog/action-setup
https://securitylab.github.com/resources/github-actions-preventing-pwn-requests/
neveler#7


image

@github-actions github-actions Bot added the 1+ label Aug 16, 2026
@neveler neveler changed the title Update check-codes.yml configuration 为代码检查集成 reviewdog Aug 16, 2026
@Glavo

Glavo commented Aug 16, 2026

Copy link
Copy Markdown
Member

@codex review

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: c7ef111911

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread .github/workflows/check-codes.yml Outdated
@neveler
neveler marked this pull request as draft August 16, 2026 15:41
@neveler neveler changed the title 为代码检查集成 reviewdog 为 PR 增加自动发布 checkstyle 审查评论的功能 Aug 17, 2026
@github-actions github-actions Bot added 40+ and removed 1+ labels Aug 17, 2026
@github-actions github-actions Bot added 1+ and removed 40+ labels Aug 17, 2026
@neveler neveler changed the title 为 PR 增加自动发布 checkstyle 审查评论的功能 为代码检查集成 reviewdog Aug 17, 2026
@neveler
neveler marked this pull request as ready for review August 17, 2026 07:00
@Glavo

Glavo commented Aug 17, 2026

Copy link
Copy Markdown
Member

@codex review

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: e940f016e7

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread .github/workflows/check-codes.yml Outdated
@neveler
neveler marked this pull request as draft August 17, 2026 22:44
@github-actions github-actions Bot added 100+ and removed 1+ labels Aug 18, 2026
@neveler neveler changed the title 为代码检查集成 reviewdog 将 PR Checkstyle 报告同步至 Pull Request 审查评论 Aug 18, 2026
@neveler
neveler marked this pull request as ready for review August 18, 2026 00:32
@Glavo

Glavo commented Aug 19, 2026

Copy link
Copy Markdown
Member

@codex review

@chatgpt-codex-connector chatgpt-codex-connector 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.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 346aab98c2

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread .github/scripts/check-codes-comment.js
Comment on lines +107 to +109
} catch (error) {
core.error(`Failed to post review comments to GitHub: ${error.message}`);
}

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Fail the job when review creation fails

When GitHub rejects the review—for example because a diagnostic has an invalid position—or the API experiences a transient failure, this catch only emits an annotation and then returns normally. core.error does not mark an actions/github-script step as failed, so the dedicated comment workflow finishes successfully despite posting no diagnostics, concealing the malfunction from maintainers; rethrow the error or call core.setFailed.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

个人认为此错误完全可以忽略,没必要非得报错吧。

@Glavo
Glavo requested a balanced review from Copilot August 19, 2026 13:42

Copilot AI 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.

Pull request overview

新增安全的特权工作流,将 Checkstyle 报告发布为 PR 审查评论。

Changes:

  • 生成并上传 reviewdog JSONL 报告。
  • 验证 PR 来源后创建行内审查评论。
  • 优化脚本的 sparse checkout。

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 3 comments.

File Description
.github/workflows/pr-size-label.yml 精确检出标签脚本。
.github/workflows/check-codes.yml 生成并上传 Checkstyle 报告。
.github/workflows/check-codes-comment.yml 下载报告并触发评论脚本。
.github/scripts/check-codes-comment.js 验证运行来源并发布审查评论。
Suppressed comments (1)

.github/scripts/check-codes-comment.js:108

  • This catch also leaves the workflow green when the review API rejects the payload, even though its sole purpose was not completed. Mark the step failed or rethrow so maintainers can detect and retry publication failures.
        core.error(`Failed to post review comments to GitHub: ${error.message}`);

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment on lines +76 to +80
if (filePath && line) {
comments.push({
path: filePath,
line,
side: "RIGHT",
commit_id: run.head_sha,
body: "🤖 Static analysis found the following issues:",
event: "COMMENT",
comments: comments
Comment on lines +33 to +34
core.error(`Failed to fetch PR #${PULL_REQUEST_NUMBER}: ${error.message}`);
return;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants