forked from Expensify/App
-
Notifications
You must be signed in to change notification settings - Fork 0
139 lines (124 loc) · 5.29 KB
/
claude-review.yml
File metadata and controls
139 lines (124 loc) · 5.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
name: PR Reviews with Claude Code
permissions:
contents: read
pull-requests: write
on:
pull_request_target:
types: [opened, ready_for_review]
pull_request_review:
types: [submitted]
concurrency:
group: claude-review-${{ github.event.pull_request.html_url }}
cancel-in-progress: true
jobs:
validate:
if: github.event_name == 'pull_request_target'
uses: ./.github/workflows/contributorValidationGate.yml
with:
PR_NUMBER: ${{ github.event.pull_request.number }}
PR_AUTHOR: ${{ github.event.pull_request.user.login }}
AUTHOR_ASSOCIATION: ${{ github.event.pull_request.author_association }}
checkCPlusApproval:
if: github.event_name == 'pull_request_review' && github.event.review.state == 'approved'
runs-on: blacksmith-2vcpu-ubuntu-2404
outputs:
IS_CPLUS: ${{ steps.check.outputs.IS_CPLUS }}
steps:
- name: Checkout repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
with:
fetch-depth: 1
- name: Check Contributor+ membership
id: check
uses: ./.github/actions/composite/isContributorPlus
with:
USERNAME: ${{ github.event.review.user.login }}
OS_BOTIFY_TOKEN: ${{ secrets.OS_BOTIFY_TOKEN }}
review:
needs: [validate, checkCPlusApproval]
if: |
!cancelled()
&& github.event.pull_request.draft != true
&& !contains(github.event.pull_request.title, 'Revert')
&& (
(github.event_name == 'pull_request_target' && needs.validate.outputs.IS_AUTHORIZED == 'true')
|| (github.event_name == 'pull_request_review' && needs.checkCPlusApproval.outputs.IS_CPLUS == 'true')
)
runs-on: blacksmith-2vcpu-ubuntu-2404
env:
PR_NUMBER: ${{ github.event.pull_request.number }}
steps:
- name: Checkout repository
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6
with:
fetch-depth: 1
- name: Setup Node
uses: ./.github/actions/composite/setupNode
- name: Filter paths
uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3.0.2
id: filter
with:
filters: |
code:
- 'src/**'
docs:
- 'docs/**/*.md'
- 'docs/**/*.csv'
- name: Add claude utility scripts to PATH
run: |
echo "$GITHUB_WORKSPACE/.claude/scripts" >> "$GITHUB_PATH"
- name: Extract allowed rules from coding standards
run: |
"$GITHUB_WORKSPACE/.github/scripts/extractAllowedRules.sh" \
"$GITHUB_WORKSPACE/.claude/skills/coding-standards/rules" \
"$RUNNER_TEMP/allowed-rules.txt"
- name: Load code review JSON schema
id: schema
run: echo "json=$(jq -c . "$GITHUB_WORKSPACE/.claude/schemas/code-review-output.json")" >> "$GITHUB_OUTPUT"
- name: Run Claude Code (code)
id: code-review
if: steps.filter.outputs.code == 'true'
uses: anthropics/claude-code-action@ba026a3e56b9f646ae3b1be02dd9c0812aa2f8ae # v1.0.86
with:
display_report: "true"
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
github_token: ${{ secrets.GITHUB_TOKEN }}
allowed_non_write_users: "*"
prompt: "/review-code-pr REPO: ${{ github.repository }} PR_NUMBER: ${{ github.event.pull_request.number }}"
claude_args: |
--model claude-opus-4-6
--allowedTools "Task,Glob,Grep,Read,Bash(gh pr diff:*),Bash(gh pr view:*),Bash(check-compiler.sh:*)" --json-schema '${{ steps.schema.outputs.json }}'
- name: Post code review results
if: steps.code-review.outcome == 'success' && steps.filter.outputs.code == 'true'
env:
GH_TOKEN: ${{ github.token }}
STRUCTURED_OUTPUT: ${{ steps.code-review.outputs.structured_output }}
ALLOWED_RULES_FILE: ${{ runner.temp }}/allowed-rules.txt
run: |
if [ -z "$STRUCTURED_OUTPUT" ]; then
echo "::error::Claude Code Action returned empty structured output"
exit 1
fi
COUNT=$(echo "$STRUCTURED_OUTPUT" | jq '.violations | length')
if [ "$COUNT" -eq 0 ]; then
addPrReaction.sh "$PR_NUMBER"
else
echo "$STRUCTURED_OUTPUT" | jq -c '.violations[]' | while IFS= read -r v; do
PATH_ARG=$(echo "$v" | jq -r '.path')
BODY_ARG=$(echo "$v" | jq -r '.body')
LINE_ARG=$(echo "$v" | jq -r '.line')
createInlineComment.sh "$PATH_ARG" "$BODY_ARG" "$LINE_ARG" || true
done
fi
- name: Run Claude Code (docs)
if: steps.filter.outputs.docs == 'true'
uses: anthropics/claude-code-action@ba026a3e56b9f646ae3b1be02dd9c0812aa2f8ae # v1.0.86
with:
display_report: "true"
anthropic_api_key: ${{ secrets.ANTHROPIC_API_KEY }}
github_token: ${{ secrets.GITHUB_TOKEN }}
allowed_non_write_users: "*"
prompt: "/review-helpdot-pr REPO: ${{ github.repository }} PR_NUMBER: ${{ github.event.pull_request.number }}"
claude_args: |
--model claude-opus-4-6
--allowedTools "Task,Glob,Grep,Read,Bash(gh pr comment:*),Bash(gh pr diff:*),Bash(gh pr view:*),mcp__github_inline_comment__create_inline_comment"