logo
5
4
Login
feat: 支持评分和最大评论数两参数同时有效

AI Code Review

Supports four types of operations using AI: code review, PR title and description readability check, commit message readability check, and change summary.

Note: Results are for reference only and are not recommended as final criteria.

Image Name

cnbcool/ai-review

Parameter Description

  • type: Operation type, default is code-review
    • code-review: Code review
    • pr-info-readability-check: PR title and description readability check
    • commit-message-readability-check: Commit message readability check
    • diff-summary: Change summary
  • message: When type=commit-message-readability-check, you can specify the message parameter to indicate the commit message. If not specified, it defaults to CNB_COMMIT_MESSAGE
  • pr_comment: true or false, default is true. Whether to post PR comments as pull_request inline comments. Valid when type=code-review.
  • max_comments: Maximum number of comments, maximum is 10. Valid when type=code-review. Both max_comments and score_for_add_comment parameters are set, both are valid. Neither is set, a comment will be posted by default.
  • prompt_output_file: Optional, relative file path, such as ./prompt.txt. If provided, the prompt will be saved to the file.
  • result_output_file: Optional, relative file path, such as ./result.txt. If provided, the AI output result will be saved to the file.
  • score_for_add_comment: Optional, when type=code-review and pr_comment is true, you can specify this parameter to indicate the comment score threshold. Reviews below this score will be commented on the PR. Both max_comments and score_for_add_comment parameters are set, both are valid. Neither is set, a comment will be posted by default.
  • ai_chat_url: Optional, AI chat service address. For example https://ai.xxx.com/chat/completions. If not specified, the AI service provided by CNB will be used by default.
  • ai_token: Optional, AI chat service token. If not specified, the AI service token provided by CNB will be used by default.
  • ai_model: Optional, AI chat service model. If not specified, the AI service model provided by CNB will be used by default.

Output Results

  • pr-info-readability-check: Outputs environment variable name status, value is yes or no
  • commit-message-readability-check: Outputs environment variable name status, value is yes or no
  • diff-summary: Outputs environment variable name summary, indicating the content of the change summary

Using in CNB

Code Review

By default, AI review comments will be sent as comments to the PR. Currently only supports sending one comment.

main: pull_request: - stages: - name: Code Review image: cnbcool/ai-review:latest settings: type: code-review

PR Title and Description Readability Check

main: pull_request: - stages: - name: Title and Description Readability Check image: cnbcool/ai-review:latest settings: type: pr-info-readability-check exports: status: STATUS - name: Title and Description Readability Check Result script: echo $STATUS

Commit Message Readability Check

main: push: - stages: - name: Commit Message Readability Check image: cnbcool/ai-review:latest settings: type: commit-message-readability-check exports: status: STATUS - name: Commit Message Readability Check Result script: echo $STATUS

Change Summary

main: pull_request: - stages: - name: Change Summary image: cnbcool/ai-review:latest settings: type: diff-summary exports: summary: SUMMARY - name: Change Summary script: echo $SUMMARY