|
1 | 1 | # Smart AI Code Review Action |
2 | 2 |
|
3 | | -AI-powered code review with **intelligent fallback system**: |
4 | | -1. **GitHub Models** (primary, fastest) |
5 | | -2. **Ollama** (fallback for rate limits) |
6 | | -3. **Static review** (final fallback) |
| 3 | +[](https://github.com/marketplace/actions/smart-ai-code-review-action) |
7 | 4 |
|
8 | | -## Features |
| 5 | +An intelligent GitHub Action that provides automated, AI-powered code reviews on your pull requests. It features a resilient fallback system, using **GitHub Models** as the primary provider and **Ollama** for local models as a backup, ensuring you always get a review. |
9 | 6 |
|
10 | | -✅ **Smart Diff Prioritization** - Focuses on critical files |
11 | | -✅ **Multi-Model Support** - GitHub Models + Ollama fallback |
12 | | -✅ **Rate Limit Resilience** - Never fails due to API limits |
13 | | -✅ **Comprehensive Reviews** - Security, performance, best practices |
14 | | -✅ **Zero Configuration** - Works out of the box |
| 7 | +## Key Features |
| 8 | + |
| 9 | +- 🧠 **Intelligent Diff Analysis**: Automatically prioritizes critical files in large pull requests to stay within token limits. |
| 10 | +- 🔄 **Resilient Fallback System**: If GitHub Models API fails or is rate-limited, it seamlessly switches to a self-hosted Ollama model. |
| 11 | +- 🤖 **Multi-Provider Support**: Natively supports GitHub Models and any model compatible with Ollama. |
| 12 | +- ✅ **Comprehensive Reviews**: Analyzes code for security vulnerabilities, performance bottlenecks, best practices, and style. |
| 13 | +- ⚙️ **Highly Configurable**: Fine-tune models, ignore specific files, and adjust AI parameters. |
| 14 | +- 🚀 **Zero-Setup Ready**: Works out of the box with the standard `GITHUB_TOKEN`. |
| 15 | + |
| 16 | +## How It Works |
| 17 | + |
| 18 | +1. **GitHub Models First**: The action first attempts to generate a high-quality review using the specified GitHub Model (e.g., `gpt-4o-mini`). |
| 19 | +2. **Ollama Fallback**: If the primary API call fails (due to errors, rate limits, etc.), the action automatically installs Ollama inside the runner, pulls your specified model (e.g., `qwen2:7b`), and generates the review. |
| 20 | +3. **Static Fallback**: If both AI providers fail, a structured error report is posted, ensuring you are never left without feedback. |
15 | 21 |
|
16 | 22 | ## Usage |
17 | 23 |
|
| 24 | +Create a workflow file (e.g., `.github/workflows/code-review.yml`) in your repository. |
| 25 | + |
| 26 | +### Basic Example |
| 27 | + |
| 28 | +This configuration uses the default settings and is the quickest way to get started. |
| 29 | + |
18 | 30 | ```yaml |
19 | | -- uses: euclidstellar/code-review-agent@v1 |
20 | | - with: |
21 | | - github-token: ${{ secrets.GITHUB_TOKEN }} |
22 | | - model: 'gpt-4o-mini' |
23 | | - ollama-model: 'qwen2.5:7b' # Fallback model |
| 31 | +name: AI Code Review |
| 32 | + |
| 33 | +on: |
| 34 | + pull_request: |
| 35 | + types: [opened, synchronize, reopened] |
| 36 | + |
| 37 | +permissions: |
| 38 | + contents: read |
| 39 | + pull-requests: write |
| 40 | + |
| 41 | +jobs: |
| 42 | + ai-review: |
| 43 | + runs-on: ubuntu-latest |
| 44 | + steps: |
| 45 | + - name: Checkout Repository |
| 46 | + uses: actions/checkout@v4 |
| 47 | + with: |
| 48 | + fetch-depth: 0 # Required to get the full git history for diffing |
| 49 | + |
| 50 | + - name: Run Smart AI Code Review |
| 51 | + uses: euclidstellar/code-review-agent@v1 # Replace with your repo name |
| 52 | + with: |
| 53 | + github-token: ${{ secrets.GITHUB_TOKEN }} |
24 | 54 | ``` |
25 | 55 |
|
26 | | -## Advanced Configuration |
| 56 | +### Advanced Example |
| 57 | +
|
| 58 | +This configuration customizes the models, temperature, and file patterns. |
27 | 59 |
|
28 | 60 | ```yaml |
29 | | -- uses: euclidstellar/code-review-agent@v1 |
30 | | - with: |
31 | | - github-token: ${{ secrets.GITHUB_TOKEN }} |
32 | | - model: 'gpt-4o-mini' |
33 | | - max-tokens: 6700 |
34 | | - temperature: 0.1 |
35 | | - enable-ollama: true |
36 | | - ollama-model: 'qwen2.5:7b' |
37 | | - use-ollama-fallback: true |
38 | | - ignore-patterns: '*.md,node_modules/**' |
| 61 | +name: Advanced AI Code Review |
| 62 | + |
| 63 | +on: |
| 64 | + pull_request: |
| 65 | + types: [opened, synchronize, reopened] |
| 66 | + |
| 67 | +permissions: |
| 68 | + contents: read |
| 69 | + pull-requests: write |
| 70 | + |
| 71 | +jobs: |
| 72 | + ai-review: |
| 73 | + runs-on: ubuntu-latest |
| 74 | + steps: |
| 75 | + - name: Checkout Repository |
| 76 | + uses: actions/checkout@v4 |
| 77 | + with: |
| 78 | + fetch-depth: 0 |
| 79 | + |
| 80 | + - name: Run Smart AI Code Review |
| 81 | + uses: euclidstellar/code-review-agent@v1 # Replace with your repo name |
| 82 | + with: |
| 83 | + github-token: ${{ secrets.GITHUB_TOKEN }} |
| 84 | + model: 'gpt-4o' |
| 85 | + ollama-model: 'llama3:8b' |
| 86 | + temperature: 0.5 |
| 87 | + ignore-patterns: '*.md,*.lock,dist/**' |
39 | 88 | ``` |
| 89 | +
|
| 90 | +## Inputs |
| 91 | +
|
| 92 | +See the [`action.yml`](action.yml) file for a full list of inputs and their descriptions. |
| 93 | + |
| 94 | +## Contributing |
| 95 | + |
| 96 | +Contributions are welcome! Please open an issue or submit a pull request. |
| 97 | + |
| 98 | +## License |
| 99 | + |
| 100 | +This project is licensed under the [MIT License](LICENSE). |
0 commit comments