Skip to content

Commit 71259cf

Browse files
authored
Consolidate AI review workflows and documentation (#9)
* docs: split reusable workflow guides * refactor: consolidate model review workflows * feat: allow selecting AI reviewers * feat: label AI inline review comments * fix: skip approval without reviewers * feat: configure AI reviewer models * chore: align AI reviewer reasoning defaults
1 parent 92d2ff3 commit 71259cf

13 files changed

Lines changed: 610 additions & 299 deletions

‎.github/workflows/ai-pr-review.yml‎

Lines changed: 51 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,36 @@ on:
1010
required: false
1111
type: string
1212
default: ""
13+
run-claude:
14+
description: Run the Claude pull request review
15+
required: false
16+
type: boolean
17+
default: true
18+
run-codex:
19+
description: Run the Codex pull request review
20+
required: false
21+
type: boolean
22+
default: true
23+
claude-model:
24+
description: Claude model ID to use through Amazon Bedrock
25+
required: false
26+
type: string
27+
default: us.anthropic.claude-opus-4-8
28+
claude-reasoning-effort:
29+
description: Claude reasoning effort
30+
required: false
31+
type: string
32+
default: xhigh
33+
codex-model:
34+
description: Codex model ID to use through Amazon Bedrock
35+
required: false
36+
type: string
37+
default: openai.gpt-5.6-sol
38+
codex-reasoning-effort:
39+
description: Codex reasoning effort
40+
required: false
41+
type: string
42+
default: xhigh
1343
secrets:
1444
BEDROCK_ROLE_ARN:
1545
description: IAM role used to invoke the AI review models
@@ -22,12 +52,20 @@ concurrency:
2252
cancel-in-progress: true
2353

2454
jobs:
55+
# Direct pull_request_target runs have no workflow_call inputs. Formatting
56+
# distinguishes a missing value from an explicit false supplied by a caller.
2557
approve_review:
2658
name: Approve AI PR review
2759
if: >-
28-
github.event.pull_request.user.login == 'dependabot[bot]' ||
29-
github.event.pull_request.draft ||
30-
github.event.pull_request.head.repo.full_name != github.repository
60+
(
61+
format('{0}', inputs['run-claude']) != 'false' ||
62+
format('{0}', inputs['run-codex']) != 'false'
63+
) &&
64+
(
65+
github.event.pull_request.user.login == 'dependabot[bot]' ||
66+
github.event.pull_request.draft ||
67+
github.event.pull_request.head.repo.full_name != github.repository
68+
)
3169
runs-on: ubuntu-latest
3270
environment: ai-pr-review
3371
permissions: {}
@@ -38,10 +76,11 @@ jobs:
3876
run: echo "Approved review of $HEAD_SHA"
3977

4078
claude-review:
41-
name: Generate Claude review
79+
name: Claude review
4280
needs: approve_review
4381
if: >-
4482
always() &&
83+
format('{0}', inputs['run-claude']) != 'false' &&
4584
(
4685
(
4786
github.event.pull_request.user.login != 'dependabot[bot]' &&
@@ -53,28 +92,20 @@ jobs:
5392
permissions:
5493
contents: read
5594
id-token: write
56-
pull-requests: read
95+
pull-requests: write
5796
uses: ./.github/workflows/claude-review.yml
5897
with:
5998
prompt-path: ${{ inputs['prompt-path'] }}
99+
model: ${{ inputs['claude-model'] || 'us.anthropic.claude-opus-4-8' }}
100+
reasoning-effort: ${{ inputs['claude-reasoning-effort'] || 'xhigh' }}
60101
secrets: inherit
61102

62-
claude-review-comment:
63-
name: Post Claude review
64-
needs: claude-review
65-
if: >-
66-
always() &&
67-
needs.claude-review.result == 'success'
68-
permissions:
69-
contents: read
70-
pull-requests: write
71-
uses: ./.github/workflows/claude-review-comment.yml
72-
73103
codex-review:
74-
name: Generate Codex review
104+
name: Codex review
75105
needs: approve_review
76106
if: >-
77107
always() &&
108+
format('{0}', inputs['run-codex']) != 'false' &&
78109
(
79110
(
80111
github.event.pull_request.user.login != 'dependabot[bot]' &&
@@ -86,19 +117,10 @@ jobs:
86117
permissions:
87118
contents: read
88119
id-token: write
89-
pull-requests: read
120+
pull-requests: write
90121
uses: ./.github/workflows/codex-review.yml
91122
with:
92123
prompt-path: ${{ inputs['prompt-path'] }}
124+
model: ${{ inputs['codex-model'] || 'openai.gpt-5.6-sol' }}
125+
reasoning-effort: ${{ inputs['codex-reasoning-effort'] || 'xhigh' }}
93126
secrets: inherit
94-
95-
codex-review-comment:
96-
name: Post Codex review
97-
needs: codex-review
98-
if: >-
99-
always() &&
100-
needs.codex-review.result == 'success'
101-
permissions:
102-
contents: read
103-
pull-requests: write
104-
uses: ./.github/workflows/codex-review-comment.yml

‎.github/workflows/claude-review-comment.yml‎

Lines changed: 0 additions & 47 deletions
This file was deleted.

‎.github/workflows/claude-review.yml‎

Lines changed: 81 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: Generate Claude PR Review
1+
name: Claude PR Review
22

33
on:
44
workflow_call:
@@ -8,6 +8,16 @@ on:
88
required: false
99
type: string
1010
default: ""
11+
model:
12+
description: Claude model ID to use through Amazon Bedrock
13+
required: false
14+
type: string
15+
default: us.anthropic.claude-opus-4-8
16+
reasoning-effort:
17+
description: Claude reasoning effort
18+
required: false
19+
type: string
20+
default: xhigh
1121
secrets:
1222
BEDROCK_ROLE_ARN:
1323
description: IAM role used to invoke Claude on Amazon Bedrock
@@ -27,6 +37,31 @@ jobs:
2737
pull-requests: read
2838

2939
steps:
40+
- name: Validate Claude review configuration
41+
id: review-config
42+
env:
43+
CLAUDE_MODEL: ${{ inputs['model'] }}
44+
CLAUDE_REASONING_EFFORT: ${{ inputs['reasoning-effort'] }}
45+
run: |
46+
set -euo pipefail
47+
48+
if [[ ! "$CLAUDE_MODEL" =~ ^[A-Za-z0-9][A-Za-z0-9._:/-]*$ ]]; then
49+
echo "::error::Claude model must be a non-empty model ID."
50+
exit 1
51+
fi
52+
53+
case "$CLAUDE_REASONING_EFFORT" in
54+
low|medium|high|xhigh|max)
55+
;;
56+
*)
57+
echo "::error::Claude reasoning effort must be low, medium, high, xhigh, or max."
58+
exit 1
59+
;;
60+
esac
61+
62+
echo "model=$CLAUDE_MODEL" >> "$GITHUB_OUTPUT"
63+
echo "reasoning_effort=$CLAUDE_REASONING_EFFORT" >> "$GITHUB_OUTPUT"
64+
3065
# pull_request_target exposes repository secrets, so only check out the
3166
# exact trusted base revision. The PR's code is never checked out.
3267
- name: Check out base branch
@@ -139,7 +174,8 @@ jobs:
139174
classify_inline_comments: "false"
140175
prompt: ${{ steps.review-inputs.outputs.prompt }}
141176
claude_args: |
142-
--model us.anthropic.claude-opus-4-8
177+
--model ${{ steps.review-config.outputs.model }}
178+
--effort ${{ steps.review-config.outputs.reasoning_effort }}
143179
--max-turns 20
144180
--allowedTools "Read,Grep,Glob"
145181
--disallowedTools "Bash,Write,Edit,NotebookEdit,WebFetch,WebSearch"
@@ -162,7 +198,8 @@ jobs:
162198
classify_inline_comments: "false"
163199
prompt: ${{ steps.review-inputs.outputs.prompt }}
164200
claude_args: |
165-
--model us.anthropic.claude-opus-4-8
201+
--model ${{ steps.review-config.outputs.model }}
202+
--effort ${{ steps.review-config.outputs.reasoning_effort }}
166203
--max-turns 20
167204
--allowedTools "Read,Grep,Glob"
168205
--disallowedTools "Bash,Write,Edit,NotebookEdit,WebFetch,WebSearch"
@@ -208,3 +245,44 @@ jobs:
208245
if-no-files-found: error
209246
overwrite: true
210247
retention-days: 1
248+
249+
post:
250+
name: Post Claude review
251+
needs: generate
252+
runs-on: ubuntu-latest
253+
timeout-minutes: 10
254+
permissions:
255+
contents: read
256+
pull-requests: write
257+
258+
steps:
259+
- name: Download Claude review
260+
uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1
261+
with:
262+
name: claude-review-${{ github.run_id }}
263+
path: ${{ runner.temp }}/claude-review
264+
265+
# Load the posting script from the same immutable revision as this
266+
# workflow. No pull request code is checked out or executed.
267+
- name: Check out AI review toolkit
268+
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
269+
with:
270+
repository: ${{ job.workflow_repository }}
271+
ref: ${{ job.workflow_sha }}
272+
path: .ai-review-toolkit
273+
sparse-checkout: scripts
274+
persist-credentials: false
275+
276+
- name: Post Claude review
277+
env:
278+
EXPECTED_BASE_SHA: ${{ github.event.pull_request.base.sha }}
279+
EXPECTED_HEAD_SHA: ${{ github.event.pull_request.head.sha }}
280+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
281+
PR_NUMBER: ${{ github.event.pull_request.number }}
282+
REVIEW_FILE: ${{ runner.temp }}/claude-review/claude-review.json
283+
run: |
284+
bash .ai-review-toolkit/scripts/post_ai_review.sh \
285+
claude \
286+
"$EXPECTED_BASE_SHA" \
287+
"$EXPECTED_HEAD_SHA" \
288+
"$REVIEW_FILE"

‎.github/workflows/codex-review-comment.yml‎

Lines changed: 0 additions & 47 deletions
This file was deleted.

0 commit comments

Comments
 (0)