name: Gitea Code Review description: A GitHub Action that uses OpenAI to review code in pull request. inputs: PROGRAMMING_LANGUAGE: description: 'The programming language used in the GitHub repository. If not provided, the detected programming language will be used.' default: '' FULL_REVIEW_COMMENT: description: 'The comment to trigger a code review for the pull request.' default: 'openai' REVIEW_COMMENT_PREFIX: description: 'The comment prefix to trigger a code review with the comment content.' default: 'openai:' OPENAI_TOKEN: description: 'The API token for the OpenAI API.' required: true GITHUB_TOKEN: description: 'The API token for the Github API.' required: true GITHUB_BASE_URL: description: 'The base URL for the GitHub API.' MAX_CODE_LENGTH: description: 'The maximum code length for the pull request to be sent to OpenAI.' default: 6000 type: int SOURCE_AT: description: 'Where is the source code located' default: 'github' PROMPT_TEMPLATE: description: 'The template for the FULL_REVIEW_COMMENT prompt.' default: 'Your task is to act as a code reviewer and review a pull request by summarizing the changes made, identifying potential issues related to logic and runtime, and creating a bullet list of action items needed before the change can be approved. The output should focus on items mentioned in the given code review checklist. Instructions: - Review the output of git diff for the pull request - Summarize the overview of the changes made - Identify potential issues related to logic and runtime - Output as a markdown document, with the following sections: #### Overview of changes: - Summarize the overview of the changes made #### Changelog: - Summarize the overview in a bullet point to consider it in Change-log. #### issues: - Identify potential issues related to logic and runtime - Identify issues mentioned in the code review checklist #### Action items: - Mandatory action items that are must and needed before the change can be approved #### Joke about this PR: - Tell me a joke about this Code Review - If there are no issues, output "None" - If there are no action items, output "None" - Create a bullet list of action items needed before the change can be approved - The response sentences are no longer than 16 words each - Keep the response sentences as short as possible - Focus on items mentioned in the given code review checklist: Code Structure - Validation - Business logic should be in service class - Dont repeat yourself (DRY) - Prefer to use Eloquent over using Query Builder and raw SQL queries. Prefer collections over arrays - Mass assignment - Do not execute queries in Blade templates and use eager loading (N + 1 problem) - Chunk data for data-heavy tasks - Comment your code, but prefer descriptive method and variable names over comments - Do not put JS and CSS in Blade templates and do not put any HTML in PHP classes - Use config and language files, constants instead of text in the code - Use standard Laravel tools accepted by community - Follow Laravel naming conventions - Use shorter and more readable syntax where possible - Use IoC container or facades instead of new Class - Are there any unnecessary files, folders, or code modules? - Does the code follow the Single Responsibility Principle (SRP) and Dont Repeat Yourself (DRY) principle? Error Handling - Are all error scenarios covered in the code? - Are the error messages clear and helpful? - Is the code handling errors gracefully? Security - Are sensitive data and credentials stored securely? - Are all external libraries and packages up-to-date? - Is the code protected against common security vulnerabilities such as SQL injection and cross-site scripting (XSS)? \`\`\` ${code} \`\`\`' ANSWER_TEMPLATE: description: 'The template for the answer sent to the GitHub comment.' default: 'AI Code Review: ### Summary: ${answer}' runs: using: 'node16' main: 'dist/index.js'