-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
2c9269f
commit 9421478
Showing
8 changed files
with
188 additions
and
200 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
# Sample Coding Rules for AI Review Flex | ||
|
||
The following are sample coding rules that `AI Review Flex`. These rules are written in markdown and should be placed in a file (e.g., `coding_guide.md`) within your repository. | ||
|
||
## Use camelCase for variable names | ||
|
||
Ensure that all your variable names are in camelCase. For example, use `employeeList` instead of `EmployeeList` or `employee_list`. | ||
|
||
- File Pattern: \.(js|ts|jsx|tsx)$ | ||
- AI Review: ON | ||
|
||
## Functions should have descriptive names | ||
|
||
Function names should clearly describe what the function does using verb-noun pairs when applicable, such as `calculateTotal` or `getUserInfo`. | ||
|
||
- File Pattern: \.(js|ts)$ | ||
- AI Review: ON | ||
|
||
## Constants should be in uppercase | ||
|
||
All constants should be declared using uppercase letters and underscore separators, like `MAX_RETRY_COUNT`. | ||
|
||
- File Pattern: \.(js|ts|jsx|tsx)$ | ||
- AI Review: ON | ||
|
||
## Comment public methods and classes | ||
|
||
All public methods and classes should have JSDoc comments describing their purpose, parameters, and return values. | ||
|
||
- File Pattern: \.(js|ts)$ | ||
- AI Review: ON | ||
|
||
## Avoid 'any' type in TypeScript | ||
|
||
The use of `any` type should be avoided in TypeScript files. Instead, use specific types or generics for better type safety. | ||
|
||
- File Pattern: \.ts$ | ||
- AI Review: ON | ||
|
||
## No console logs in production code | ||
|
||
Remove all `console.log` statements from the production code to avoid leaking information and cluttering the output. | ||
|
||
- File Pattern: \.(js|ts|jsx|tsx)$ | ||
- AI Review: ON | ||
|
||
## SQL Naming Conventions | ||
|
||
Use snake*case for all SQL identifiers, including table names and column names. Prefix tables with `tbl*`and views with`view\_`. | ||
|
||
- File Pattern: `\.(sql)$` | ||
- AI Review: ON | ||
|
||
## Commit Messages | ||
|
||
All commit messages should follow the conventional commit format for consistency and clarity. | ||
|
||
- File Pattern: `\.(md|txt|docx)$` | ||
- AI Review: OFF |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,88 @@ | ||
# AI Craftman | ||
# AI Review Flex | ||
|
||
AI reviewer configurable for you. | ||
`AI Review Flex` is a versatile GitHub Action that employs AI to review code against project-specific guidelines. By interpreting markdown coding guides, it delivers tailored feedback for each pull request to uphold your coding standards. | ||
|
||
## What is this | ||
## Prerequisites | ||
|
||
Fully configurable AI reviewers that review according to project-specific coding conventions. | ||
To use `AI Review Flex`, make sure you have: | ||
|
||
--- | ||
- A GitHub repository. | ||
- An OpenAI API Key. | ||
|
||
The rest of the README is WIP | ||
## Setup | ||
|
||
Incorporate this action in your workflow (`.github/workflows/main.yml`) with the required settings: | ||
|
||
```yaml | ||
- name: AI Review Flex | ||
uses: baseballyama/ai-review-flex@main | ||
with: | ||
BASE_REF: ${{ github.base_ref }} | ||
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }} | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
GITHUB_EVENT_PATH: ${{ github.event_path }} | ||
LANGUAGE: "English" | ||
CODING_GUIDE_PATH: "path/to/guide.md" | ||
CODING_GUIDE_LEVEL: 2 | ||
CODING_GUIDE_ENABLE_PATTERN: "AI Review.*ON" | ||
CODING_GUIDE_FILE_PATTERN: "File Pattern:\\s*`?(.+)`?$" | ||
CODING_GUIDE_READER: "path/to/custom_reader.js" | ||
DEBUG: false | ||
``` | ||
## Customizing Coding Rules | ||
Configure these parameters in the workflow for tailored coding standard reviews: | ||
| Parameter | Description | Required | Default | | ||
| ----------------------------- | -------------------------------------------- | -------- | --------------------------- | | ||
| `CODING_GUIDE_PATH` | Path to markdown coding rules. | No | - | | ||
| `CODING_GUIDE_LEVEL` | Markdown level to interpret as rules. | No | `2` | | ||
| `CODING_GUIDE_ENABLE_PATTERN` | Regex pattern to match reviewed rules. | No | `AI Review.*ON` | | ||
| `CODING_GUIDE_FILE_PATTERN` | Regex for file paths to apply rules. | No | `File Pattern:\s*/?(.+)/?$` | | ||
| `CODING_GUIDE_READER` | Path to a `.js` custom rule reader function. | No | - | | ||
| `LANGUAGE` | Language preference for reviews. | No | "English" | | ||
| `DEBUG` | Enable debug mode for detailed logs. | No | `false` | | ||
|
||
Example custom rule reader function: | ||
|
||
```javascript | ||
import * as fs from "node:fs"; | ||
export default async (): Promise<{ rule: string, filePattern: RegExp }[]> => { | ||
const markdown = await fs.promises.readFile("GUIDE.md", "utf-8"); | ||
return markdown | ||
.split("## ") | ||
.map((rule) => `## ${rule}`) | ||
.filter(() => { | ||
/** some filter process */ | ||
return true; | ||
}) | ||
.map((rule) => { | ||
const [, filePattern = ".*"] = rule.match(/File Pattern: (\S+)$/m) ?? []; | ||
return { rule, filePattern: RegExp(filePattern) }; | ||
}); | ||
}; | ||
``` | ||
|
||
Set the custom reader in your workflow as: | ||
|
||
```yaml | ||
CODING_GUIDE_READER: "path/to/your/rules-reader.js" | ||
``` | ||
## Example of Coding Rules | ||
Please see [ExampleOfCodigRules.md](./ExampleOfCodigRules.md) to check example of coding rules. | ||
## Usage | ||
Configure the action, and it will automatically review PRs based on your rules. | ||
## Contributing | ||
Suggestions and contributions are appreciated! Feel free to submit issues or pull requests. | ||
## License | ||
Distributed under the MIT License. |
This file contains 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
Oops, something went wrong.