|
| 1 | +name: AI PR Review |
| 2 | + |
| 3 | +on: |
| 4 | + pull_request: |
| 5 | + types: [opened, synchronize] |
| 6 | + paths: |
| 7 | + - "src/**" |
| 8 | + - "test/**" |
| 9 | + - "package.json" |
| 10 | + - "bun.lock" |
| 11 | + - "tsconfig.json" |
| 12 | + - "eslint.config.*" |
| 13 | + - "build.ts" |
| 14 | + - ".github/workflows/ai-pr-review.yml" |
| 15 | + |
| 16 | +concurrency: |
| 17 | + group: ai-pr-review-${{ github.event.pull_request.number }} |
| 18 | + cancel-in-progress: true |
| 19 | + |
| 20 | +permissions: |
| 21 | + contents: read |
| 22 | + pull-requests: write |
| 23 | + |
| 24 | +jobs: |
| 25 | + review: |
| 26 | + if: >- |
| 27 | + github.event.pull_request.head.repo.full_name == github.repository && |
| 28 | + github.event.pull_request.draft == false |
| 29 | + runs-on: ubuntu-latest |
| 30 | + timeout-minutes: 20 |
| 31 | + |
| 32 | + steps: |
| 33 | + - name: Checkout PR |
| 34 | + uses: actions/checkout@v4 |
| 35 | + with: |
| 36 | + fetch-depth: 0 |
| 37 | + |
| 38 | + - name: Setup Bun |
| 39 | + uses: oven-sh/setup-bun@v2 |
| 40 | + |
| 41 | + - name: Install dependencies |
| 42 | + run: bun install |
| 43 | + |
| 44 | + - name: Verify secrets present |
| 45 | + env: |
| 46 | + ANTHROPIC_API_KEY: ${{ secrets.ANTHROPIC_API_KEY }} |
| 47 | + MINIMAX_API_KEY: ${{ secrets.MINIMAX_API_KEY }} |
| 48 | + run: | |
| 49 | + : "${ANTHROPIC_API_KEY:?Missing ANTHROPIC_API_KEY secret (powers the review agent)}" |
| 50 | + if [[ -z "${MINIMAX_API_KEY:-}" ]]; then |
| 51 | + echo "::notice::MINIMAX_API_KEY not set — unit tests only; no live mmx API smoke tests." |
| 52 | + else |
| 53 | + echo "MINIMAX_API_KEY present — live API smoke tests allowed." |
| 54 | + fi |
| 55 | +
|
| 56 | + - name: Run Claude Code review |
| 57 | + uses: anthropics/claude-code-action@v1.0.102 |
| 58 | + env: |
| 59 | + ANTHROPIC_BASE_URL: https://api.minimax.io/anthropic |
| 60 | + # For mmx CLI live calls only — never paste into prompt or PR comments. |
| 61 | + MINIMAX_API_KEY: ${{ secrets.MINIMAX_API_KEY }} |
| 62 | + PR_NUMBER: ${{ github.event.pull_request.number }} |
| 63 | + PR_TITLE: ${{ github.event.pull_request.title }} |
| 64 | + PR_URL: ${{ github.event.pull_request.html_url }} |
| 65 | + PR_AUTHOR: ${{ github.event.pull_request.user.login }} |
| 66 | + PR_BASE_SHA: ${{ github.event.pull_request.base.sha }} |
| 67 | + PR_HEAD_SHA: ${{ github.event.pull_request.head.sha }} |
| 68 | + REPO_FULL_NAME: ${{ github.repository }} |
| 69 | + with: |
| 70 | + anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }} |
| 71 | + github_token: ${{ secrets.GITHUB_TOKEN }} |
| 72 | + use_sticky_comment: true |
| 73 | + claude_args: | |
| 74 | + --model MiniMax-M2.7-highspeed |
| 75 | + --max-turns 300 |
| 76 | + --allowed-tools Bash,Read,Glob,Grep |
| 77 | + prompt: | |
| 78 | + Hi — you're helping review a pull request for **mmx-cli**, the MiniMax terminal CLI (TypeScript + Bun). |
| 79 | +
|
| 80 | + **Goal:** Automated testing of user changes, ensuring all test cases pass. Be thorough but friendly; write the PR comment like a helpful teammate, not a linter bot. |
| 81 | +
|
| 82 | + ## This PR |
| 83 | + - Repo: ${REPO_FULL_NAME} |
| 84 | + - PR #${PR_NUMBER}: ${PR_TITLE} |
| 85 | + - Link: ${PR_URL} |
| 86 | + - Author: ${PR_AUTHOR} |
| 87 | + - Base → Head: ${PR_BASE_SHA} → ${PR_HEAD_SHA} |
| 88 | +
|
| 89 | + ## Credentials (already configured — do NOT put secrets in the prompt or PR comment) |
| 90 | + - **You (the reviewer)** run on MiniMax via `ANTHROPIC_BASE_URL`; the API key is injected by GitHub Actions — you don't need to type or echo it. |
| 91 | + - **mmx CLI live API tests** (optional): if `$MINIMAX_API_KEY` is set in the environment, you may run targeted smoke tests, e.g. `bun run dev -- <subcommand> ...` or a built binary with `--api-key "$MINIMAX_API_KEY"`. Never print, log, or commit the key. If unset, skip live API calls and say so briefly in the comment. |
| 92 | +
|
| 93 | + ## How to review |
| 94 | + 1. Read `AGENTS.md` for project conventions. |
| 95 | + 2. Inspect the actual change set: `gh pr diff ${PR_NUMBER}` — only judge what this PR changes. |
| 96 | + 3. **Required checks** (must all pass): |
| 97 | + - `bun run typecheck` |
| 98 | + - `bun test` |
| 99 | + - `bun run lint` |
| 100 | + 4. **Optional** (when `MINIMAX_API_KEY` is set and the diff touches user-facing commands): build once (`bun run build:dev` or `bun run dev`) and smoke-test the affected `mmx` paths with minimal, cheap calls. Skip expensive or destructive operations. |
| 101 | + 5. Skim the diff for obvious bugs, missing tests, or breaking CLI behavior — mention only blocking/major items. |
| 102 | +
|
| 103 | + ## PR comment (English, Markdown) |
| 104 | + Post exactly one sticky review via `gh pr comment ${PR_NUMBER}`: |
| 105 | + - Remove any older comment that contains `<!-- ai-pr-review -->`. |
| 106 | + - New comment must include `<!-- ai-pr-review -->`. |
| 107 | + - Structure: short summary → **Checks** table (command + pass/fail + one-line note) → issues by file (if any) → concrete fix suggestions → verdict emoji line. |
| 108 | + - Do not reference other PR numbers (only #${PR_NUMBER} if needed). |
| 109 | +
|
| 110 | + **Verdict** |
| 111 | + - ✅ **Approve** — all required checks green, no blocking issues |
| 112 | + - 🛑 **Request Changes** — failing tests/lint/types or blocking code problems |
| 113 | + - ❌ **Error** — environment/tooling broke; explain what failed |
0 commit comments