-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathaction.yml
More file actions
294 lines (274 loc) · 12.2 KB
/
Copy pathaction.yml
File metadata and controls
294 lines (274 loc) · 12.2 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
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
name: 'CodeBoarding Action'
description: 'Review pull request architecture changes or sync a versioned CodeBoarding baseline.'
author: 'CodeBoarding'
branding:
icon: 'git-pull-request'
color: 'blue'
inputs:
mode:
description: 'review posts a PR architecture diff; sync updates the versioned analysis baseline.'
required: false
default: 'review'
llm_api_key:
description: 'Optional direct-provider key. With the default provider, empty selects hosted OIDC usage.'
required: false
default: ''
llm_provider:
description: 'Provider for llm_api_key, for example openrouter, anthropic, openai, google, or ollama.'
required: false
default: 'openrouter'
license_key:
description: 'Optional CodeBoarding license for unmetered hosted usage.'
required: false
default: ''
model:
description: 'Optional model used for both analysis and parsing.'
required: false
default: ''
agent_model:
description: 'Optional analysis-model override. Takes precedence over model.'
required: false
default: ''
parsing_model:
description: 'Optional parsing-model override. Takes precedence over model.'
required: false
default: ''
github_token:
description: 'Token used for comments and sync delivery.'
required: false
default: ${{ github.token }}
sync_strategy:
description: 'Sync delivery method: push or pull_request.'
required: false
default: 'push'
target_branch:
description: 'Branch updated by sync mode. Defaults to the event branch.'
required: false
default: ''
force_full:
description: 'Run a full sync analysis instead of reusing the committed baseline.'
required: false
default: 'false'
outputs:
diagram_md:
description: 'Path to the rendered Mermaid review diagram.'
value: ${{ steps.review_render.outputs.diagram_md }}
n_changed:
description: 'Number of changed components in review mode.'
value: ${{ steps.review_render.outputs.n_changed }}
truncated:
description: 'Whether the review graph was reduced to fit GitHub limits.'
value: ${{ steps.review_render.outputs.truncated }}
review_artifact_url:
description: 'URL of the uploaded review analysis artifact.'
value: ${{ steps.upload_review_artifact_dotcom.outputs.artifact-url }}
analysis_mode:
description: 'Whether sync used incremental or full analysis.'
value: ${{ steps.sync_analyze.outputs.analysis_mode }}
files_written:
description: 'Number of persisted analysis artifacts produced by sync.'
value: ${{ steps.sync_commit.outputs.files_written }}
committed:
description: 'Whether sync delivered a baseline commit.'
value: ${{ steps.sync_commit.outputs.committed }}
sync_pr_url:
description: 'Rolling sync PR URL when sync_strategy is pull_request.'
value: ${{ steps.sync_commit.outputs.sync_pr_url }}
sync_pr_number:
description: 'Rolling sync PR number when sync_strategy is pull_request.'
value: ${{ steps.sync_commit.outputs.sync_pr_number }}
runs:
using: 'composite'
steps:
- name: Resolve event
id: guard
shell: bash
env:
GH_TOKEN: ${{ inputs.github_token }}
GH_ENTERPRISE_TOKEN: ${{ inputs.github_token }}
GH_HOST: ${{ github.server_url }}
MODE: ${{ inputs.mode }}
EVENT: ${{ github.event_name }}
REF_NAME: ${{ github.ref_name }}
REF_TYPE: ${{ github.ref_type }}
EVENT_SHA: ${{ github.sha }}
HEAD_AUTHOR_EMAIL: ${{ github.event.head_commit.author.email }}
TARGET_BRANCH_INPUT: ${{ inputs.target_branch }}
SYNC_STRATEGY: ${{ inputs.sync_strategy }}
COMMENT_BODY: ${{ github.event.comment.body }}
AUTHOR_ASSOCIATION: ${{ github.event.comment.author_association }}
ISSUE_PR_URL: ${{ github.event.issue.pull_request.url }}
EVENT_PR_NUMBER: ${{ github.event.pull_request.number }}
PULL_HEAD_SHA: ${{ github.event.pull_request.head.sha }}
PULL_BASE_SHA: ${{ github.event.pull_request.base.sha }}
PULL_HEAD_REPO: ${{ github.event.pull_request.head.repo.full_name }}
PULL_BASE_REPO: ${{ github.event.pull_request.base.repo.full_name }}
REPOSITORY: ${{ github.repository }}
run: "$GITHUB_ACTION_PATH/scripts/action/guard.sh"
- name: Acknowledge review command
if: steps.guard.outputs.skip != 'true' && steps.guard.outputs.event == 'issue_comment'
continue-on-error: true
shell: bash
env:
GH_TOKEN: ${{ inputs.github_token }}
GH_ENTERPRISE_TOKEN: ${{ inputs.github_token }}
GITHUB_SERVER_URL: ${{ github.server_url }}
REPOSITORY: ${{ github.repository }}
COMMENT_ID: ${{ github.event.comment.id }}
run: GH_HOST="${GITHUB_SERVER_URL#*://}" gh api -X POST "repos/${REPOSITORY}/issues/comments/${COMMENT_ID}/reactions" -f content=eyes >/dev/null
- name: Post review progress
if: steps.guard.outputs.skip != 'true' && steps.guard.outputs.mode == 'review'
continue-on-error: true
uses: marocchino/sticky-pull-request-comment@v2
with:
header: ${{ steps.guard.outputs.comment_id }}
number: ${{ steps.guard.outputs.pr_number }}
GITHUB_TOKEN: ${{ inputs.github_token }}
message: |
### CodeBoarding review · analyzing…
⏳ CodeBoarding is analyzing this pull request's architecture changes.
<sub>run [${{ github.run_id }}](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}) · attempt ${{ github.run_attempt }}</sub>
- name: Checkout analysis target
if: steps.guard.outputs.skip != 'true'
uses: actions/checkout@v4
with:
repository: ${{ steps.guard.outputs.checkout_repo }}
ref: ${{ steps.guard.outputs.checkout_ref }}
token: ${{ inputs.github_token }}
fetch-depth: 1
persist-credentials: false
path: .codeboarding-target
- name: Setup Python
if: steps.guard.outputs.skip != 'true'
uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Install CodeBoarding
if: steps.guard.outputs.skip != 'true'
shell: bash
run: python -m pip install --disable-pip-version-check 'codeboarding==0.13.8'
- name: Configure analysis authentication
if: steps.guard.outputs.skip != 'true'
shell: bash
env:
ACTION_PATH: ${{ github.action_path }}
LLM_API_KEY: ${{ inputs.llm_api_key }}
LLM_PROVIDER: ${{ inputs.llm_provider }}
LICENSE_KEY: ${{ inputs.license_key }}
run: "$GITHUB_ACTION_PATH/scripts/action/configure-auth.sh"
- name: Analyze baseline
id: sync_analyze
if: steps.guard.outputs.skip != 'true' && steps.guard.outputs.mode == 'sync'
shell: bash
env:
ACTION_PATH: ${{ github.action_path }}
ANALYSIS_KIND: sync
CHECKOUT_DIR: ${{ github.workspace }}/.codeboarding-target
FORCE_FULL: ${{ inputs.force_full }}
MODEL: ${{ inputs.model }}
AGENT_MODEL_INPUT: ${{ inputs.agent_model }}
PARSING_MODEL_INPUT: ${{ inputs.parsing_model }}
run: '"$GITHUB_ACTION_PATH/scripts/action/with-auth.sh" "$GITHUB_ACTION_PATH/scripts/action/analyze.sh"'
- name: Deliver baseline
id: sync_commit
if: steps.guard.outputs.skip != 'true' && steps.guard.outputs.mode == 'sync'
shell: bash
env:
ACTION_PATH: ${{ github.action_path }}
ANALYSIS_DIR: ${{ steps.sync_analyze.outputs.analysis_dir }}
CHECKOUT_DIR: ${{ github.workspace }}/.codeboarding-target
TARGET_BRANCH: ${{ steps.guard.outputs.target_branch }}
SYNC_BRANCH_START_SHA: ${{ steps.guard.outputs.sync_branch_start_sha }}
SYNC_STRATEGY: ${{ inputs.sync_strategy }}
GITHUB_TOKEN: ${{ inputs.github_token }}
GH_TOKEN: ${{ inputs.github_token }}
GH_ENTERPRISE_TOKEN: ${{ inputs.github_token }}
GH_HOST: ${{ github.server_url }}
GITHUB_SERVER_URL: ${{ github.server_url }}
REPOSITORY: ${{ github.repository }}
run: "$GITHUB_ACTION_PATH/scripts/action/deliver-sync.sh"
- name: Write sync summary
if: always() && steps.guard.outputs.skip != 'true' && steps.guard.outputs.mode == 'sync'
shell: bash
env:
MODE: ${{ steps.sync_analyze.outputs.analysis_mode }}
COMMITTED: ${{ steps.sync_commit.outputs.committed }}
FILES: ${{ steps.sync_commit.outputs.files_written }}
STRATEGY: ${{ inputs.sync_strategy }}
PR_URL: ${{ steps.sync_commit.outputs.sync_pr_url }}
run: "$GITHUB_ACTION_PATH/scripts/action/sync-summary.sh"
- name: Analyze pull request
id: review_analyze
if: steps.guard.outputs.skip != 'true' && steps.guard.outputs.mode == 'review'
shell: bash
env:
ACTION_PATH: ${{ github.action_path }}
ANALYSIS_KIND: review
CHECKOUT_DIR: ${{ github.workspace }}/.codeboarding-target
REVIEW_BASE_SHA: ${{ steps.guard.outputs.base_sha }}
REVIEW_HEAD_SHA: ${{ steps.guard.outputs.head_sha }}
REVIEW_BASE_REPO: ${{ steps.guard.outputs.base_repo }}
GIT_TOKEN: ${{ inputs.github_token }}
GITHUB_SERVER_URL: ${{ github.server_url }}
MODEL: ${{ inputs.model }}
AGENT_MODEL_INPUT: ${{ inputs.agent_model }}
PARSING_MODEL_INPUT: ${{ inputs.parsing_model }}
run: '"$GITHUB_ACTION_PATH/scripts/action/with-auth.sh" "$GITHUB_ACTION_PATH/scripts/action/analyze.sh"'
- name: Render review diagram
id: review_render
if: steps.guard.outputs.skip != 'true' && steps.guard.outputs.mode == 'review'
shell: bash
env:
ACTION_PATH: ${{ github.action_path }}
BASE_ANALYSIS_PATH: ${{ steps.review_analyze.outputs.base_analysis_path }}
HEAD_ANALYSIS_PATH: ${{ steps.review_analyze.outputs.analysis_path }}
run: "$GITHUB_ACTION_PATH/scripts/action/render-review.sh"
- name: Build review artifact
id: review_artifact
if: steps.guard.outputs.skip != 'true' && steps.guard.outputs.mode == 'review'
shell: bash
env:
ANALYSIS_PATH: ${{ steps.review_analyze.outputs.analysis_path }}
ANALYSIS_MODE: ${{ steps.review_analyze.outputs.analysis_mode }}
BASE_SHA: ${{ steps.guard.outputs.base_sha }}
HEAD_SHA: ${{ steps.guard.outputs.head_sha }}
PR_NUMBER: ${{ steps.guard.outputs.pr_number }}
run: "$GITHUB_ACTION_PATH/scripts/action/build-review-artifact.sh"
- name: Upload review artifact
id: upload_review_artifact_dotcom
if: steps.guard.outputs.skip != 'true' && steps.guard.outputs.mode == 'review' && github.server_url == 'https://github.com'
uses: actions/upload-artifact@v4
with:
name: codeboarding-review-${{ github.run_id }}-${{ github.run_attempt }}
path: ${{ steps.review_artifact.outputs.artifact_dir }}
if-no-files-found: error
- name: Build review comment
id: review_body
if: steps.guard.outputs.skip != 'true' && steps.guard.outputs.mode == 'review'
shell: bash
env:
DIAGRAM: ${{ steps.review_render.outputs.diagram_md }}
N_CHANGED: ${{ steps.review_render.outputs.n_changed }}
ARTIFACT_URL: ${{ steps.upload_review_artifact_dotcom.outputs.artifact-url }}
PR_NUMBER: ${{ steps.guard.outputs.pr_number }}
run: "$GITHUB_ACTION_PATH/scripts/action/build-review-comment.sh"
- name: Post review comment
id: review_comment
if: steps.guard.outputs.skip != 'true' && steps.guard.outputs.mode == 'review'
uses: marocchino/sticky-pull-request-comment@v2
with:
header: ${{ steps.guard.outputs.comment_id }}
number: ${{ steps.guard.outputs.pr_number }}
GITHUB_TOKEN: ${{ inputs.github_token }}
path: ${{ steps.review_body.outputs.path }}
- name: Post review failure
if: failure() && steps.guard.outputs.skip != 'true' && steps.guard.outputs.mode == 'review' && steps.review_comment.outcome != 'success'
continue-on-error: true
uses: marocchino/sticky-pull-request-comment@v2
with:
header: ${{ steps.guard.outputs.comment_id }}
number: ${{ steps.guard.outputs.pr_number }}
GITHUB_TOKEN: ${{ inputs.github_token }}
message: |
### CodeBoarding review · failed
See the [workflow logs](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}).