Skip to content

Commit cb9e44d

Browse files
committed
feat: add Automated Code Review workflow
Setup a read-only code review pipeline using the google-antigravity SDK and GitHub Actions. The workflow runs on pull_request and triggers on maintainer PR opens or /review comments. It runs the review-pr skill to evaluate code quality, correctness, and architecture, outputting findings as GHA warning annotations.
1 parent b5d754e commit cb9e44d

43 files changed

Lines changed: 443 additions & 2626 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
name: Automated Code Review
2+
3+
# TODO: Eventually, use pull_request_target instead of pull_request.
4+
# pull_request_target runs in the base branch context and has access
5+
# to secrets (like GEMINI_API_KEY) even for fork PRs.
6+
# Using pull_request for now during setup/testing.
7+
on:
8+
pull_request:
9+
types: [opened]
10+
pull_request_review_comment:
11+
types: [created]
12+
13+
permissions:
14+
contents: read
15+
pull-requests: read
16+
17+
jobs:
18+
review:
19+
runs-on: ubuntu-latest
20+
# Trigger only if:
21+
# 1. It is a pull_request event, it is NOT a draft, and the author is a maintainer
22+
# (OWNER, MEMBER, or COLLABORATOR).
23+
# 2. OR it is a pull_request_review_comment event, the comment body has a line starting with "/review",
24+
# and the commenter is a maintainer.
25+
if: >
26+
(github.event_name == 'pull_request' && !github.event.pull_request.draft &&
27+
contains(fromJson('["OWNER", "MEMBER", "COLLABORATOR"]'), github.event.pull_request.author_association)) ||
28+
(github.event_name == 'pull_request_review_comment' &&
29+
(startsWith(github.event.comment.body, '/review') || contains(github.event.comment.body, '\n/review')) &&
30+
contains(fromJson('["OWNER", "MEMBER", "COLLABORATOR"]'), github.event.comment.author_association))
31+
steps:
32+
- name: Checkout PR Branch
33+
uses: actions/checkout@v7
34+
with:
35+
ref: ${{ github.event.pull_request.head.sha }}
36+
persist-credentials: false
37+
38+
- name: Checkout Reviewbot (Base Branch)
39+
uses: actions/checkout@v7
40+
with:
41+
sparse-checkout: |
42+
tools/private/reviewbot
43+
path: reviewbot
44+
45+
- name: Install uv
46+
uses: astral-sh/setup-uv@v8.1.0
47+
48+
- name: Set up Python
49+
run: uv python install 3.13
50+
51+
- name: Install Dependencies
52+
run: |
53+
uv pip install google-antigravity requests
54+
55+
- name: Run Antigravity Review
56+
env:
57+
GEMINI_API_KEY: ${{ secrets.GEMINI_API_KEY }}
58+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
59+
run: |
60+
uv run reviewbot/tools/private/reviewbot/antigravity_review.py \
61+
--prompt reviewbot/tools/private/reviewbot/prompt.txt

.github/workflows/on_comment.yaml

Lines changed: 0 additions & 140 deletions
This file was deleted.
Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
name: "On Issue Comment"
2+
3+
on:
4+
issue_comment:
5+
types: [created]
6+
7+
permissions:
8+
contents: write
9+
issues: write
10+
pull-requests: write
11+
12+
jobs:
13+
# This job always runs to prevent GHA from marking the run as failed when
14+
# all other jobs are skipped.
15+
noop:
16+
runs-on: ubuntu-latest
17+
steps:
18+
- run: echo "No-op"
19+
20+
parse_comment:
21+
runs-on: ubuntu-latest
22+
if: |
23+
github.event.issue.pull_request == null &&
24+
contains(github.event.issue.labels.*.name, 'type: release') &&
25+
(github.event.comment.author_association == 'OWNER' ||
26+
github.event.comment.author_association == 'MEMBER' ||
27+
github.event.comment.author_association == 'COLLABORATOR')
28+
outputs:
29+
command: ${{ steps.parse.outputs.command }}
30+
issue_number: ${{ github.event.issue.number }}
31+
backports: ${{ steps.parse.outputs.backports }}
32+
steps:
33+
- name: Parse comment
34+
id: parse
35+
env:
36+
COMMENT_BODY: ${{ github.event.comment.body }}
37+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
38+
run: |
39+
if echo "$COMMENT_BODY" | grep -qE '^[[:space:]]*/create-rc([[:space:]]|$)'; then
40+
echo "command=create-rc" >> "$GITHUB_OUTPUT"
41+
elif echo "$COMMENT_BODY" | grep -qE '^[[:space:]]*/prepare([[:space:]]|$)'; then
42+
echo "command=prepare" >> "$GITHUB_OUTPUT"
43+
elif echo "$COMMENT_BODY" | grep -qE '^[[:space:]]*/process-backports([[:space:]]|$)'; then
44+
echo "command=process-backports" >> "$GITHUB_OUTPUT"
45+
elif echo "$COMMENT_BODY" | grep -qE '^[[:space:]]*/add-backports([[:space:]]|$)'; then
46+
args=$(echo "$COMMENT_BODY" | grep -E '^[[:space:]]*/add-backports([[:space:]]|$)' | sed -E 's/^[[:space:]]*\/add-backports[[:space:]]*//')
47+
# Strip leading/trailing spaces and commas
48+
args=$(echo "$args" | sed -e 's/^[[:space:],]*//' -e 's/[[:space:],]*$//')
49+
# Replace internal spaces/commas with single comma
50+
csv=$(echo "$args" | sed -E 's/[[:space:],]+/ /g' | tr ' ' ',')
51+
if [ -n "$csv" ]; then
52+
echo "command=add-backports" >> "$GITHUB_OUTPUT"
53+
echo "backports=$csv" >> "$GITHUB_OUTPUT"
54+
else
55+
echo "command=none" >> "$GITHUB_OUTPUT"
56+
echo "Error: No PRs specified for add-backports." >&2
57+
gh api \
58+
--method POST \
59+
-H "Accept: application/vnd.github+json" \
60+
-H "X-GitHub-Api-Version: 2022-11-28" \
61+
/repos/${{ github.repository }}/issues/comments/${{ github.event.comment.id }}/reactions \
62+
-f "content=-1"
63+
fi
64+
elif echo "$COMMENT_BODY" | grep -qE '^[[:space:]]*/promote([[:space:]]|$)'; then
65+
echo "command=promote" >> "$GITHUB_OUTPUT"
66+
else
67+
echo "command=none" >> "$GITHUB_OUTPUT"
68+
fi
69+
70+
call_create_rc:
71+
needs: parse_comment
72+
if: needs.parse_comment.outputs.command == 'create-rc'
73+
uses: ./.github/workflows/release_create_rc.yaml
74+
with:
75+
issue: ${{ needs.parse_comment.outputs.issue_number }}
76+
comment_id: "${{ github.event.comment.id }}"
77+
secrets: inherit
78+
79+
call_prepare:
80+
needs: parse_comment
81+
if: needs.parse_comment.outputs.command == 'prepare'
82+
uses: ./.github/workflows/release_prepare.yaml
83+
with:
84+
issue: ${{ needs.parse_comment.outputs.issue_number }}
85+
secrets: inherit
86+
87+
call_process_backports:
88+
needs: parse_comment
89+
if: |
90+
needs.parse_comment.outputs.command == 'process-backports' ||
91+
needs.parse_comment.outputs.command == 'add-backports'
92+
uses: ./.github/workflows/release_process_backports.yaml
93+
with:
94+
issue: ${{ needs.parse_comment.outputs.issue_number }}
95+
add_backports: ${{ needs.parse_comment.outputs.command == 'add-backports' && needs.parse_comment.outputs.backports || '' }}
96+
comment_id: "${{ github.event.comment.id }}"
97+
secrets: inherit
98+
99+
call_promote:
100+
needs: parse_comment
101+
if: needs.parse_comment.outputs.command == 'promote'
102+
uses: ./.github/workflows/release_promote_rc.yaml
103+
with:
104+
issue: ${{ needs.parse_comment.outputs.issue_number }}
105+
secrets: inherit

0 commit comments

Comments
 (0)