-
Notifications
You must be signed in to change notification settings - Fork 88
feat: add CodeRabbit integration for AI-powered code review #1315
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
jeremyeder
wants to merge
5
commits into
ambient-code:main
Choose a base branch
from
jeremyeder:coderabbit-integration-clean
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from 2 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
07d4dda
feat: add CodeRabbit integration for AI-powered code review
c2f0560
fix: replace pre-commit hook with command-type review gate
c0c2a70
fix: address CodeRabbit review findings
a06dad5
docs: add CodeRabbit bookmarks, update docs for review gate
09da874
fix: update smoke test and integration test for review gate
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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 hidden or 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,129 @@ | ||
| name: CodeRabbit Integration Smoke Test | ||
|
|
||
| # Validates the CodeRabbit integration works end-to-end: | ||
| # - CLI installs and authenticates | ||
| # - Can review files against the real CodeRabbit API | ||
| # - Config file (.coderabbit.yaml) is valid | ||
|
|
||
| on: | ||
| pull_request: | ||
| branches: [main] | ||
| paths: | ||
| - '.coderabbit.yaml' | ||
| - 'components/backend/handlers/coderabbit_auth.go' | ||
| - 'components/backend/handlers/integration_validation.go' | ||
| - 'components/frontend/src/components/coderabbit-connection-card.tsx' | ||
| - 'components/runners/ambient-runner/ambient_runner/platform/auth.py' | ||
| - 'scripts/pre-commit/coderabbit-review.sh' | ||
| - '.github/workflows/coderabbit-smoke-test.yml' | ||
|
|
||
| workflow_dispatch: | ||
|
|
||
| schedule: | ||
| - cron: '0 6 * * 1' # Weekly Monday 6am UTC | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| concurrency: | ||
| group: coderabbit-smoke-${{ github.event.pull_request.number || github.ref }} | ||
| cancel-in-progress: true | ||
|
|
||
| jobs: | ||
| smoke-test: | ||
| name: CodeRabbit Smoke Test | ||
| runs-on: ubuntu-latest | ||
| timeout-minutes: 10 | ||
|
|
||
| steps: | ||
| - name: Checkout code | ||
| uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6 | ||
|
|
||
| - name: Set up Node.js | ||
| uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6 | ||
| with: | ||
| node-version: '20' | ||
|
|
||
| - name: Install CodeRabbit CLI | ||
| run: npm install -g coderabbit | ||
|
|
||
| - name: Verify CLI installed | ||
| run: | | ||
| coderabbit --version | ||
| echo "CLI binary: $(which coderabbit)" | ||
|
|
||
| - name: Validate .coderabbit.yaml schema | ||
| run: | | ||
| echo "=== Validating .coderabbit.yaml ===" | ||
| python3 -c " | ||
| import yaml, sys | ||
| with open('.coderabbit.yaml') as f: | ||
| config = yaml.safe_load(f) | ||
| assert 'reviews' in config, 'Missing reviews section' | ||
| assert 'language' in config, 'Missing language field' | ||
| print(f'Config valid: {len(config)} top-level keys') | ||
| print(f'Reviews profile: {config[\"reviews\"].get(\"profile\", \"not set\")}') | ||
| print(f'Auto review: {config[\"reviews\"].get(\"auto_review\", {}).get(\"enabled\", False)}') | ||
| print(f'Tools configured: {len(config[\"reviews\"].get(\"tools\", {}))}') | ||
| " | ||
| echo "PASSED: .coderabbit.yaml is valid" | ||
|
|
||
| - name: Run CodeRabbit review on config file | ||
| env: | ||
| CODERABBIT_API_KEY: ${{ secrets.CODERABBIT_API_KEY }} | ||
| run: | | ||
| echo "=== Running CodeRabbit review against real API ===" | ||
|
|
||
| # Skip if no API key (fork PRs, missing secret) | ||
| if [ -z "$CODERABBIT_API_KEY" ]; then | ||
| echo "CODERABBIT_API_KEY not set - skipping live review" | ||
| echo "This is expected for fork PRs or when the secret is not configured" | ||
| exit 0 | ||
| fi | ||
|
|
||
| # Review the config file itself using agent mode for structured output | ||
| EXIT_CODE=0 | ||
| OUTPUT=$(coderabbit review \ | ||
| --agent \ | ||
| --files .coderabbit.yaml \ | ||
| --api-key "$CODERABBIT_API_KEY" \ | ||
| 2>&1) || EXIT_CODE=$? | ||
|
|
||
| echo "$OUTPUT" | ||
|
|
||
| # Auth errors are fatal | ||
| if echo "$OUTPUT" | grep -qiE "unauthorized|forbidden|invalid.*key"; then | ||
| echo "FAILED: CodeRabbit API key appears invalid" | ||
| exit 1 | ||
| fi | ||
|
|
||
| # Non-zero exit from CLI is a real failure | ||
| if [ "$EXIT_CODE" -ne 0 ]; then | ||
| echo "FAILED: coderabbit review exited $EXIT_CODE" | ||
| exit 1 | ||
| fi | ||
|
|
||
| echo "PASSED: CodeRabbit API responded successfully" | ||
|
|
||
| - name: Verify pre-commit hook skips gracefully | ||
| run: | | ||
| echo "=== Testing pre-commit hook graceful skip ===" | ||
| unset CODERABBIT_API_KEY | ||
|
|
||
| chmod +x scripts/pre-commit/coderabbit-review.sh | ||
| OUTPUT=$(scripts/pre-commit/coderabbit-review.sh 2>&1) | ||
| EXIT_CODE=$? | ||
|
|
||
| echo "$OUTPUT" | ||
|
|
||
| if [ "$EXIT_CODE" -ne 0 ]; then | ||
| echo "FAILED: Hook should exit 0 when skipping" | ||
| exit 1 | ||
| fi | ||
|
|
||
| if ! echo "$OUTPUT" | grep -qiE "not found|not set|skipping"; then | ||
| echo "FAILED: Hook should print a skip message" | ||
| exit 1 | ||
| fi | ||
|
|
||
| echo "PASSED: Pre-commit hook skips gracefully" | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.