Skip to content

Commit 632a3b1

Browse files
xlcbkchr
andauthored
add ai review workflow (#10394)
Integrate a generic review bot for new PR it can only be dispatched manually in actions for now. We can enable it on new PRs or other conditions later if needed. Future tasks: - command bot integration so non github org users can request review - polkadot-sdk specific prompts related: polkadot-fellows/runtimes#1012 --------- Co-authored-by: Bastian Köcher <[email protected]> Co-authored-by: Bastian Köcher <[email protected]>
1 parent 72874f1 commit 632a3b1

File tree

4 files changed

+63
-3
lines changed

4 files changed

+63
-3
lines changed

.config/review.polkacodes.yml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
rules:
2+
- repo: polka-codes/prompts
3+
path: review/preamble.md
4+
branch: master
5+
- repo: polka-codes/prompts
6+
path: review/rust.md
7+
branch: master
8+
- repo: polka-codes/prompts
9+
path: review/polkadot-sdk.md
10+
branch: master

.github/scripts/cmd/cmd.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -545,7 +545,7 @@ def main():
545545
# Output labels as JSON for GitHub Action
546546
import json
547547
labels_output = {"labels": final_labels}
548-
print(f"LABELS_JSON: {json.dumps(labels_output)}")
548+
print_and_log(f"LABELS_JSON: {json.dumps(labels_output)}")
549549
except ValueError as e:
550550
print_and_log(f'❌ {e}')
551551

.github/workflows/ai-review.yml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
name: AI PR Review
2+
3+
on:
4+
# pull_request: # enable this when we think this is ready
5+
# types: [opened, ready_for_review]
6+
workflow_dispatch:
7+
inputs:
8+
pr_number:
9+
description: 'PR number to review'
10+
required: true
11+
type: number
12+
13+
permissions:
14+
contents: read
15+
pull-requests: write
16+
17+
concurrency:
18+
group: review-pr-${{ github.event.inputs.pr_number || github.event.number }}
19+
cancel-in-progress: true
20+
21+
jobs:
22+
review:
23+
timeout-minutes: 10
24+
runs-on: ubuntu-latest
25+
steps:
26+
- name: Checkout repository
27+
uses: actions/checkout@v4
28+
with:
29+
fetch-depth: 0
30+
31+
- name: Process PR
32+
uses: polka-codes/action@v2
33+
with:
34+
pr_number: ${{ github.event.inputs.pr_number || github.event.number }}
35+
review: true
36+
config: .config/review.polkacodes.yml
37+
env:
38+
POLKA_API_PROVIDER: google
39+
POLKA_MODEL: gemini-3-pro-preview
40+
GITHUB_TOKEN: ${{ github.token }}
41+
POLKA_API_KEY: ${{ secrets.GEMINI_API_KEY }}
42+
POLKA_BUDGET: 5
43+

.github/workflows/cmd-run.yml

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -293,12 +293,19 @@ jobs:
293293
repository: ${{ env.REPO }}
294294
ref: ${{ env.PR_BRANCH }}
295295

296-
- name: Download all artifacts
296+
- name: Download command-diff artifact
297297
uses: actions/download-artifact@018cc2cf5baa6db3ef3c5f8a56943fffe632ef53 # v6.0.0
298298
with:
299299
name: command-diff
300300
path: command-diff
301301

302+
- name: Download command-output artifact
303+
if: startsWith(github.event.inputs.cmd, 'label')
304+
uses: actions/download-artifact@018cc2cf5baa6db3ef3c5f8a56943fffe632ef53 # v6.0.0
305+
with:
306+
name: command-output
307+
path: command-output
308+
302309
- name: Apply labels for label command
303310
if: startsWith(github.event.inputs.cmd, 'label')
304311
uses: actions/github-script@ed597411d8f924073f98dfc5c65a23a2325f34cd # v8.0.0
@@ -310,7 +317,7 @@ jobs:
310317
let labels = [];
311318
312319
try {
313-
const output = fs.readFileSync('/tmp/cmd/command_output.log', 'utf8');
320+
const output = fs.readFileSync('command-output/command_output.log', 'utf8');
314321
315322
// Parse JSON labels from output - look for "LABELS_JSON: {...}"
316323
const jsonMatch = output.match(/LABELS_JSON: (.+)/);

0 commit comments

Comments
 (0)