feat(ci): migrate AI review to self-hosted PR-Agent

This commit is contained in:
Tam Nhu Tran committed 2026-04-14 12:39:52 -04:00
1 parent 9545499487
commit 25216eaf33
14 files changed
+179 -3047

No files matched your search

@@ -2,35 +2,36 @@ import { describe, expect, test } from 'bun:test';
import * as fs from 'node:fs';
import * as path from 'node:path';
function loadWorkflow() {
const workflowPath = path.resolve(import.meta.dir, '../../../../.github/workflows/ai-review.yml');
return fs.readFileSync(workflowPath, 'utf8');
function resolvePath(relativePath: string) {
return path.resolve(import.meta.dir, relativePath);
}
describe('ai-review workflow', () => {
test('uses the claude-code-action reviewer path with configurable review runtime and PR-sha comment markers', () => {
const workflow = loadWorkflow();
describe('PR-Agent review lane migration', () => {
test('keeps ai-review.yml as the PR-Agent workflow on the self-hosted cliproxy runner', () => {
const workflowPath = resolvePath('../../../../.github/workflows/ai-review.yml');
const prAgentConfigPath = resolvePath('../../../../.pr_agent.toml');
expect(workflow).toContain('timeout-minutes: 20');
expect(workflow).toContain('Variables: AI_REVIEW_BASE_URL, AI_REVIEW_MODEL');
expect(workflow).toContain('Secrets: AI_REVIEW_API_KEY');
expect(workflow).toContain('ANTHROPIC_BASE_URL: ${{ vars.AI_REVIEW_BASE_URL }}');
expect(workflow).toContain('REVIEW_MODEL: ${{ vars.AI_REVIEW_MODEL }}');
expect(workflow).toContain('ANTHROPIC_AUTH_TOKEN: ${{ secrets.AI_REVIEW_API_KEY }}');
expect(workflow).toContain('ANTHROPIC_MODEL: ${{ vars.AI_REVIEW_MODEL }}');
expect(workflow).toContain('ANTHROPIC_DEFAULT_OPUS_MODEL: ${{ vars.AI_REVIEW_MODEL }}');
expect(workflow).toContain('ANTHROPIC_DEFAULT_SONNET_MODEL: ${{ vars.AI_REVIEW_MODEL }}');
expect(workflow).toContain('ANTHROPIC_DEFAULT_HAIKU_MODEL: ${{ vars.AI_REVIEW_MODEL }}');
expect(workflow).toContain('uses: anthropics/claude-code-action@v1');
expect(workflow).toContain('anthropic_api_key: ${{ secrets.AI_REVIEW_API_KEY }}');
expect(workflow).toContain('--model ${{ env.REVIEW_MODEL }}');
expect(workflow).toContain('--max-turns 45');
expect(workflow).toContain('--json-schema');
expect(workflow).toContain('normalize-ai-review-output.mjs');
expect(workflow).not.toContain('build-ai-review-packet.mjs');
expect(workflow).not.toContain('run-ai-review-direct.mjs');
expect(workflow).toContain('pr:${{ needs.prepare.outputs.pr_number }}');
expect(workflow).toContain('sha:${{ needs.prepare.outputs.head_sha }}');
expect(workflow).not.toContain('run:${{ github.run_id }}');
expect(fs.existsSync(workflowPath)).toBe(true);
expect(fs.existsSync(prAgentConfigPath)).toBe(true);
const workflow = fs.readFileSync(workflowPath, 'utf8');
const config = fs.readFileSync(prAgentConfigPath, 'utf8');
expect(workflow).toContain('name: AI Code Review');
expect(workflow).toContain('runs-on: [self-hosted, cliproxy]');
expect(workflow).toContain('uses: qodo-ai/pr-agent');
expect(workflow).toContain('OPENAI.API_BASE');
expect(workflow).toContain('OPENAI_KEY');
expect(workflow).toContain('config.model');
expect(workflow).toContain('github_action_config.auto_review');
expect(workflow).not.toContain('uses: anthropics/claude-code-action@v1');
expect(workflow).not.toContain('AI_REVIEW_API_KEY');
expect(config).toContain('[config]');
expect(config).toContain('git_provider = "github"');
expect(config).toMatch(/\bmodel\s*=\s*"[^"\n]+"/);
expect(config).toContain('[pr_reviewer]');
expect(config).not.toContain('auto_review = true');
expect(config).not.toContain('claude-code-action');
});
});