diff --git a/.coderabbit.yaml b/.coderabbit.yaml new file mode 100644 index 00000000000..c23d2c71b22 --- /dev/null +++ b/.coderabbit.yaml @@ -0,0 +1,7 @@ +# yaml-language-server: $schema=https://storage.googleapis.com/coderabbit_public_assets/schema.v2.json + +reviews: + # Don't fail the "CodeRabbit" commit status when a review can't be performed + # (e.g. "Review rate limited"). The "AI Review" workflow enforces that either + # CodeRabbit or thepastaclaw has reviewed the PR instead. + fail_commit_status: false diff --git a/.github/workflows/pr-ai-review.yml b/.github/workflows/pr-ai-review.yml new file mode 100644 index 00000000000..f392b711f0f --- /dev/null +++ b/.github/workflows/pr-ai-review.yml @@ -0,0 +1,55 @@ +name: "AI Review" + +on: + pull_request: + types: + - opened + - reopened + - ready_for_review + - synchronize + pull_request_review: + types: + - submitted + +permissions: + pull-requests: read + +concurrency: + group: ai-review-${{ github.event.pull_request.number }} + cancel-in-progress: true + +jobs: + ai-review: + name: CodeRabbit or PastaClaw review + runs-on: ubuntu-24.04 + steps: + - name: Check for a review from CodeRabbit or thepastaclaw + uses: actions/github-script@v7 + with: + script: | + const reviewers = new Set(['coderabbitai[bot]', 'coderabbitai', 'thepastaclaw']); + + const reviews = await github.paginate(github.rest.pulls.listReviews, { + owner: context.repo.owner, + repo: context.repo.repo, + pull_number: context.payload.pull_request.number, + }); + + const found = reviews.filter( + (review) => + review.state !== 'PENDING' && + reviewers.has(review.user?.login?.toLowerCase()) + ); + + if (found.length > 0) { + const authors = [...new Set(found.map((review) => review.user.login))]; + core.info(`Found ${found.length} review(s) from: ${authors.join(', ')}`); + return; + } + + core.setFailed( + 'No review from CodeRabbit or thepastaclaw yet. This check passes ' + + 'once either of them submits a review, so a rate-limited ' + + 'CodeRabbit does not block the PR when thepastaclaw has reviewed ' + + '(or vice versa). It re-runs automatically when a review is submitted.' + );