diff --git a/.github/workflows/gemini-review.yml b/.github/workflows/gemini-review.yml index dc525cd74..4e580fd1d 100644 --- a/.github/workflows/gemini-review.yml +++ b/.github/workflows/gemini-review.yml @@ -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 }}' @@ -106,4 +107,8 @@ jobs: ] } } - prompt: '/gemini-review' + extensions: | + [ + "https://github.com/gemini-cli-extensions/code-review" + ] + prompt: '/code-review pr-review' diff --git a/evals/pr-review.eval.ts b/evals/pr-review.eval.ts index 05fa9e8ba..1f2f68baf 100644 --- a/evals/pr-review.eval.ts +++ b/evals/pr-review.eval.ts @@ -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'; @@ -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) { @@ -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, ); diff --git a/examples/workflows/pr-review/README.md b/examples/workflows/pr-review/README.md index 2b91c5564..603ac7f1f 100644 --- a/examples/workflows/pr-review/README.md +++ b/examples/workflows/pr-review/README.md @@ -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 @@ -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 @@ -216,7 +215,7 @@ 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:** @@ -224,7 +223,7 @@ The review prompt is defined in the `gemini-review.toml` file. The action automa ```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: @@ -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: + + ```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" diff --git a/examples/workflows/pr-review/gemini-review.yml b/examples/workflows/pr-review/gemini-review.yml index 28313594f..b400b28e4 100644 --- a/examples/workflows/pr-review/gemini-review.yml +++ b/examples/workflows/pr-review/gemini-review.yml @@ -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 }}' @@ -106,4 +107,8 @@ jobs: ] } } - prompt: '/gemini-review' + extensions: | + [ + "https://github.com/gemini-cli-extensions/code-review" + ] + prompt: '/code-review pr-review'