Repository navigation
1829 lines (1675 loc) · 81.1 KB
/
Copy pathci.yml
File metadata and controls
1829 lines (1675 loc) · 81.1 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
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# .github/workflows/ci.yml
name: 'LLxprt Code CI'
on:
push:
branches:
- 'main'
- 'release/**'
pull_request:
branches:
- 'main'
- 'release/**'
- 'dev/**'
merge_group:
workflow_dispatch:
inputs:
prereview_pr:
description: 'Optional PR number for runner-local prereview validation'
type: string
default: ''
prereview_head:
description: 'Expected immutable head SHA for prereview validation'
type: string
default: ''
concurrency:
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }}
cancel-in-progress: true
permissions:
checks: 'write'
contents: 'read'
statuses: 'write'
defaults:
run:
shell: 'bash'
env:
ACTIONLINT_VERSION: '1.7.7'
SHELLCHECK_VERSION: '0.11.0'
YAMLLINT_VERSION: '1.35.1'
jobs:
prereview_validation:
if: github.event_name == 'workflow_dispatch' && inputs.prereview_pr != ''
uses: './.github/workflows/pr-review.yml'
permissions:
contents: read
pull-requests: write
issues: read
actions: read
with:
pull_request_number: '${{ inputs.prereview_pr }}'
expected_head_sha: '${{ inputs.prereview_head }}'
skip_check:
name: 'Skip Duplicate Check'
runs-on: 'ubuntu-latest'
outputs:
should_skip: ${{ steps.skip_check.outputs.should_skip }}
paths_result: ${{ steps.skip_check.outputs.paths_result }}
steps:
- id: skip_check
# ratchet:fkirc/skip-duplicate-actions@v5.3.2
uses: 'fkirc/skip-duplicate-actions@b974a9395958c231af965b70070979a577efa578'
with:
concurrent_skipping: 'same_content'
skip_after_successful_duplicate: 'true'
do_not_skip: '["workflow_dispatch", "merge_group"]'
doc_change_filter:
name: 'Detect doc-only changes'
runs-on: 'ubuntu-latest'
# Every heavy job declares `needs: doc_change_filter`, so a stalled `gh api`
# call here would block the whole tier for the 6-hour Actions default. Cap
# it like shard_selector does; two API calls need nowhere near this.
timeout-minutes: 5
needs:
- 'skip_check'
if: ${{ needs.skip_check.outputs.should_skip != 'true' }}
env:
GH_TOKEN: '${{ github.token }}'
# Reads PR file metadata (issue #342); be explicit rather than relying on
# the repo being public. Matches how shard_selector declares permissions.
permissions:
contents: 'read'
pull-requests: 'read'
outputs:
docs_only: '${{ steps.detect.outputs.docs_only }}'
steps:
- name: 'Checkout'
uses: 'actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1' # ratchet:actions/checkout@v7
with:
fetch-depth: 1
- name: 'Set up Node.js'
uses: 'actions/setup-node@820762786026740c76f36085b0efc47a31fe5020' # ratchet:actions/setup-node@v7
with:
node-version-file: '.nvmrc'
- name: 'Determine documentation-only PR'
id: 'detect'
env:
PR_NUMBER: >-
${{ github.event_name == 'pull_request' && github.event.pull_request.number || '' }}
run: |
set -euo pipefail
# Non-PR events (push, merge_group, workflow_dispatch) always run full CI.
if [[ -z "${PR_NUMBER:-}" ]]; then
echo "docs_only=false" >>"$GITHUB_OUTPUT"
exit 0
fi
# Fetch the full structured PR file list as NDJSON (one entry per line
# across all pages, including status/previous_filename/patch so renames
# and the .gitignore carve-out are handled) and the authoritative
# changed_files count. `|| true` keeps an API blip from failing this
# job: the detector script then resolves to docs_only=false (run full
# CI) rather than skipping the six heavy jobs and wedging the PR.
files_json="${RUNNER_TEMP}/pr-files.ndjson"
: >"$files_json"
gh api \
--paginate \
-H "Accept: application/vnd.github+json" \
"repos/${GITHUB_REPOSITORY}/pulls/${PR_NUMBER}/files" \
--jq '.[]' >"$files_json" || true
changed_files="$(gh api \
-H "Accept: application/vnd.github+json" \
"repos/${GITHUB_REPOSITORY}/pulls/${PR_NUMBER}" \
--jq '.changed_files' || true)"
# The classifier (scripts/docs-only-filter.ts) is a conservative
# allowlist (issue #342): runtime .md/.txt inputs under packages/ are
# CODE, renames require both sides to be docs, and the changed_files
# count guards against the 3000-file API ceiling. It writes docs_only
# to GITHUB_OUTPUT and a summary to GITHUB_STEP_SUMMARY, always
# exiting 0 so a detector blip never wedges a PR.
node scripts/docs-only-filter.ts \
--files-json "$files_json" \
--changed-files "$changed_files" \
--output github-actions || true
#
# Lint: GitHub Actions
#
# Shard selection (issue #2709)
#
# A cheap Node script reads the PR's changed paths and a checked-in package
# import graph to select only the test shards that can observe the changes.
# Non-PR events (push, merge_group, workflow_dispatch) select all shards.
# Unknown paths or selector failure run all six shards (fail-closed). The
# selector is path-only (no AST scan, no install) and completes in
# milliseconds; the import-graph drift guard
# (scripts/check-affected-test-shards.ts) runs in the lint_javascript job.
shard_selector:
name: 'Select test shards'
runs-on: 'ubuntu-latest'
timeout-minutes: 5
needs:
- 'skip_check'
if: ${{ needs.skip_check.outputs.should_skip != 'true' }}
permissions:
contents: 'read'
pull-requests: 'read'
outputs:
matrix: '${{ steps.select.outputs.matrix }}'
selected_shards: '${{ steps.select.outputs.selected_shards }}'
has_tests: '${{ steps.select.outputs.has_tests }}'
coverage_complete: '${{ steps.select.outputs.coverage_complete }}'
full_run_reason: '${{ steps.select.outputs.full_run_reason }}'
lint_targets: '${{ steps.lint_select.outputs.lint_targets }}'
lint_full_run: '${{ steps.lint_select.outputs.lint_full_run }}'
lint_full_run_reason: '${{ steps.lint_select.outputs.lint_full_run_reason }}'
steps:
- name: 'Checkout'
uses: 'actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1' # ratchet:actions/checkout@v7
with:
fetch-depth: 0
persist-credentials: false
- name: 'Set up Node.js'
uses: 'actions/setup-node@820762786026740c76f36085b0efc47a31fe5020' # ratchet:actions/setup-node@v7
with:
node-version-file: '.nvmrc'
- name: 'Determine changed files'
id: 'changed'
env:
GH_TOKEN: '${{ github.token }}'
PR_NUMBER: >-
${{ github.event_name == 'pull_request' && github.event.pull_request.number || '' }}
run: |
set -euo pipefail
# Non-PR events select all shards, so we only need the file list for
# pull_request events. An empty file list makes the selector fail
# closed (all shards), which is the safe default.
files_file="${RUNNER_TEMP}/changed-files.txt"
: >"$files_file"
if [[ -n "${PR_NUMBER:-}" ]]; then
gh api \
--paginate \
-H "Accept: application/vnd.github+json" \
"repos/${GITHUB_REPOSITORY}/pulls/${PR_NUMBER}/files" \
--jq '.[].filename' >"$files_file"
fi
echo "count=$(wc -l <"$files_file" | tr -d ' ')" >>"$GITHUB_OUTPUT"
- name: 'Select affected shards'
id: 'select'
run: |
set -euo pipefail
event='${{ github.event_name }}'
files_arg=()
if [[ "$event" == "pull_request" ]]; then
files_arg=(--files-from "${RUNNER_TEMP}/changed-files.txt")
fi
# The selector writes selected_shards, matrix, has_tests,
# coverage_complete, and full_run_reason directly to GITHUB_OUTPUT,
# and a human-readable summary to GITHUB_STEP_SUMMARY. The matrix is
# a JSON array of {shard, os, node-version} objects, one per
# selected shard per OS (Linux + macOS).
node scripts/affected-test-shards.ts \
--event "$event" \
"${files_arg[@]}" \
--output github-actions
- name: 'Select affected lint targets'
id: 'lint_select'
run: |
set +e
event='${{ github.event_name }}'
files_arg=()
if [[ "$event" == "pull_request" ]]; then
files_arg=(--files-from "${RUNNER_TEMP}/changed-files.txt")
fi
# The lint selector reuses the same import graph as the test-shard
# selector and writes lint_targets (JSON array of package dirs +
# integration-tests) and lint_full_run (true when fail-closed to a
# full root lint) directly to GITHUB_OUTPUT. The selector must NOT
# fail this job — on crash it writes a full-run fallback so that
# lint_javascript's step-level fail-closed logic lints the whole
# root tree.
node scripts/affected-lint-targets.ts \
--event "$event" \
"${files_arg[@]}" \
--output github-actions
select_rc=$?
if [[ "$select_rc" -ne 0 ]]; then
echo "lint_targets=[\".\"]" >> "$GITHUB_OUTPUT"
echo "lint_full_run=true" >> "$GITHUB_OUTPUT"
echo "lint_full_run_reason=lint selector failed (exit $select_rc)" >> "$GITHUB_OUTPUT"
echo "::warning::affected-lint-targets failed (exit $select_rc); falling back to full lint"
fi
#
lint_github_actions:
name: 'Lint (GitHub Actions)'
runs-on: 'ubuntu-latest'
needs:
- 'skip_check'
if: ${{ needs.skip_check.outputs.should_skip != 'true' }}
steps:
- name: 'Checkout'
uses: 'actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1' # ratchet:actions/checkout@v7
with:
fetch-depth: 1
- name: 'Install shellcheck' # Actionlint uses shellcheck
run: |-
mkdir -p "${RUNNER_TEMP}/shellcheck"
curl -sSLo "${RUNNER_TEMP}/.shellcheck.txz" "https://github.com/koalaman/shellcheck/releases/download/v${SHELLCHECK_VERSION}/shellcheck-v${SHELLCHECK_VERSION}.linux.x86_64.tar.xz"
tar -xf "${RUNNER_TEMP}/.shellcheck.txz" -C "${RUNNER_TEMP}/shellcheck" --strip-components=1
echo "${RUNNER_TEMP}/shellcheck" >> "${GITHUB_PATH}"
- name: 'Install actionlint'
run: |-
mkdir -p "${RUNNER_TEMP}/actionlint"
curl -sSLo "${RUNNER_TEMP}/.actionlint.tgz" "https://github.com/rhysd/actionlint/releases/download/v${ACTIONLINT_VERSION}/actionlint_${ACTIONLINT_VERSION}_linux_amd64.tar.gz"
tar -xzf "${RUNNER_TEMP}/.actionlint.tgz" -C "${RUNNER_TEMP}/actionlint"
echo "${RUNNER_TEMP}/actionlint" >> "${GITHUB_PATH}"
# For actionlint, we specifically ignore shellcheck rules that are
# annoying or unhelpful. See the shellcheck action for a description.
- name: 'Run actionlint'
run: |-
actionlint \
-color \
-format "{{range \$err := .}}::error file={{\$err.Filepath}},line={{\$err.Line}},col={{\$err.Column}}::{{\$err.Filepath}}@{{\$err.Line}} {{\$err.Message}}%0A\`\`\`%0A{{replace \$err.Snippet \"\\\\n\" \"%0A\"}}%0A\`\`\`\\n{{end}}" \
-ignore 'SC2002:' \
-ignore 'SC2016:info' \
-ignore 'SC2129:' \
-ignore 'label ".+" is unknown'
- name: 'Run ratchet'
uses: 'sethvargo/ratchet@9ca118155b0f79464185703a50da367e111107cd' # ratchet:sethvargo/ratchet@v0.12.0
with:
files: |-
.github/workflows/*.yml
.github/actions/**/*.yml
#
# Lint: Javascript
#
# S6 (#2243): installs dependencies with `bun install`. The root postinstall
# script (scripts/postinstall.cjs) replaces Bun's hoisted static workspace
# copies with symlinks to the real workspace dirs, so esbuild/tsserver
# resolve workspace `dist/` correctly (see dev-docs/bun.md). Lint/typecheck/
# format/build run under Node via `npm run …` (the workspace-fanout scripts
# `npm run typecheck --workspaces` / `npm run test --workspaces` recurse under
# `bun run`, so execution stays on npm; only the install moved to Bun.
lint_javascript:
name: 'Lint (Javascript)'
runs-on: 'ubuntu-latest'
needs:
- 'skip_check'
- 'shard_selector'
# Fail closed: run this required lint job even when shard_selector fails or
# is skipped, so the step-level fail-closed logic (full lint on non-success)
# is reachable. Without `!cancelled()`, GitHub Actions skips dependent jobs
# before evaluating `if` when a needed job fails, which would silently skip
# lint and allow un-linted code to merge.
if: ${{ !cancelled() && needs.skip_check.outputs.should_skip != 'true' }}
steps:
- name: 'Checkout'
uses: 'actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1' # ratchet:actions/checkout@v7
with:
fetch-depth: 0
persist-credentials: false
- name: 'Set up Node.js'
uses: 'actions/setup-node@820762786026740c76f36085b0efc47a31fe5020' # ratchet:actions/setup-node@v7
with:
node-version-file: '.nvmrc'
# S6 (#2243): Bun is the package manager for this job. Node remains
# required because the lint/typecheck/format/build scripts execute under
# it. Several npm scripts invoked below (check:lockfile,
# lint:eslint-guard, build, bundle) are backed by bun scripts/*.ts and
# require the Bun runtime to be on PATH.
- name: 'Setup Bun'
uses: 'oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6' # ratchet:oven-sh/setup-bun@v2
with:
bun-version-file: '.bun-version'
- name: 'Cache Bun dependencies'
uses: 'actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9' # ratchet:actions/cache@v6
with:
path: |
~/.bun/install/cache
key: ${{ runner.os }}-bun-${{ hashFiles('bun.lock') }}
- name: 'Run lockfile check'
run: |-
npm run check:lockfile
- name: 'Install dependencies'
# `bun install` drives dependency resolution; the root postinstall
# (scripts/postinstall.cjs) then replaces Bun's static workspace copies
# with symlinks so esbuild/tsserver resolve workspace `dist/` (see
# dev-docs/bun.md). Bun re-normalizes `bun.lock` on every install
# (dev-docs/bun.md), so restore the committed lockfile or the
# formatter's `git diff --exit-code` below would flag the re-write.
# Likewise, the vscode-ide-companion `prepare` script regenerates
# NOTICES.txt from live npm metadata, so restore the committed copy.
run: |-
bun install
git checkout -- bun.lock
git checkout -- packages/vscode-ide-companion/NOTICES.txt
- name: 'Run formatter check'
run: |-
npm run format
# Check for changes, excluding project-plans directory
git diff --exit-code -- . ':!project-plans/'
- name: 'Run ESLint policy guard'
env:
ESLINT_GUARD_BASE: >-
${{ github.event_name == 'pull_request' && github.event.pull_request.base.sha
|| github.event_name == 'merge_group' && github.event.merge_group.base_sha
|| github.event_name == 'push' && github.event.before
|| 'origin/main' }}
ESLINT_GUARD_HEAD: ${{ github.sha }}
run: |-
npm run lint:eslint-guard
- name: 'Run CLI import-boundary guard'
run: |-
npm run lint:cli-boundary
npm run lint:a2a-boundary
- name: 'Run Gemini containment guard'
run: |-
npm run lint:gemini-containment
- name: 'Run runtime-dependency declaration guard (#3305)'
# Fails if any published workspace package imports, at runtime, a
# package it does not declare in dependencies/peerDependencies/
# optionalDependencies. A devDependencies-only declaration is a
# failure: that section is never installed for a consumer, which is
# how the published mcp tarball shipped unable to resolve core.
run: |-
npm run lint:runtime-deps
- name: 'Run legacy-global-path guard (#2606)'
run: |-
npm run lint:legacy-paths
- name: 'Run no-vitest guard (#2970)'
run: |-
npm run lint:no-vitest
- name: 'Check for new JS files (#2745)'
run: |-
npm run lint:no-new-js
- name: 'Run CLI test-discovery guard (#2923)'
run: |-
npm run lint:cli-test-discovery
- name: 'Run copyright-year guard (#2820)'
env:
COPYRIGHT_GUARD_BASE: >-
${{ github.event_name == 'pull_request' && github.event.pull_request.base.sha
|| github.event_name == 'merge_group' && github.event.merge_group.base_sha
|| github.event_name == 'push' && github.event.before
|| 'origin/main' }}
COPYRIGHT_GUARD_HEAD: ${{ github.sha }}
run: |-
npm run lint:copyright-year
- name: 'Run doc-links guard (#2654)'
run: |-
npm run lint:doc-links
- name: 'Run doc-placement guard (#2654)'
run: |-
npm run lint:doc-placement
- name: 'Run affected-test-shards graph drift guard (#2709)'
# Verifies the checked-in import graph matches the real AST-derived
# edges. Runs here (after build) because it needs the TypeScript
# compiler API available.
run: |-
npm run lint:affected-shards
- name: 'Run E2E real-model budget guard (#2278)'
# Validates integration-tests/real-model-budget.ts: no duplicate or
# malformed entries, a ceiling that is at least a 50% cut from the
# measured baseline, and no entry naming a rig.setup() call that no
# longer exists. The per-leg ledger check runs in e2e.yml.
run: |-
npm run lint:e2e-model-budget
# Runs independently of test shard selection. Path observers only reduce
# test work; this guard provides the settings synchronization guarantee.
# It must run before build:types, whose declaration-only output cannot be
# executed when the schema follows runtime imports across workspaces.
- name: 'Run settings docs/schema sync guard (#3212)'
run: |-
npm run lint:settings-sync
# Build must run BEFORE the type-aware lint: three workspace tsconfigs
# map cross-workspace imports to `dist/*.d.ts` — cli -> tools, core -> mcp,
# and a2a-server -> settings/storage/tools — so tsserver (projectService)
# needs the compiled declarations on disk to resolve types. Under npm
# `npm ci`'s postinstall builds implicitly; under `bun install` (whose
# postinstall only symlinks, see scripts/postinstall.cjs) it does not, so
# the build is explicit here.
#
# `build:types` emits declarations only (issue #2983). Every later step in
# this job reads types and none executes application code, so the
# transpiled `.js` was pure cost here. Do not reuse `build:types` in a job
# that runs the CLI or a Bun test suite: Bun honors tsconfig `paths`, so a
# declaration-only `dist` makes cross-package imports resolve to a `.d.ts`
# with no JavaScript behind it. The release path (release.yml -> `npm run
# build:packages`) still does a full emit, because every published library
# workspace declares `main: dist/index.js` and ships `dist`, so npm
# consumers resolving without the `bun` export condition load that
# JavaScript.
- name: 'Build declarations for type-aware lint'
run: |-
npm run build:types
- name: 'Run agents API-surface guard'
run: |-
npm run lint:agents-api-surface
# The audit type-checks the non-workspace runtime plugins (see
# productionPlugins in scripts/runtime-entry-manifest.ts). The
# google-gemini plugin imports @ai-sdk/google from its own
# node_modules, which the root `bun install` does not populate, so the
# compiler reports TS2307/TS7006 and blocks the service-shape scanner.
# Plugin installs need bun >= 1.4.2 for the same reason as the
# runtime_plugins job (the repo pin re-resolves the plugin lockfile and
# stalls on hosted runners).
- name: 'Install runtime plugin dependencies for the audit'
run: |-
curl -fsSL https://bun.sh/install | BUN_INSTALL="$RUNNER_TEMP/bun-plugin" bash -s "bun-v1.4.2"
for plugin in plugins/*/; do
if [ -f "${plugin}package.json" ]; then
(cd "$plugin" && "$RUNNER_TEMP/bun-plugin/bin/bun" install --omit=peer)
fi
done
git checkout -- bun.lock
- name: 'Run runtime-boundary production audit (#2616)'
# TypeScript-aware audit of production sources: fails on any
# mutable-state, ALS, ambient-delegation, Config-locator or compiler
# finding. runtime-service-bundle and runtime-service-bag-parameter
# are a tracked residual held by the committed ratchet baseline
# (scripts/runtime-service-shape-baseline.json): per-owner counts may
# fall but never rise. Needs the declarations from build:types above.
run: |-
npm run check:runtime-boundary
# ESLint cache is CI opt-in only (issue #2710). The exact key hashes
# every linted source/config/type input so a changed cross-file type
# producer invalidates the cache of its consumers. There are no
# restore-keys: a partial match across a stale type input would be
# unsound.
- name: 'Restore ESLint cache'
id: 'eslint_cache'
if: ${{ needs.shard_selector.result == 'success' }}
uses: 'actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9' # ratchet:actions/cache@v6
with:
path: 'node_modules/.cache/eslint'
key: ${{ runner.os }}-eslint-${{ hashFiles('packages/*/src/**', 'packages/*/package.json', 'packages/*/tsconfig.json', 'scripts/**', 'evals/**', 'integration-tests/**', 'eslint.config.js', 'eslint-rules/**', 'package.json', 'package-lock.json', 'bun.lock', 'tsconfig.json', 'tsconfig.scripts.json', '*.js', 'test-setup/**', '.github/workflows/**', '.github/scripts/**') }}
- name: 'Run linter'
run: |
set -euo pipefail
# Fail closed: if the selector did not succeed, or reported a full
# run, lint the whole root tree. Otherwise lint only the selected
# package targets (the runner always includes integration-tests).
selector_result='${{ needs.shard_selector.result }}'
lint_full_run='${{ needs.shard_selector.outputs.lint_full_run }}'
lint_targets='${{ needs.shard_selector.outputs.lint_targets }}'
lint_full_run_reason='${{ needs.shard_selector.outputs.lint_full_run_reason }}'
if [[ -n "$lint_full_run_reason" ]]; then
echo "::notice::Lint running full: $lint_full_run_reason"
fi
if [[ "$selector_result" == "success" && "$lint_full_run" != "true" && -n "$lint_targets" && "$lint_targets" != "null" ]]; then
# Scoped run: the runner derives --cache args centrally from the
# LLXPRT_LINT_CACHE env (it also reads the target list from env),
# so no cache flags are passed on the CLI.
LLXPRT_LINT_CACHE=true LLXPRT_LINT_TARGETS="$lint_targets" \
npm run lint:runner
else
# Full run: the partitioned runner covers the whole tree,
# integration-tests included, one ESLint process per package
# plus a root slice (#3387). Both branches rely on the runner's
# own per-child heap, so no NODE_OPTIONS is set here.
npm run lint:ci
fi
- name: 'Run LSP package linter'
run: |-
cd packages/lsp && npx eslint .
- name: 'Run formatter on integration tests'
run: |-
npx prettier --check integration-tests
git diff --exit-code
- name: 'Run type check'
run: |-
npm run typecheck
- name: 'Run sensitive keyword linter'
run: 'bun scripts/lint.ts --sensitive-keywords'
#
# Lint: Shell
#
lint_shell:
name: 'Lint (Shell)'
runs-on: 'ubuntu-latest'
needs:
- 'skip_check'
if: ${{ needs.skip_check.outputs.should_skip != 'true' }}
steps:
- name: 'Checkout'
uses: 'actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1' # ratchet:actions/checkout@v7
with:
fetch-depth: 1
- name: 'Install shellcheck'
run: |-
mkdir -p "${RUNNER_TEMP}/shellcheck"
curl -sSLo "${RUNNER_TEMP}/.shellcheck.txz" "https://github.com/koalaman/shellcheck/releases/download/v${SHELLCHECK_VERSION}/shellcheck-v${SHELLCHECK_VERSION}.linux.x86_64.tar.xz"
tar -xf "${RUNNER_TEMP}/.shellcheck.txz" -C "${RUNNER_TEMP}/shellcheck" --strip-components=1
echo "${RUNNER_TEMP}/shellcheck" >> "${GITHUB_PATH}"
- name: 'Install shellcheck problem matcher'
run: |-
cat > "${RUNNER_TEMP}/shellcheck/problem-matcher-lint-shell.json" <<"EOF"
{
"problemMatcher": [
{
"owner": "lint_shell",
"pattern": [
{
"regexp": "^(.*):(\\\\d+):(\\\\d+):\\\\s+(?:fatal\\\\s+)?(warning|error):\\\\s+(.*)$",
"file": 1,
"line": 2,
"column": 3,
"severity": 4,
"message": 5
}
]
}
]
}
EOF
echo "::add-matcher::${RUNNER_TEMP}/shellcheck/problem-matcher-lint-shell.json"
# Note that only warning and error severity show up in the github files
# page. So we replace 'style' and 'note' with 'warning' to make it show
# up.
#
# We also try and find all bash scripts even if they don't have an
# explicit extension.
#
# We explicitly ignore the following rules:
#
# - SC2002: This rule suggests using "cmd < file" instead of "cat | cmd".
# While < is more efficient, pipes are much more readable and expected.
#
# - SC2129: This rule suggests grouping multiple writes to a file in
# braces like "{ cmd1; cmd2; } >> file". This is unexpected and less
# readable.
#
# - SC2310: This is an optional warning that only appears with "set -e"
# and when a command is used as a conditional.
- name: 'Run shellcheck'
run: |-
git ls-files | grep -E '^([^.]+|.*\.(sh|zsh|bash))$' | xargs file --mime-type \
| grep "text/x-shellscript" | awk '{ print substr($1, 1, length($1)-1) }' \
| xargs shellcheck \
--check-sourced \
--enable=all \
--exclude=SC2002,SC2129,SC2310,SC2311,SC2312 \
--severity=style \
--format=gcc \
--color=never | sed -e 's/note:/warning:/g' -e 's/style:/warning:/g'
#
# Lint: YAML
#
lint_yaml:
name: 'Lint (YAML)'
runs-on: 'ubuntu-latest'
needs:
- 'skip_check'
if: ${{ needs.skip_check.outputs.should_skip != 'true' }}
steps:
- name: 'Checkout'
uses: 'actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1' # ratchet:actions/checkout@v7
with:
fetch-depth: 1
- name: 'Setup Python'
uses: 'actions/setup-python@5fda3b95a4ea91299a34e894583c3862153e4b97' # ratchet:actions/setup-python@v7
with:
python-version: '3'
- name: 'Install yamllint'
run: |-
pip install --user "yamllint==${YAMLLINT_VERSION}"
- name: 'Run yamllint'
run: |-
git ls-files | grep -E '\.(yaml|yml)' | xargs yamllint --format github
#
# Lint: All
#
# This is a virtual job that other jobs depend on to wait for all linters to
# finish. It's also used to ensure linting happens on CI via required
# workflows.
lint:
name: 'Lint'
needs:
- 'lint_github_actions'
- 'lint_javascript'
- 'lint_shell'
- 'lint_yaml'
# node_consumer_smoke provides a cheap package install/invocation gate.
# test_shard depends directly on it (issue #2877); lint retains the
# dependency here to preserve smoke coverage when the matrix is skipped.
- 'node_consumer_smoke'
# doc_change_filter (issue #342) makes node_consumer_smoke skippable on
# docs-only PRs. skip_check makes every job skippable on duplicate runs.
# Both are read below so this required aggregator stays honest instead of
# being skipped by GitHub when a needed job is skipped.
- 'doc_change_filter'
- 'skip_check'
if: ${{ always() }}
runs-on: 'ubuntu-latest'
steps:
- name: 'Check lint results'
run: |-
should_skip='${{ needs.skip_check.outputs.should_skip }}'
docs_only='${{ needs.doc_change_filter.outputs.docs_only }}'
lint_github_actions_result='${{ needs.lint_github_actions.result }}'
lint_javascript_result='${{ needs.lint_javascript.result }}'
lint_shell_result='${{ needs.lint_shell.result }}'
lint_yaml_result='${{ needs.lint_yaml.result }}'
node_consumer_smoke_result='${{ needs.node_consumer_smoke.result }}'
# Explicit duplicate-skip: skip_check said this run duplicates a
# passing one, so every downstream job was intentionally skipped.
# The required Lint check is green by design.
if [ "$should_skip" == "true" ]; then
echo "skip_check reported a duplicate passing run (should_skip=true). Lint check is green by design."
exit 0
fi
# Every linter must succeed regardless of PR type.
if [ "$lint_github_actions_result" != "success" ]; then
echo "::error::GitHub Actions lint did not succeed (result: $lint_github_actions_result)"
exit 1
fi
if [ "$lint_javascript_result" != "success" ]; then
echo "::error::JavaScript lint did not succeed (result: $lint_javascript_result)"
exit 1
fi
if [ "$lint_shell_result" != "success" ]; then
echo "::error::Shell lint did not succeed (result: $lint_shell_result)"
exit 1
fi
if [ "$lint_yaml_result" != "success" ]; then
echo "::error::YAML lint did not succeed (result: $lint_yaml_result)"
exit 1
fi
# node_consumer_smoke must succeed on code PRs. On docs-only PRs
# (issue #342) it is intentionally skipped, which is accepted here.
if [ "$node_consumer_smoke_result" != "success" ]; then
if [ "$docs_only" == "true" ] && [ "$node_consumer_smoke_result" == "skipped" ]; then
echo "docs-only PR: node_consumer_smoke intentionally skipped (issue #342)."
else
echo "::error::Node Consumer Smoke did not succeed (result: $node_consumer_smoke_result)"
exit 1
fi
fi
echo 'All linters finished!'
#
# Bun: Workspace install smoke
#
# Verifies the S1 acceptance criterion that `bun install` succeeds from a
# clean checkout and wires up every workspace package. Uses a plain
# `bun install` rather than `--frozen-lockfile`: Bun re-normalizes this
# monorepo's lockfile on every pass (see dev-docs/bun.md), so a frozen check
# would be perpetually red despite a valid, deterministically generated
# lockfile. Pinning via .bun-version keeps the toolchain reproducible.
bun_install_smoke:
name: 'Bun Install Smoke'
runs-on: 'ubuntu-latest'
# A monorepo smoke install completes in well under a minute; cap the job so a
# hung `bun install` (registry stall or workspace-resolution deadlock) fails
# fast instead of occupying a runner up to the 6-hour GitHub Actions default.
timeout-minutes: 15
needs:
- 'doc_change_filter'
- 'skip_check'
# Skip on docs-only PRs (issue #342): a doc edit cannot change whether
# `bun install` resolves and links the workspaces.
if: ${{ needs.doc_change_filter.outputs.docs_only != 'true' && needs.skip_check.outputs.should_skip != 'true' }}
steps:
- name: 'Checkout'
uses: 'actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1' # ratchet:actions/checkout@v7
with:
# This job runs `bun install`, which executes the lifecycle scripts of
# trusted native dependencies. It performs no authenticated git
# operation after checkout, so the default credential persistence only
# widens the token's exposure to those install-time scripts. Drop it.
persist-credentials: false
- name: 'Setup Bun'
uses: 'oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6' # ratchet:oven-sh/setup-bun@v2
with:
bun-version-file: '.bun-version'
- name: 'Install workspaces with Bun'
run: |-
bun install
- name: 'Verify Bun linked every declared local workspace package'
# Runs the committed verifier (also runnable locally via
# `bun install && bun scripts/verify-bun-workspace-links.ts`) so the
# link-check logic lives in one tested place instead of an inline
# heredoc. Executed with `bun` — already set up for this job — to avoid
# relying on an implicitly-provided Node on the runner.
run: |-
bun scripts/verify-bun-workspace-links.ts
#
# Bun: Native-module smoke (issue 2239, S2)
#
# Verifies that the native modules the CLI depends on load and operate under
# the Bun runtime on POSIX: @ast-grep/napi, @napi-rs/keyring (construct-only),
# web-tree-sitter + tree-sitter-bash WASM, and the Bun.Terminal PTY adapter
# (the bun-pty seam). Does NOT weaken existing checks — it is an additive job.
bun_native_modules_smoke:
name: 'Bun Native Modules Smoke'
runs-on: 'ubuntu-latest'
timeout-minutes: 15
needs:
- 'doc_change_filter'
- 'skip_check'
# Skip on docs-only PRs (issue #342): a doc edit cannot change native
# module load/operate behaviour under the Bun runtime.
if: ${{ needs.doc_change_filter.outputs.docs_only != 'true' && needs.skip_check.outputs.should_skip != 'true' }}
permissions:
contents: 'read'
steps:
- name: 'Checkout'
uses: 'actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1' # ratchet:actions/checkout@v7
with:
persist-credentials: false
- name: 'Set up Node.js'
uses: 'actions/setup-node@820762786026740c76f36085b0efc47a31fe5020' # ratchet:actions/setup-node@v7
with:
node-version-file: '.nvmrc'
cache: 'npm'
- name: 'Setup Bun'
uses: 'oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6' # ratchet:oven-sh/setup-bun@v2
with:
bun-version-file: '.bun-version'
# `npm install`, not `npm ci`: packages/cli declares the os-gated launcher
# packages (issue #2978) as optionalDependencies. They cannot be root
# workspaces -- npm enforces a workspace's `os` field and fails
# EBADPLATFORM on every platform -- so before their first publish they are
# unresolvable and absent from the lockfile. `npm ci` rejects that as a
# manifest/lock desync; `npm install` correctly omits an unresolvable
# OPTIONAL dependency, exits 0, and leaves the lockfile untouched. This
# job only needs node_modules for the harness below, so it does not
# depend on `npm ci`'s stricter guarantees.
- name: 'Install dependencies'
run: |-
npm install --no-audit --no-fund
- name: 'Run Bun native-module smoke harness'
run: |-
bun scripts/bun-native-modules-smoke.ts
#
# Node consumer smoke (issue 2243, S6 / issue 2603)
#
# Guards npm install/invocation compatibility: install with npm, then run the
# installed bin directly. The bin is a POSIX sh launcher (issue #2603) that
# execs the package-local Bun against packages/cli/index.ts — no Node process
# is started on the installed command path. A direct dependency of test_shard
# (issue #2877) and of the lint aggregator, so broken package installs or CLI
# invocation fail before matrix fanout.
node_consumer_smoke:
name: 'Node Consumer Smoke'
runs-on: 'ubuntu-latest'
timeout-minutes: 15
needs:
- 'doc_change_filter'
- 'skip_check'
# Skip on docs-only PRs (issue #342): a doc edit cannot change npm
# package install/invocation compatibility.
if: ${{ needs.doc_change_filter.outputs.docs_only != 'true' && needs.skip_check.outputs.should_skip != 'true' }}
# This job installs the packed package with npm (executing third-party
# install scripts) and only needs to read the repo, so scope permissions to
# contents:read and drop credential persistence. It validates the published
# npm entry path by running the installed launcher directly after install;
# the launcher execs Bun on TypeScript source.
permissions:
contents: 'read'
steps:
- name: 'Checkout'
uses: 'actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1' # ratchet:actions/checkout@v7
with:
fetch-depth: 1
persist-credentials: false
- name: 'Set up Node.js'
uses: 'actions/setup-node@820762786026740c76f36085b0efc47a31fe5020' # ratchet:actions/setup-node@v7
with:
node-version-file: '.nvmrc'
cache: 'npm'
- name: 'Setup Bun'
# The installed launcher executes Bun against the package's TypeScript
# sources even though the package itself is installed with npm.
uses: 'oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6' # ratchet:oven-sh/setup-bun@v2
with:
bun-version-file: '.bun-version'
- name: 'Pack source-runtime package'
run: |-
mkdir -p "$RUNNER_TEMP/llxprt-pack"
npm pack --pack-destination "$RUNNER_TEMP/llxprt-pack"
- name: 'Install packed package with npm'
run: |-
mkdir -p "$RUNNER_TEMP/llxprt-consumer"
cd "$RUNNER_TEMP/llxprt-consumer"
npm init -y
npm install "$RUNNER_TEMP/llxprt-pack"/*.tgz
- name: 'Smoke test installed CLI entry (launcher -> Bun, no Node in chain)'
run: '"$RUNNER_TEMP/llxprt-consumer/node_modules/.bin/llxprt" --version'
#
# Bun-backed test orchestration smoke (issue #2463)
#
# Verifies that `bun scripts/test.ts` (the `test:bun` entry point) can
# discover all workspaces, parse their test/pretest scripts, and produce
# a summary — using a dry-run mode that does not actually execute the
# workspace test suites. This catches regressions in the orchestrator itself
# without the cost of a full test matrix. The actual workspace tests still
# run under Bun's native runner via the existing `test` job; this job only
# validates the Bun-backed orchestration script.
bun_test_orchestrator_smoke:
name: 'Bun Test Orchestrator Smoke'
runs-on: 'ubuntu-latest'
timeout-minutes: 10
needs:
- 'doc_change_filter'
- 'skip_check'
# Skip on docs-only PRs (issue #342): a doc edit cannot change test
# orchestrator discovery/parsing/routing behaviour.
if: ${{ needs.doc_change_filter.outputs.docs_only != 'true' && needs.skip_check.outputs.should_skip != 'true' }}
permissions:
contents: 'read'
steps:
- name: 'Checkout'
uses: 'actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1' # ratchet:actions/checkout@v7
with:
persist-credentials: false
- name: 'Setup Bun'
uses: 'oven-sh/setup-bun@0c5077e51419868618aeaa5fe8019c62421857d6' # ratchet:oven-sh/setup-bun@v2
with:
bun-version-file: '.bun-version'
- name: 'Install dependencies'
run: |-
bun install
git checkout -- bun.lock
- name: 'Run test orchestrator on a single workspace'
# Runs the orchestrator against one workspace. --skip-pretest skips
# pretest hooks (like the agents API-surface guard) to keep the smoke
# fast. The workspace's test phase still runs, but test-utils has a
# tiny test suite. --skip-scripts skips the root script harness tests.
# The only failure modes that matter here are bugs in the orchestrator
# itself (discovery, parsing, routing).
run: |-
bun scripts/test.ts --workspace test-utils --skip-scripts
- name: 'Run script harness tests for the orchestrator'
run: |-
bun test --preload ./scripts/tests/test-setup.ts scripts/tests/test-orchestrator.test.ts
- name: 'Verify every test file is covered by some executor'
# Fails when a test file exists on disk that no executor runs (uncovered)
# or when two executors both run the same file (doubly-executed). This
# runs on every non-docs-only PR regardless of which shard it touches,
# so a package-only change cannot introduce an uncovered file.
run: |-
bun scripts/check-test-file-coverage.ts
#
# Windows test-infra gate (issue #3439)
#
# The full Windows matrix lives in the nightly (issue #3153), which meant
# Windows-incompatible test code merged green and was first exercised by
# the next day's nightly — the recurring "Nightly workflow failed" issues.
# This gate runs the Windows-sensitive test infrastructure (the per-package
# bun test runners, the CLI launcher shims, and the test orchestrator) on
# windows-latest for every push to main, and for PRs that touch that
# surface, so the same class of failure is caught within minutes of the
# offending change instead of the next night. It deliberately does NOT run
# the six-shard corpus (issue #3249 keeps Windows runner cost bounded);
# only the suites whose subjects are process launching and path handling,
# which is exactly the Windows-divergent surface.
windows_test_infra:
name: 'Windows Test-Infra Gate'
runs-on: 'windows-latest'
timeout-minutes: 20
needs:
- 'doc_change_filter'
- 'skip_check'
if: ${{ needs.doc_change_filter.outputs.docs_only != 'true' && needs.skip_check.outputs.should_skip != 'true' }}
permissions:
contents: 'read'
pull-requests: 'read'
outputs:
affected: '${{ steps.filter.outputs.affected }}'