Repository navigation
158 lines (155 loc) · 7.13 KB
/
Copy pathcode-review.yml
File metadata and controls
158 lines (155 loc) · 7.13 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
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
name: AI Code Review (Reusable)
on:
workflow_call:
inputs:
openai-model:
description: 'OpenAI model to use for the review'
required: false
type: string
default: 'deepseek-v4-flash'
openai-fallback-model:
description: 'Fallback model used if the primary model fails or times out.'
required: false
type: string
default: 'glm-5.3-flash'
openai-base-url:
description: 'OpenAI API base URL (for custom endpoints or proxies)'
required: false
type: string
default: 'https://tokenhub.tencentmaas.com/plan/v3'
openai-timeout:
description: 'Seconds to wait for the connection to the API. Model response time is not limited.'
required: false
type: string
default: '15'
openai-max-retries:
description: 'Retry count for timeouts/429/5xx errors'
required: false
type: string
default: '5'
review-language:
description: 'Language of the review comment (e.g. en, zh, ja, ko, es, fr, de, ru, pt)'
required: false
type: string
default: 'cn'
max-tokens-per-chunk:
description: 'Max tokens of diff per review call, for large pull requests'
required: false
type: string
default: '131072'
agent-context-tokens:
description: >-
The transcript a review run may carry before it is compacted, in tokens.
A cost and latency budget rather than the model's limit — every agent step
re-sends the whole transcript, so this multiplies by the step count.
required: false
type: string
default: '200000'
silent-mode:
description: "Set 'true' to post a comment instead of a review. Only affects the prose-fallback path; the normal tool-driven review posts inline comments regardless."
required: false
type: string
default: 'true'
dry-run:
description: "Set 'true' to print the review without posting anything — useful for trying the bot out on a pull request"
required: false
type: string
default: 'false'
state-dir:
description: 'Root for the per-PR working directories (default: <tmp>/ai-code-review). Each PR gets one directory holding its agent session and its Unity project; both are deleted when the PR closes.'
required: false
type: string
default: ''
project-prompt-path:
description: |
Path to this repository's own review criteria, relative to the repo root.
Read from the pull request's head and added to the built-in prompt; it can
add criteria but cannot change the tool contract or the output format.
Pass an empty string to use the built-in prompt alone.
required: false
type: string
default: '.github/ai-review.md'
unity-editor-version:
description: 'Editor version the per-PR Unity project is created for.'
required: false
type: string
default: '2022.3.62f3'
unity-template:
description: 'Template package the per-PR Unity project is created from.'
required: false
type: string
default: 'com.unity.template.3d'
unity-sync-method:
description: 'Optional -executeMethod used to regenerate project files (default UnityEditor.SyncVS.SyncSolution).'
required: false
type: string
default: ''
resharper-dotnet-sdk:
description: 'Pin the .NET SDK whose MSBuild jb inspectcode uses (e.g. 10.0.300). Empty auto-detects, which picks the newest installed SDK and fails when that one cannot build the solution.'
required: false
type: string
default: ''
resharper-build:
description: "Set 'true' to let jb inspectcode build the solution before inspecting it. Off by default: the pipeline already compiled the code, and Unity's generated projects do not build cleanly under a generic MSBuild, which fails the step with no report at all."
required: false
type: string
default: ''
resharper-ignore-rules:
description: 'Comma-separated ReSharper naming rules to drop, e.g. "Unity serialized field". For a rule the analyser reports and the team''s IDE cannot show or silence.'
required: false
type: string
default: ''
secrets:
OPENAI_API_KEY:
required: true # OpenAI API key
APP_ID:
required: true # GitHub App ID (used to generate a token)
APP_PK:
required: true # GitHub App private key
jobs:
review:
runs-on: [build-server, unitypkg-share]
# One run per pull request at a time. Every comment starts its own run, so
# five replies written within a minute were five runs listing the same
# unresolved threads at the same moment, settling all of them and posting a
# note for each — four identical "✔️ fixed" replies in one thread. Queued
# rather than cancelled, so every comment still gets an answer, in turn.
concurrency:
group: ai-review-${{ github.repository }}-${{ github.event.pull_request.number || github.event.issue.number || github.run_id }}
cancel-in-progress: false
# The one ceiling the run cannot escape. A composite action's steps may not
# set `timeout-minutes` of their own, and each stage bounds its own
# subprocesses, so this bounds the job: 360 minutes is GitHub's default and
# a Unity build that wedges should not get to use it.
timeout-minutes: 150
steps:
- name: Generate token via GitHub App
id: generate_token
uses: actions/create-github-app-token@v1
with:
app-id: ${{ secrets.APP_ID }}
private-key: ${{ secrets.APP_PK }}
repositories: ${{ github.event.repository.name }}, ToolsWorkflow
- name: ${{ github.event.action == 'closed' && 'Forget the closed pull request' || 'Review the pull request' }}
uses: peroperogames/ToolsWorkflow/review@main
with:
github-token: ${{ steps.generate_token.outputs.token }}
openai-api-key: ${{ secrets.OPENAI_API_KEY }}
openai-model: ${{ inputs.openai-model }}
openai-fallback-model: ${{ inputs.openai-fallback-model }}
openai-base-url: ${{ inputs.openai-base-url }}
openai-timeout: ${{ inputs.openai-timeout }}
openai-max-retries: ${{ inputs.openai-max-retries }}
review-language: ${{ inputs.review-language }}
max-tokens-per-chunk: ${{ inputs.max-tokens-per-chunk }}
agent-context-tokens: ${{ inputs.agent-context-tokens }}
silent-mode: ${{ inputs.silent-mode }}
dry-run: ${{ inputs.dry-run }}
state-dir: ${{ inputs.state-dir }}
project-prompt-path: ${{ inputs.project-prompt-path }}
unity-editor-version: ${{ inputs.unity-editor-version }}
unity-template: ${{ inputs.unity-template }}
unity-sync-method: ${{ inputs.unity-sync-method }}
resharper-dotnet-sdk: ${{ inputs.resharper-dotnet-sdk }}
resharper-build: ${{ inputs.resharper-build }}
resharper-ignore-rules: ${{ inputs.resharper-ignore-rules }}