Repository navigation
457 lines (444 loc) · 23.8 KB
/
Copy pathcode-qa.yml
File metadata and controls
457 lines (444 loc) · 23.8 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
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
name: Code QA Roo Code
on:
workflow_dispatch:
push:
branches: [main]
pull_request:
types: [opened, reopened, ready_for_review, synchronize, labeled, unlabeled]
merge_group:
types: [checks_requested]
# Cancel superseded runs when a pull request is updated. Non-PR events keep
# unique groups, so main, merge-queue, and manual runs are never cancelled.
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.run_id }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
# Least privilege: every job below escalates only where it needs to.
permissions:
contents: read
jobs:
classify:
name: classify (code-qa)
# Classifies the pull request change range before any validation
# runs. Only an explicit documentation-only allowlist match can
# skip expensive jobs, and only for pull_request events; a failed
# or missing classification fails safe to full validation. The
# validation-gate job below audits this decision on every run.
runs-on: ubuntu-latest
outputs:
category: ${{ steps.classify.outputs.category }}
reason: ${{ steps.classify.outputs.reason }}
reason-code: ${{ steps.classify.outputs.reason-code }}
changed-files: ${{ steps.classify.outputs.changed-files }}
allowlist-fingerprint: ${{ steps.classify.outputs.allowlist-fingerprint }}
steps:
- name: Checkout code
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
# Classification resolves the merge base from history.
fetch-depth: 0
# This job never pushes — don't persist the GITHUB_TOKEN.
persist-credentials: false
- name: Classify changed files
id: classify
uses: ./.github/actions/classify-changes
with:
event-name: ${{ github.event_name }}
head-sha: ${{ github.sha }}
force-full-label: ${{ github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'ci:full-validation') }}
force-full-variable: ${{ vars.ZOO_CODE_REQUIRE_FULL_VALIDATION == 'true' }}
dependency-review:
runs-on: ubuntu-latest
# Only meaningful for PRs — validates the dependency diff of the pull
# request against GitHub's advisory database before merge.
if: github.event_name == 'pull_request'
steps:
- name: Checkout code
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
# This job never pushes — don't persist the GITHUB_TOKEN.
persist-credentials: false
- name: Dependency review
uses: actions/dependency-review-action@a1d282b36b6f3519aa1f3fc636f609c47dddb294 # v5.0.0
invisible-chars:
runs-on: ubuntu-latest
# Reject invisible / homoglyph Unicode that GitHub's diff UI renders
# invisibly and most editors hide. These compile fine, which is the
# risk: identifier-splitting, string-literal injection, and the
# "Trojan Source" bidi-override attack (U+202A-U+202E). Scanning raw
# bytes catches them in strings, identifiers, and comments alike.
steps:
- name: Checkout code
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
# This job never pushes — don't persist the GITHUB_TOKEN.
persist-credentials: false
- name: Reject invisible / homoglyph Unicode
run: |
# zero-width (U+200B-200F), word joiner (U+2060), BOM (U+FEFF),
# bidi overrides (U+202A-202E), soft hyphen (U+00AD).
# Covers source, release-adjacent executable scripts
# (*.sh / *.cjs / *.cts / *.mts), and the executable shell
# blocks inside GitHub workflow/action YAML.
if grep -rnP '[\x{200B}-\x{200F}\x{202A}-\x{202E}\x{2060}\x{FEFF}\x{00AD}]' \
--include='*.ts' --include='*.tsx' --include='*.js' --include='*.mjs' \
--include='*.cjs' --include='*.cts' --include='*.mts' --include='*.sh' \
--include='*.yml' --include='*.yaml' \
--exclude-dir=node_modules --exclude-dir=dist --exclude-dir=out \
--exclude-dir=coverage --exclude-dir=.turbo --exclude-dir=.vinxi \
src webview-ui packages apps .github; then
echo "::error::Found invisible or homoglyph Unicode characters (zero-width / bidi-override / BOM / soft hyphen)"
exit 1
fi
format-check:
name: Formatting and validation policy tests
# Always runs, including documentation-only pull requests: Prettier
# checks every Markdown file, so formatting validation must never be
# reduced by classification. This job also validates the classifier
# and gate logic on every run.
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Setup Node.js and pnpm
uses: ./.github/actions/setup-node-pnpm
with:
install-args: "--frozen-lockfile"
- name: Check formatting
run: pnpm format:check
- name: Test change classification and validation gate
run: pnpm test:change-gate
check-translations:
needs: classify
# Fail-safe: only a successful documentation-only classification on
# a pull request skips this job. Everything else runs unchanged.
if: ${{ !cancelled() && (needs.classify.result != 'success' || github.event_name != 'pull_request' || needs.classify.outputs.category != 'docs-only') }}
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Setup Node.js and pnpm
uses: ./.github/actions/setup-node-pnpm
with:
install-args: "--frozen-lockfile"
- name: Verify all translations are complete
run: node scripts/find-missing-translations.js
- name: Verify t() calls pass every interpolation variable
run: node scripts/check-i18n-interpolation.js
knip:
# Intentionally ungated: the repository invariant test requires the
# knip job to run without conditions or allowed failure.
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Setup Node.js and pnpm
uses: ./.github/actions/setup-node-pnpm
with:
install-args: "--frozen-lockfile"
- name: Verify Knip guardrails
run: pnpm test:knip-policy
- name: Run knip checks
run: pnpm knip
- name: Run production Knip checks
run: pnpm knip:production
compile:
needs: [classify, format-check]
# Start the required check even for docs-only changes.
if: ${{ !cancelled() }}
env:
RUN_VALIDATION: ${{ needs.classify.result != 'success' || github.event_name != 'pull_request' || needs.classify.outputs.category != 'docs-only' }}
runs-on: ubuntu-latest
steps:
- name: Enforce formatting and validation policy tests
env:
FORMAT_RESULT: ${{ needs.format-check.result }}
run: test "$FORMAT_RESULT" = success
- name: Checkout code
if: env.RUN_VALIDATION == 'true'
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Setup Node.js and pnpm
if: env.RUN_VALIDATION == 'true'
uses: ./.github/actions/setup-node-pnpm
with:
install-args: "--frozen-lockfile"
- name: Lint
if: env.RUN_VALIDATION == 'true'
run: pnpm lint
- name: Check types
if: env.RUN_VALIDATION == 'true'
run: pnpm check-types
- name: Validate Code QA workflow
if: env.RUN_VALIDATION == 'true'
run: pnpm test:code-qa-ci
- name: Validate Solheim provider smoke workflow
if: env.RUN_VALIDATION == 'true'
run: pnpm test:solheim-smoke-ci
- name: Test Solheim provider smoke units
if: env.RUN_VALIDATION == 'true'
run: pnpm test:solheim-smoke:unit
- name: Check Solheim provider smoke types
if: env.RUN_VALIDATION == 'true'
run: pnpm solheim-smoke:check-types
- name: Test agent evals units
if: env.RUN_VALIDATION == 'true'
run: pnpm test:agent-evals:unit
- name: Check agent evals types
if: env.RUN_VALIDATION == 'true'
run: pnpm agent-evals:check-types
- name: Model-check task lifecycle protocols
if: env.RUN_VALIDATION == 'true'
run: pnpm lifecycle:model-check
- name: Model-check webview recovery
if: env.RUN_VALIDATION == 'true'
run: pnpm webview-recovery:check-types && pnpm webview-recovery:model-check
- name: Validate MCP OAuth integration
if: env.RUN_VALIDATION == 'true'
run: pnpm mcp:integration-check
build-vsix:
name: Build test VSIX
needs: classify
if: ${{ !cancelled() && github.event_name == 'pull_request' && (needs.classify.result != 'success' || needs.classify.outputs.category != 'docs-only') }}
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
persist-credentials: false
- name: Setup Node.js and pnpm
uses: ./.github/actions/setup-node-pnpm
with:
install-args: "--frozen-lockfile"
- name: Build workspace packages
run: |
pnpm --filter @roo-code/build build
pnpm --filter @roo-code/vscode-webview build
- name: Package extension
run: pnpm --filter ./src vsix
- name: Upload test VSIX
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: zoo-code-vsix-pr-${{ github.event.pull_request.number }}
path: bin/*.vsix
if-no-files-found: error
retention-days: 7
unit-test:
name: platform-unit-test (${{ matrix.name }})
needs: classify
# Start the required check even for docs-only changes.
if: ${{ !cancelled() }}
env:
RUN_VALIDATION: ${{ needs.classify.result != 'success' || github.event_name != 'pull_request' || needs.classify.outputs.category != 'docs-only' }}
runs-on: ${{ matrix.os }}
concurrency:
# Duplicate runs for one commit must not race the OS-specific Turbo cache save.
group: unit-test-${{ github.repository }}-${{ github.sha }}-${{ matrix.name }}
cancel-in-progress: false
strategy:
matrix:
include:
- os: ubuntu-latest
name: ubuntu-latest
codecov-flag: ubuntu
collect-coverage: true
- os: windows-latest
name: windows-latest
codecov-flag: windows
collect-coverage: false
steps:
- name: Report documentation-only validation
if: env.RUN_VALIDATION == 'false'
shell: bash
run: echo "Documentation-only change; expensive platform validation steps skipped." >> "$GITHUB_STEP_SUMMARY"
- name: Checkout code
if: env.RUN_VALIDATION == 'true'
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
- name: Setup Node.js and pnpm
if: env.RUN_VALIDATION == 'true'
uses: ./.github/actions/setup-node-pnpm
with:
install-args: "--frozen-lockfile"
- name: Restore Turbo cache
if: env.RUN_VALIDATION == 'true'
id: turbo-cache
uses: actions/cache/restore@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: .turbo/cache
key: ${{ runner.os }}-turbo-${{ hashFiles('**/pnpm-lock.yaml') }}-${{ github.sha }}
restore-keys: |
${{ runner.os }}-turbo-${{ hashFiles('**/pnpm-lock.yaml') }}-
${{ runner.os }}-turbo-
# Windows never uploads coverage, so Windows runs the same test
# suites through the uninstrumented Turbo tasks. Ubuntu stays the
# authoritative coverage lane.
- name: Run non-extension package coverage
if: ${{ env.RUN_VALIDATION == 'true' && (matrix.collect-coverage) }}
run: pnpm turbo run test:coverage --filter="!@roo-code/core" --filter="!zoo-code" --log-order grouped --output-logs new-only
- name: Run non-extension package tests
if: ${{ env.RUN_VALIDATION == 'true' && (!matrix.collect-coverage) }}
run: pnpm turbo run test --filter="!@roo-code/core" --filter="!zoo-code" --log-order grouped --output-logs new-only
- name: Run extension coverage lanes
if: ${{ env.RUN_VALIDATION == 'true' && (matrix.collect-coverage) }}
run: pnpm turbo run test:coverage:api test:coverage:core test:coverage:services test:coverage:misc test:coverage:tree-sitter --filter="zoo-code" --concurrency=2 --log-order grouped --output-logs new-only
- name: Run extension test lanes
if: ${{ env.RUN_VALIDATION == 'true' && (!matrix.collect-coverage) }}
run: pnpm turbo run test:api test:core test:services test:misc test:tree-sitter --filter="zoo-code" --concurrency=2 --log-order grouped --output-logs new-only
# Runs outside Turbo so changes to .coderabbit.yaml,
# .github/workflows/label-pr-review-state.yml, and
# .github/workflows/stale.yml always bust the result. Those files
# sit outside the src/ package boundary and cannot be declared as
# Turbo inputs.
- name: Run workflow config tests
if: env.RUN_VALIDATION == 'true'
run: pnpm --dir src run test:workflow
- name: Verify extension coverage contract
if: ${{ env.RUN_VALIDATION == 'true' && (matrix.collect-coverage) }}
run: pnpm --dir src run verify:coverage-contract
- name: Run extension dist smoke test
if: env.RUN_VALIDATION == 'true'
run: pnpm turbo run test:dist --filter="zoo-code" --log-order grouped --output-logs new-only
- name: Run core unit coverage
if: ${{ env.RUN_VALIDATION == 'true' && (matrix.collect-coverage) }}
run: pnpm turbo run test:coverage:unit --filter="@roo-code/core" --log-order grouped --output-logs new-only
- name: Run core unit tests
if: ${{ env.RUN_VALIDATION == 'true' && (!matrix.collect-coverage) }}
run: pnpm turbo run test:unit --filter="@roo-code/core" --log-order grouped --output-logs new-only
- name: Run core integration coverage
if: ${{ env.RUN_VALIDATION == 'true' && (matrix.collect-coverage) }}
run: pnpm turbo run test:coverage:integration --filter="@roo-code/core" --log-order grouped --output-logs new-only
- name: Run core integration tests
if: ${{ env.RUN_VALIDATION == 'true' && (!matrix.collect-coverage) }}
run: pnpm turbo run test:integration --filter="@roo-code/core" --log-order grouped --output-logs new-only
- name: Verify extension coverage reports
if: ${{ env.RUN_VALIDATION == 'true' && (matrix.collect-coverage) }}
run: |
node src/scripts/verify-lcov.mjs src/coverage/api/lcov.info
node src/scripts/verify-lcov.mjs src/coverage/core/lcov.info
node src/scripts/verify-lcov.mjs src/coverage/services/lcov.info
node src/scripts/verify-lcov.mjs src/coverage/misc/lcov.info
node src/scripts/verify-lcov.mjs src/coverage/tree-sitter/lcov.info
- name: Merge extension coverage reports
if: ${{ env.RUN_VALIDATION == 'true' && (matrix.collect-coverage) }}
run: |
mkdir -p src/coverage/merged
pnpm --dir src run merge:coverage
node src/scripts/verify-lcov.mjs src/coverage/merged/lcov.info
# Validate cache boundaries before publishing any new Turbo entries.
- name: Verify coverage cache inputs
if: ${{ env.RUN_VALIDATION == 'true' && (matrix.collect-coverage) }}
run: pnpm --dir src run verify:coverage-cache-inputs
- name: Save Turbo cache
if: ${{ env.RUN_VALIDATION == 'true' && (steps.turbo-cache.outputs.cache-hit != 'true') }}
uses: actions/cache/save@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0
with:
path: .turbo/cache
key: ${{ steps.turbo-cache.outputs.cache-primary-key }}
# Only ubuntu uploads coverage. Windows still runs the same test
# lanes for behavioral confidence, but duplicating coverage uploads
# there mostly adds Codecov overhead without changing pass/fail
# behavior.
# Coverage is uploaded in separate steps so each LCOV gets the
# correct flag set. Extension lanes instrument the same sources, so
# union them before upload; a line is covered when any lane executes
# it. Core and webview reports retain their independent flags.
# See https://docs.codecov.com/docs/flags
- name: Upload non-core coverage to Codecov
if: ${{ env.RUN_VALIDATION == 'true' && (matrix.collect-coverage) }}
uses: codecov/codecov-action@303a32d7a59b442fa8d48b6a1cc6825c09c847a5 # v7.1.1
with:
files: >-
src/coverage/merged/lcov.info,
packages/cloud/coverage/lcov.info,
packages/telemetry/coverage/lcov.info,
apps/cli/coverage/lcov.info
disable_search: true
flags: ${{ matrix.codecov-flag }}
token: ${{ secrets.CODECOV_TOKEN }}
- name: Upload webview JSDOM coverage to Codecov
if: ${{ env.RUN_VALIDATION == 'true' && (matrix.collect-coverage) }}
uses: codecov/codecov-action@303a32d7a59b442fa8d48b6a1cc6825c09c847a5 # v7.1.1
with:
files: webview-ui/coverage/lcov.info
disable_search: true
flags: webview-ui
token: ${{ secrets.CODECOV_TOKEN }}
- name: Upload core unit coverage to Codecov
if: ${{ env.RUN_VALIDATION == 'true' && (matrix.collect-coverage) }}
uses: codecov/codecov-action@303a32d7a59b442fa8d48b6a1cc6825c09c847a5 # v7.1.1
with:
files: packages/core/coverage/unit/lcov.info
disable_search: true
flags: ${{ matrix.codecov-flag }},core-unit
token: ${{ secrets.CODECOV_TOKEN }}
- name: Upload core integration coverage to Codecov
if: ${{ env.RUN_VALIDATION == 'true' && (matrix.collect-coverage) }}
uses: codecov/codecov-action@303a32d7a59b442fa8d48b6a1cc6825c09c847a5 # v7.1.1
with:
files: packages/core/coverage/integration/lcov.info
disable_search: true
flags: ${{ matrix.codecov-flag }},core-integration
token: ${{ secrets.CODECOV_TOKEN }}
- name: Upload coverage reports to GitHub
if: ${{ env.RUN_VALIDATION == 'true' && (matrix.collect-coverage) }}
uses: actions/upload-artifact@cf430e030ddbb5b0abf93d22962f4752f3646cd9 # v7.0.2
with:
name: coverage-reports-${{ matrix.name }}
path: |
src/coverage/api/lcov.info
src/coverage/core/lcov.info
src/coverage/services/lcov.info
src/coverage/misc/lcov.info
src/coverage/tree-sitter/lcov.info
src/coverage/merged/lcov.info
webview-ui/coverage/lcov.info
packages/cloud/coverage/lcov.info
packages/telemetry/coverage/lcov.info
apps/cli/coverage/lcov.info
packages/core/coverage/unit/lcov.info
packages/core/coverage/integration/lcov.info
retention-days: 7
validation-gate:
name: validation-gate (code-qa)
# Always-running required gate for change-based validation. It
# rejects a missing or failed classification, validation jobs that
# did not run when full validation was required, jobs that ran when
# a documentation-only skip was expected, and a classifier replay
# that disagrees with the recorded classification. It also records
# the classification, the skipped work, runner minutes, and the
# required-check completion time in the job summary.
if: always()
needs:
- classify
- dependency-review
- invisible-chars
- format-check
- check-translations
- knip
- compile
- build-vsix
- unit-test
runs-on: ubuntu-latest
permissions:
contents: read
actions: read
steps:
- name: Checkout code
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
with:
# The gate replays the classifier against the same range.
fetch-depth: 0
# This job never pushes — don't persist the GITHUB_TOKEN.
persist-credentials: false
- name: Run validation gate
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NEEDS_JSON: ${{ toJSON(needs) }}
EVENT_NAME: ${{ github.event_name }}
PR_DRAFT: ${{ github.event.pull_request.draft }}
RUN_ID: ${{ github.run_id }}
HEAD_SHA: ${{ github.sha }}
FORCE_FULL_LABEL: ${{ github.event_name == 'pull_request' && contains(github.event.pull_request.labels.*.name, 'ci:full-validation') }}
FORCE_FULL_VARIABLE: ${{ vars.ZOO_CODE_REQUIRE_FULL_VALIDATION == 'true' }}
WATCHED_JOBS: dependency-review:pr-only:ungated,invisible-chars:always:ungated,format-check:always:ungated,check-translations:always:gated,knip:always:ungated,compile:always:ungated,build-vsix:pr-only:gated,unit-test:always:ungated
run: |
BASE_SHA="$(git rev-parse "${HEAD_SHA}^1")"
node scripts/change-gate.mjs ci --base "$BASE_SHA" --head "$HEAD_SHA"