Skip to content
Merged
Show file tree
Hide file tree
Changes from 8 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion .github/workflows/gemini-review.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ jobs:
PULL_REQUEST_NUMBER: '${{ github.event.pull_request.number || github.event.issue.number }}'
REPOSITORY: '${{ github.repository }}'
ADDITIONAL_CONTEXT: '${{ inputs.additional_context }}'
GEMINI_API_KEY: '${{ secrets.GEMINI_API_KEY }}'
Comment thread
cynthialong0-0 marked this conversation as resolved.
with:
gcp_location: '${{ vars.GOOGLE_CLOUD_LOCATION }}'
gcp_project_id: '${{ vars.GOOGLE_CLOUD_PROJECT }}'
Expand Down Expand Up @@ -106,4 +107,8 @@ jobs:
]
}
}
prompt: '/gemini-review'
extensions: |
[
"https://github.com/gemini-cli-extensions/code-review"
]
prompt: '/code-review pr-review'
19 changes: 12 additions & 7 deletions evals/pr-review.eval.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { describe, expect, it } from 'vitest';
import { TestRig } from './test-rig';
import { mkdirSync, copyFileSync, readFileSync } from 'node:fs';
import { mkdirSync, readFileSync, writeFileSync } from 'node:fs';
import { join } from 'node:path';
import { execSync } from 'node:child_process';

Expand All @@ -13,6 +13,8 @@ interface ReviewCase {

const datasetPath = join(__dirname, 'data/pr-review.json');
const dataset: ReviewCase[] = JSON.parse(readFileSync(datasetPath, 'utf-8'));
const REVIEW_TOML_URL =
'https://raw.githubusercontent.com/gemini-cli-extensions/code-review/main/commands/code-review.toml';

describe('PR Review Workflow', () => {
for (const item of dataset) {
Expand All @@ -22,14 +24,17 @@ describe('PR Review Workflow', () => {
const rig = new TestRig(`review-${item.id}`);
try {
rig.setupMockMcp();
mkdirSync(join(rig.testDir, '.gemini/commands'), { recursive: true });
copyFileSync(
'.github/commands/gemini-review.toml',
join(rig.testDir, '.gemini/commands/gemini-review.toml'),
);
const commandDir = join(rig.testDir, '.gemini/commands');
mkdirSync(commandDir, { recursive: true });

const response = await fetch(REVIEW_TOML_URL);
if (!response.ok)
throw new Error(`Failed to fetch TOML: ${response.statusText}`);
const tomlContent = await response.text();
writeFileSync(join(commandDir, 'code-review.toml'), tomlContent);

const stdout = await rig.run(
['--prompt', '/gemini-review', '--yolo'],
['--prompt', '"/code-review pr-review"', '--yolo'],
item.inputs,
);

Expand Down
26 changes: 16 additions & 10 deletions examples/workflows/pr-review/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ This document explains how to use the Gemini CLI on GitHub to automatically revi

## Overview

The PR Review workflow uses Google's Gemini AI to provide comprehensive code reviews for pull requests. It analyzes code quality, security, performance, and maintainability while providing constructive feedback in a structured format.
The PR Review workflow uses Google's Gemini AI and [code review extension](https://github.com/gemini-cli-extensions/code-review) to provide comprehensive code reviews for pull requests. It analyzes code quality, security, performance, and maintainability while providing constructive feedback in a structured format.

## Features

Expand Down Expand Up @@ -178,16 +178,15 @@ After posting all inline comments, the action submits the review with a final su
The action provides specific, actionable feedback directly on the relevant lines of code in the pull request. Each comment includes:

- **Priority**: An emoji indicating the severity of the feedback.
- 🔴 **Critical**: Must be fixed before merging (e.g., security vulnerabilities, breaking changes).
- 🟠 **High**: Should be addressed (e.g., performance issues, design flaws).
- 🟡 **Medium**: Recommended improvements (e.g., code quality, style).
- 🟢 **Low**: Nice-to-have suggestions (e.g., documentation, minor refactoring).
- 🔵 **Unclear**: Priority is not determined.
- **Critical**: Must be fixed before merging (e.g., security vulnerabilities, breaking changes).
- **High**: Should be addressed (e.g., performance issues, design flaws).
- **Medium**: Recommended improvements (e.g., code quality, style).
- **Low**: Nice-to-have suggestions (e.g., documentation, minor refactoring).
- **Suggestion**: A code block with a suggested change, where applicable.

**Example Inline Comment:**

> 🟢 Use camelCase for function names
> Use camelCase for function names
>
> ```suggestion
> myFunction
Expand Down Expand Up @@ -216,15 +215,15 @@ You can customize the workflow by modifying:

### Review Prompt Customization

The review prompt is defined in the `gemini-review.toml` file. The action automatically copies this file from `.github/commands/` to `.gemini/commands/` during execution.
The review prompt utilizes [code review extension](https://github.com/gemini-cli-extensions/code-review) and its defined prompt.

**To customize the review prompt:**

1. Copy the TOML file to your repository:

```bash
mkdir -p .gemini/commands
curl -o .gemini/commands/gemini-review.toml https://raw.githubusercontent.com/google-github-actions/run-gemini-cli/main/examples/workflows/pr-review/gemini-review.toml
curl -o .gemini/commands/gemini-review.toml https://raw.githubusercontent.com/gemini-cli-extensions/code-review/main/commands/code-review.toml
```

2. Edit `.gemini/commands/gemini-review.toml` to customize:
Expand All @@ -233,7 +232,14 @@ The review prompt is defined in the `gemini-review.toml` file. The action automa
- Include project-specific guidelines
- Adjust review depth and focus areas

3. Commit the file to your repository:
3. Edit `.github/workflows/gemini-review.yml` to use the customized prompt:

Comment thread
cynthialong0-0 marked this conversation as resolved.
```yml
- prompt: '/code-review pr-review'
+ prompt: '/gemini-review pr-review'
```

4. Commit the file to your repository:
```bash
git add .gemini/commands/gemini-review.toml
git commit -m "feat: customize PR review prompt"
Expand Down
7 changes: 6 additions & 1 deletion examples/workflows/pr-review/gemini-review.yml
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ jobs:
PULL_REQUEST_NUMBER: '${{ github.event.pull_request.number || github.event.issue.number }}'
REPOSITORY: '${{ github.repository }}'
ADDITIONAL_CONTEXT: '${{ inputs.additional_context }}'
GEMINI_API_KEY: '${{ secrets.GEMINI_API_KEY }}'
with:
gcp_location: '${{ vars.GOOGLE_CLOUD_LOCATION }}'
gcp_project_id: '${{ vars.GOOGLE_CLOUD_PROJECT }}'
Expand Down Expand Up @@ -106,4 +107,8 @@ jobs:
]
}
}
prompt: '/gemini-review'
extensions: |
[
"https://github.com/gemini-cli-extensions/code-review"
]
prompt: '/code-review pr-review'
Loading