Repository navigation
1963 lines (1819 loc) · 93.8 KB
/
Copy pathci.yml
File metadata and controls
1963 lines (1819 loc) · 93.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
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
# ============================================================================
# CI POLICY (maintainer decision — do not change in a contributor PR)
# * Pull requests run ONLY the fast Ubuntu subset (default: gates + `test changed`).
# * Full cross-platform (macOS/Windows) CI runs ONLY via manual
# workflow_dispatch on dev.
# * NEVER add a push trigger or pull_request runs for macOS/Windows jobs.
# PRs that change this policy will be closed. See AGENTS.md "CI policy".
# ============================================================================
name: Cross-platform CI
run-name: ocx-ci-v1 lane=${{ github.event.inputs.lane || 'all' }} sha=${{ github.sha }}
on:
# Always create the aggregate `ci` check for pull requests. Expensive jobs
# apply the former path allowlist through the `changes` job below, so a
# docs-only PR receives explicit positive evidence instead of no check at all.
pull_request: {}
# No base-branch filter on purpose. GitHub matches `branches:` against the
# BASE ref, so even `[dev]` would silently exclude stacked child PRs — whose
# base is another open PR's head branch, an intentional review workflow per
# AGENTS.md that `enforce-target` already exempts from the wrong-base gate.
# The #951-#955 stack merged with `enforce-target`, `label`, and
# `react-doctor` as its only check-runs: no test job ever queued for 24
# changed files under `src/`.
#
# An allowlist cannot express "base is another PR's head" — stacked bases
# carry contributor prefixes (`fix/`, `feat/`, `agent/`) as readily as
# `codex/`, and contributor stacks need CI most. The `changes` job below is
# the real scope gate for expensive jobs. Safe to
# widen here because this workflow is `pull_request` (not `pull_request_target`),
# declares `contents: read`, and reads no secrets.
#
# Pull requests run only the fast Ubuntu subset. Cross-platform jobs run
# after merge by a manual workflow_dispatch on dev.
workflow_dispatch:
inputs:
lane:
description: "all (default), release-gates, macos-control, or windows-native-claim"
type: choice
default: all
options: [all, release-gates, macos-control, windows-native-claim]
permissions:
contents: read
concurrency:
# Pull requests want supersession: a newer head on the same ref
# makes the older one irrelevant, and cancelling it saves an hour of runners
# for an answer nobody will read.
#
# `workflow_dispatch` is the opposite. An operator dispatching a lane has
# asked for evidence about one specific commit, and the next merge into
# `dev` is not a newer answer to that question — it is an unrelated commit
# that happens to share `github.ref`. Keyed on the ref alone, the merge
# cancelled the dispatch, so the `macos control` lane — the longest job in
# this workflow at roughly fifty minutes — could not complete on any branch
# under active development. Run 35318264610 was cancelled in the same second
# its job started, three minutes after it was queued. Cancellations of that
# shape were read as runner capacity for months, and a maintainer dispatching
# the lane for release evidence usually got nothing back without noticing,
# because a cancelled job reports neither pass nor fail (#5037).
#
# `github.run_id` is unique per run, so each dispatch is a group of one: it
# cancels nothing and nothing cancels it, including a second dispatch of the
# same ref.
#
# The schedule branch of this expression is retained for selector compatibility;
# this workflow no longer declares a schedule trigger.
group: cross-platform-ci-${{ github.event_name == 'workflow_dispatch' && github.run_id || github.event_name == 'schedule' && github.run_id || github.ref }}
cancel-in-progress: ${{ github.event_name != 'workflow_dispatch' && github.event_name != 'schedule' }}
jobs:
# Which Windows runner this run is allowed to use.
#
# READ THIS BEFORE TREATING IT AS A SECURITY BOUNDARY: it is not one.
#
# On `pull_request` this workflow is loaded from the PR head, so the `case`
# below is owned by the proposed patch exactly like an `if:` guard would be.
# A hostile PR can delete the branch and hardcode the self-hosted labels into
# `$GITHUB_OUTPUT`, and `runs-on` will honour it. That this job runs on
# `ubuntu-latest` changes nothing — the untrusted part is its OUTPUT, not its
# host. `.github/workflows/ci.yml` is in the `changes` job's `ci` filter, so
# such an edit triggers every expensive verification job.
#
# What actually keeps untrusted code off a self-hosted runner lives OUTSIDE
# this file, where a PR cannot reach it: the fork-PR approval policy
# (`all_external_contributors`) and the judgement of whoever clicks approve.
# Runner groups would be the other lever, but they are an organisation
# feature and this repository is user-owned, so the approval policy is the
# only one available here. GitHub's own guidance is to avoid self-hosted
# runners on public repositories for this reason.
#
# So read the routing below as a STABILITY/OPERATIONS control that keeps
# honest pull requests on GitHub-hosted runners and lets trusted branch runs
# avoid the hosted-Windows Bun crashes. It is not the security boundary.
#
# `workflow_dispatch` requires write access, but a trusted author does not
# make candidate dependencies or postinstall hooks independently audited.
select-windows-runner:
name: select windows runner
runs-on: ubuntu-latest
timeout-minutes: 2
outputs:
runner: ${{ steps.pick.outputs.runner }}
label: ${{ steps.pick.outputs.label }}
steps:
# This job also runs when the diagnostic lane skips changes.
- name: Validate dispatch source
shell: bash
env:
EVENT_NAME: ${{ github.event_name }}
REF: ${{ github.ref }}
run: |
if [ "$EVENT_NAME" = workflow_dispatch ] && [ "$REF" != refs/heads/dev ]; then
echo '::error::manual cross-platform CI must run from dev'
exit 1
fi
- name: Pick runner
id: pick
env:
# Read through env rather than interpolating directly into the script:
# `github.event_name` is a fixed vocabulary, but keeping the habit means
# no future edit here can grow a script-injection sink.
EVENT_NAME: ${{ github.event_name }}
USE_SELF_HOSTED: ${{ vars.OCX_SELF_HOSTED_WINDOWS }}
shell: bash
run: |
set -euo pipefail
trusted=no
case "$EVENT_NAME" in
push|workflow_dispatch|schedule) trusted=yes ;;
esac
# Repository variable OCX_SELF_HOSTED_WINDOWS is an OPERATIONAL switch,
# not a security control: a PR that rewrites this script ignores it for
# the same reason it ignores the event check above. Its job is to keep CI
# working when the box is off or busy. Anything other than `1` —
# including unset, the state before a runner exists — falls back to
# windows-latest.
if [ "$trusted" = "yes" ] && [ "${USE_SELF_HOSTED:-}" = "1" ]; then
echo 'runner=["self-hosted","Windows","X64","ocx-home"]' >> "$GITHUB_OUTPUT"
echo 'label=self-hosted (ocx-home)' >> "$GITHUB_OUTPUT"
else
echo 'runner="windows-latest"' >> "$GITHUB_OUTPUT"
echo 'label=windows-latest' >> "$GITHUB_OUTPUT"
fi
# Which areas the pull request actually touches.
#
# Deliberately a job-level filter rather than a wider workflow-level `paths:`
# one. A workflow skipped by path filtering leaves its checks Pending forever,
# so a PR requiring them can never merge; a skipped *job* reports success.
# That asymmetry is the whole reason this job exists instead of more entries
# in the `on:` block above.
changes:
name: changes
if: github.event_name != 'workflow_dispatch' || github.event.inputs.lane != 'windows-native-claim'
runs-on: ubuntu-latest
timeout-minutes: 5
# The workflow grants only `contents: read`, and specifying any permission
# sets every unspecified one to `none`. paths-filter reads the PR's file list
# through the API on `pull_request`, so without this it fails outright — and
# a failed filter produces empty outputs, which every `== 'true'` condition
# below would read as "nothing changed, skip".
permissions:
contents: read
pull-requests: read
outputs:
# Downstream jobs consume only the value re-emitted by the validation
# step. A missing or malformed filter output must fail this job instead
# of silently making every expensive job skip.
ci: ${{ steps.scope.outputs.ci }}
desktop: ${{ steps.scope.outputs.desktop }}
fast: ${{ steps.lane.outputs.fast }} # true: `test changed` replaces the five shards
native: ${{ steps.matrices.outputs.native }}
# Matrix include lists for keyring-smoke and npm-global-smoke, built and
# shape-checked by the same validation step as `native`.
keyring_matrix: ${{ steps.matrices.outputs.keyring_matrix }}
npm_global_matrix: ${{ steps.matrices.outputs.npm_global_matrix }}
# A full manual dispatch selects every scope regardless of path filters.
gui: ${{ (github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' && (github.event.inputs.lane == '' || github.event.inputs.lane == 'all')) && 'true' || steps.filter.outputs.gui }}
packaging: ${{ (github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' && (github.event.inputs.lane == '' || github.event.inputs.lane == 'all')) && 'true' || steps.filter.outputs.packaging }}
docs: ${{ (github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' && (github.event.inputs.lane == '' || github.event.inputs.lane == 'all')) && 'true' || steps.filter.outputs.docs }}
structure: ${{ (github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' && (github.event.inputs.lane == '' || github.event.inputs.lane == 'all')) && 'true' || steps.filter.outputs.structure }}
# Narrow scopes for two paths the ci filter leaves out on purpose. Both are re-emitted by the
# validation step below, so a malformed filter output fails this job instead of silently
# skipping the check it selects.
setup_action: ${{ steps.narrow.outputs.setup_action }}
remote_helper: ${{ steps.narrow.outputs.remote_helper }}
# Pull-request scope for the two smoke jobs that used to ride the whole ci filter.
# Manual dispatch runs both regardless; see the docker/keyring filters.
docker: ${{ steps.narrow.outputs.docker }}
keyring: ${{ steps.narrow.outputs.keyring }}
# Whether this pull request needs the Windows shards: the windows path
# filter below OR an added src/tests line naming a Windows marker. Computed
# by scripts/ci/windows-sensitive-diff.sh, which validates its input and
# treats the diff as data.
windows: ${{ steps.windows.outputs.windows }}
# The commit every test job checks out. Empty (the event's own commit)
# except on a schedule, where it is the one dev SHA resolved below.
checkout_ref: ${{ steps.nightly.outputs.checkout_ref }}
steps:
- name: Validate dispatch source
shell: bash
env:
EVENT_NAME: ${{ github.event_name }}
REF: ${{ github.ref }}
run: |
if [ "$EVENT_NAME" = workflow_dispatch ] && [ "$REF" != refs/heads/dev ]; then
echo '::error::manual cross-platform CI must run from dev'
exit 1
fi
- name: Checkout
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7
with:
# No job here pushes, and the self-hosted box keeps its checkout
# between jobs, so leaving a usable token in .git/config is avoidable
# residue. Matches the convention already used by the other workflows.
persist-credentials: false
# The pull request merge commit plus its first parent, the base tip,
# so the Windows marker scan can diff exactly this pull request.
fetch-depth: 2
- name: Detect changed areas
id: filter
uses: dorny/paths-filter@de90cc6fb38fc0963ad72b210f1f284cd68cea36 # v3.0.2
with:
# Without this the action compares against the repository's DEFAULT
# branch, which is `dev`. For a non-PR event that diff starts at
# `dev` itself, so every area touched since the branch point keeps
# reading as "changed" — the scoped jobs would run on nearly every
# such event and the saving would silently not happen while CI stayed
# green.
#
# On `pull_request` the action ignores this and uses the PR's own file
# list. Otherwise `github.ref` keeps the diff scoped to this ref, which
# is the intent.
base: ${{ github.ref }}
filters: |
# Pull requests always
# start the workflow so the aggregate check exists, while these
# paths decide whether the expensive test jobs need to run.
ci:
- 'Dockerfile'
- 'compose.yaml'
- '.dockerignore'
- 'docker/**'
- 'src/**'
- 'bin/**'
- 'tests/**'
- 'scripts/**'
- 'app/**'
- 'desktop/**'
- 'gui/**'
- 'assets/**'
- '.github/scripts/**'
- '.github/workflows/**'
- '.gitattributes'
- '.npmignore'
- 'package.json'
- 'bun.lock'
- 'tsconfig.json'
- 'README.md'
- 'readme/**'
- 'skills/**'
- '.github/ISSUE_TEMPLATE/**'
- 'LICENSE'
# Native-gated surface: platform-macos, widget and desktop-shell
# only run when the code they build or bundle could have changed.
# The listed src/ entries are what the bundled sidecar executes,
# package.json and bun.lock change what ships inside the bundle,
# and `.github/workflows/ci.yml` verifies this filter itself, the
# way docs and structure above do.
native:
- 'app/**'
- 'desktop/**'
- 'src/service/**'
- 'src/cli/index.ts'
- 'src/lib/bun-runtime.ts'
- 'src/lib/standalone.ts'
- 'src/lib/keyring-native.ts'
- 'scripts/build-standalone.ts'
- 'scripts/standalone-keyring.ts'
- 'package.json'
- 'bun.lock'
- '.github/workflows/ci.yml'
gui:
- 'gui/**'
# Building both Linux package formats and booting their real payloads takes
# about 15 minutes, far more than the Rust-only desktop-shell check. On a
# pull request it runs only for inputs that change how the package is
# assembled or launched: the shell itself, the standalone sidecar build
# and its runtime locator, the native keyring staging, and the dependency
# set. Ordinary src/** and gui/** changes no longer select it on a pull
# request; a full manual dispatch requests this job after merge.
# The workflow names itself so edits to this lane cannot skip their own E2E.
desktop:
- 'desktop/**'
- 'src/lib/standalone.ts'
- 'src/lib/keyring-native.ts'
- 'src/lib/bun-runtime.ts'
- 'scripts/build-standalone.ts'
- 'scripts/standalone-keyring.ts'
- 'scripts/standalone-targets.ts'
- 'package.json'
- 'bun.lock'
- '.github/workflows/ci.yml'
# The docs site is built by nothing else on a pull request. `ci` above
# deliberately omits `docs-site/**` -- a prose edit has no business
# starting the cross-platform suite -- and `deploy-docs.yml` is
# dispatch-only. That left the Astro toolchain with no pull-request
# build gate at all, so a dependency bump under `docs-site/` could
# only be proven by an author's local run and would otherwise surface
# at release time.
#
# `.github/workflows/ci.yml` is here so an edit to the job below
# verifies itself. Without it this filter's own pull request would
# skip the thing it adds.
docs:
- 'docs-site/**'
- '.github/workflows/ci.yml'
# `structure/` is the one directory whose entire purpose is a gate,
# and it was the one directory the gate never saw. `ci` above omits
# it for the same reason it omits `docs-site/**`, so a pull request
# touching only `structure/` skipped every expensive leg — including
# the suite that contains `tests/ci-workflows/structure-ssot.test.ts`,
# the only place CI runs `bun run structure:check`. The aggregate
# then reported success over nothing. #4999, a pure doc split, is the
# live example; it stayed invisible for so long because
# `structure/AGENTS.md` makes a `structure/` edit almost always
# arrive beside a `src/` one, which the `ci` filter does match.
#
# The job this feeds runs the gate alone rather than widening `ci`,
# so a prose edit still does not start the cross-platform matrix.
# `.github/workflows/ci.yml` is listed for the same reason `docs`
# lists it: without it this filter's own pull request would skip the
# job it adds.
# This list keeps pull-request scope narrow; full manual dispatches
# also select the structure gate.
structure:
- 'structure/**'
- '.github/workflows/ci.yml'
# The composite action every Bun job runs. `ci` omits .github/actions/** for the same
# reason it omits docs-site/** and structure/**: a change that touches only the action
# would otherwise start the full matrix. Without this filter it started nothing, and the
# aggregate reported success over skips. The job it feeds runs the action on the three
# runner families and checks what it installed. Pull-request scope, like docs and
# structure; ci.yml is listed so an edit here verifies itself.
setup_action:
- '.github/actions/**'
- '.github/workflows/ci.yml'
# The Rust remote-workspace helper. Nothing else in CI builds it, and its sandbox is
# real only on macOS and Windows, so its job lints and tests the crate on all three.
remote_helper:
- 'native/remote-workspace-helper/**'
# docker-smoke and keyring-smoke on a pull request. Both used to run on every PR the
# ci filter matched, which is nearly all of them, while each proves something narrow:
# the image builds, starts and survives recreation with its volume; the OS keyring
# binding creates, reads and deletes a secret. A pull request now runs each only when
# its own inputs move. Manual dispatch requests both unconditionally.
# ci.yml is listed so an edit to either job verifies itself. The setup action is left to
# its own setup-action job, as the docs and structure filters leave it.
docker:
- 'Dockerfile'
- 'compose.yaml'
- '.dockerignore'
- 'docker/**'
- 'scripts/ci/docker-smoke.ts'
- 'scripts/generate-compatibility-version.ts'
- 'scripts/model-metadata.source.json'
# The image copies and runs src/, then builds the GUI with tsc and Vite.
# Include their inputs without selecting GUI tests or documentation alone.
- 'src/**'
- 'package.json'
- 'bun.lock'
- 'tsconfig.json'
- 'gui/package.json'
- 'gui/bun.lock'
- 'gui/src/**'
- 'gui/public/**'
- 'gui/index.html'
- 'gui/vite.config.ts'
- 'gui/tsconfig*.json'
- '.github/workflows/ci.yml'
# scripts/keyring-smoke.ts imports only src/lib/keyring-native.ts; the native binding
# itself arrives through package.json and bun.lock.
keyring:
- 'src/lib/keyring-native.ts'
- 'scripts/keyring-smoke.ts'
- 'package.json'
- 'bun.lock'
- '.github/workflows/ci.yml'
# Paths whose change selects the Windows suite shards on a pull
# request. These carry the Windows service, update, shim, intercept,
# ACL and process code, and the harness every Windows shard runs.
# scripts/ci/windows-sensitive-diff.sh adds the content markers.
windows:
- 'src/lib/windows-*'
- 'src/lib/*acl*'
- 'src/service/**'
- 'src/update/**'
- 'src/claude/intercept/**'
- 'src/codex/shim*'
- 'src/codex/app-server-processes.ts'
- 'src/codex/desktop-app/**'
- 'src/config/process-state.ts'
- 'src/cli/update-restart*'
- 'src/server/local-management-read-client.ts'
- 'src/server/startup-health-cache.ts'
- 'src/tray/**'
- 'scripts/test.ts'
- 'scripts/test-*.ts'
- 'scripts/ci/**'
- 'tests/preload.ts'
- 'tests/helpers/**'
- '.github/workflows/ci.yml'
- 'package.json'
- 'bun.lock'
# Everything that ends up inside `npm pack`, or that decides what
# does. `src/**` belongs here because package.json ships `src` and
# bin/ocx.mjs executes it: without that entry an ordinary source PR
# would get no Windows verification at all, since the Windows suite
# now runs only at the shipping boundary.
packaging:
- 'package.json'
- 'bun.lock'
- 'src/**'
- 'bin/**'
- 'gui/**'
- 'assets/**'
- '.npmignore'
# `.gitattributes` decides how tracked package inputs are
# materialized on each runner, so an attribute change can put CRLF
# shebangs into the tarball without any source file moving.
- '.gitattributes'
- 'README.md'
- 'LICENSE'
- 'scripts/prepare-package.ts'
- name: Assert the scope output is usable
id: scope
shell: bash
env:
CI_SCOPE: ${{ (github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' && (github.event.inputs.lane == '' || github.event.inputs.lane == 'all')) && 'true' || steps.filter.outputs.ci }}
DESKTOP_SCOPE: ${{ (github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' && (github.event.inputs.lane == '' || github.event.inputs.lane == 'all')) && 'true' || steps.filter.outputs.desktop }}
run: |
set -euo pipefail
case "$CI_SCOPE" in
true|false)
printf 'ci=%s\n' "$CI_SCOPE" >> "$GITHUB_OUTPUT"
;;
*)
printf '::error::changes.outputs.ci was %q, expected true or false\n' "$CI_SCOPE"
exit 1
;;
esac
case "$DESKTOP_SCOPE" in
true|false)
printf 'desktop=%s\n' "$DESKTOP_SCOPE" >> "$GITHUB_OUTPUT"
;;
*)
printf '::error::changes.outputs.desktop was %q, expected true or false\n' "$DESKTOP_SCOPE"
exit 1
;;
esac
- name: Assert the native and matrix outputs are usable
id: matrices
shell: bash
env:
NATIVE_SELECTED: ${{ (github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' && (github.event.inputs.lane == '' || github.event.inputs.lane == 'all')) && 'true' || steps.filter.outputs.native }}
EVENT_NAME: ${{ github.event_name }}
run: |
set -euo pipefail
case "$NATIVE_SELECTED" in
true|false)
printf 'native=%s\n' "$NATIVE_SELECTED" >> "$GITHUB_OUTPUT"
;;
*)
printf '::error::changes.outputs.native was %q, expected true or false\n' "$NATIVE_SELECTED"
exit 1
;;
esac
# These strings are what the keyring-smoke and npm-global-smoke
# matrices consume through fromJSON. A pull request runs only the
# ubuntu leg; the windows and macos legs run after merge on push
# (and on dispatch and the schedule). Outside pull requests, ubuntu
# and windows always run and macos rides the native selection.
if [ "$EVENT_NAME" = "pull_request" ]; then
keyring_matrix='[{"name":"ubuntu","runner":"ubuntu-latest"}]'
npm_global_matrix='[{"os":"ubuntu-latest"}]'
min_legs_filter='length >= 1'
elif [ "$NATIVE_SELECTED" = "true" ]; then
keyring_matrix='[{"name":"ubuntu","runner":"ubuntu-latest"},{"name":"windows","runner":"windows-latest"},{"name":"macos","runner":"macos-latest"}]'
npm_global_matrix='[{"os":"ubuntu-latest"},{"os":"windows-latest"},{"os":"macos-latest"}]'
min_legs_filter='length >= 2'
else
keyring_matrix='[{"name":"ubuntu","runner":"ubuntu-latest"},{"name":"windows","runner":"windows-latest"}]'
npm_global_matrix='[{"os":"ubuntu-latest"},{"os":"windows-latest"}]'
min_legs_filter='length >= 2'
fi
# GitHub turns an empty matrix include list into a job with no legs
# that still reports success, so the emitted value itself is
# validated: it must parse as a JSON array carrying the ubuntu leg,
# and outside pull requests the windows leg too. A malformed or
# empty matrix fails this job instead of passing over nothing.
assert_matrix() {
local label="$1" json="$2" jq_filter="$3"
if ! printf '%s' "$json" | jq -e "$jq_filter" >/dev/null; then
printf '::error::%s matrix output was %q\n' "$label" "$json"
exit 1
fi
}
if [ "$EVENT_NAME" = "pull_request" ]; then
keyring_windows='true'
npm_global_windows='true'
else
keyring_windows='any(.[]; .name == "windows")'
npm_global_windows='any(.[]; .os == "windows-latest")'
fi
assert_matrix keyring "$keyring_matrix" \
"type == \"array\" and $min_legs_filter and any(.[]; .name == \"ubuntu\") and $keyring_windows"
assert_matrix npm-global "$npm_global_matrix" \
"type == \"array\" and $min_legs_filter and any(.[]; .os == \"ubuntu-latest\") and $npm_global_windows"
printf 'keyring_matrix=%s\n' "$keyring_matrix" >> "$GITHUB_OUTPUT"
printf 'npm_global_matrix=%s\n' "$npm_global_matrix" >> "$GITHUB_OUTPUT"
- name: Assert the narrow scope outputs are usable
id: narrow
shell: bash
env:
SETUP_ACTION: ${{ (github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' && (github.event.inputs.lane == '' || github.event.inputs.lane == 'all')) && 'true' || steps.filter.outputs.setup_action }}
REMOTE_HELPER: ${{ (github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' && (github.event.inputs.lane == '' || github.event.inputs.lane == 'all')) && 'true' || steps.filter.outputs.remote_helper }}
DOCKER_SCOPE: ${{ github.event_name == 'schedule' && 'true' || steps.filter.outputs.docker }}
KEYRING_SCOPE: ${{ github.event_name == 'schedule' && 'true' || steps.filter.outputs.keyring }}
run: |
set -euo pipefail
for pair in "setup_action=$SETUP_ACTION" "remote_helper=$REMOTE_HELPER" "docker=$DOCKER_SCOPE" "keyring=$KEYRING_SCOPE"; do
case "${pair#*=}" in
true|false)
printf '%s\n' "$pair" >> "$GITHUB_OUTPUT"
;;
*)
printf '::error::changes.outputs.%s was %q, expected true or false\n' "${pair%%=*}" "${pair#*=}"
exit 1
;;
esac
done
- name: Choose the pull request test lane
id: lane
shell: bash
env:
EVENT_NAME: ${{ github.event_name }}
CI_SCOPE: ${{ steps.scope.outputs.ci }}
FULL_LABEL: ${{ contains(github.event.pull_request.labels.*.name, 'ci:full') }}
run: bash scripts/ci/select-test-lane.sh
- name: Decide whether the Windows shards run
id: windows
shell: bash
env:
EVENT_NAME: ${{ github.event_name }}
PATH_SELECTED: ${{ steps.filter.outputs.windows }}
run: bash scripts/ci/windows-sensitive-diff.sh
# A scheduled run starts from the default branch's head, which is `dev`.
# Resolve dev ONCE so the nine Windows shards, the macOS control and every
# other job test one commit, however long the queue between them.
# contents: read already covers it.
- name: Resolve the commit a scheduled run tests
id: nightly
shell: bash
env:
EVENT_NAME: ${{ github.event_name }}
GH_TOKEN: ${{ github.token }}
run: |
set -euo pipefail
if [ "$EVENT_NAME" != "schedule" ]; then
echo 'checkout_ref=' >> "$GITHUB_OUTPUT"
exit 0
fi
sha="$(gh api "repos/${GITHUB_REPOSITORY}/commits/dev" --jq .sha)"
if ! printf '%s' "$sha" | grep -Eqx '[0-9a-f]{40}'; then
printf '::error::could not resolve dev to a commit SHA\n'
exit 1
fi
printf 'checkout_ref=%s\n' "$sha" >> "$GITHUB_OUTPUT"
printf 'Scheduled run: workflow from %s, testing dev at %s\n' "$GITHUB_SHA" "$sha" >> "$GITHUB_STEP_SUMMARY"
printf 'scheduled run tests dev at %s (workflow %s)\n' "$sha" "$GITHUB_SHA"
# Bun runtime and test-runner roles both read their 1.4.4 defaults from package.json.
# Keep role validation after the historical isolate preload and spawnSync failures
# (#6713, #4956). Promotion requires a green full cross-platform lane=all run on
# the exact candidate head; focused local results do not replace that proof.
# The suite, split by file across five Linux runners.
#
# `scripts/ci/run-bun-test-batches.sh` assigns files to shards by the per-file
# durations recorded in `scripts/ci/test-durations.tsv` (sorted round-robin when
# nothing is recorded), then runs each shard in small batches so every batch gets
# a fresh Bun process. The helper prints the exact files before each batch and retries
# nothing: a test failure, a process timeout and a Bun runtime crash each fail
# the shard where they happen. A timeout or a crash is additionally swept one
# file per process, after the shard has already failed, to attribute it.
# Storage-policy API tests and api-usage are deliberately excluded here and run
# in dedicated jobs below. Bun 1.3.14 can corrupt the Linux isolate/epoll state
# around those Worker-heavy harnesses; keeping them out of the general shards
# prevents one runtime failure from wedging ~150 unrelated files while preserving
# the same coverage in fresh Bun processes.
#
# Only the suite lives here. Typecheck, lint, build, and the scans run once in
# `gates` rather than five times — they are fixed cost, and paying it per shard
# would eat what the sharding saves.
# The heavy Linux jobs (test shards, test-changed, gates) take the lidge self-hosted pool on
# trusted runs while the repository variable LIDGE_RUNNERS is on: pushes, manual runs, branches of
# this repository, and pull requests by owners, members or collaborators. Everything else, and every
# run while the variable is off, stays on ubuntu-latest, so the hosted runners keep carrying the light
# jobs. As with the Windows box above, this routing is operational; the fork-PR approval policy and
# the box's scaler, which only creates runners for trusted runs, are the security boundary.
test:
name: test ${{ matrix.shard }}/5
needs: changes
if: github.event_name != 'pull_request' || (needs.changes.outputs.ci == 'true' && needs.changes.outputs.fast != 'true')
runs-on: ${{ vars.LIDGE_RUNNERS == 'on' && (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository || contains(fromJSON('["OWNER","MEMBER","COLLABORATOR"]'), github.event.pull_request.author_association)) && fromJSON('["self-hosted","linux","x64","lidge"]') || 'ubuntu-latest' }}
# A fifth of the suite. A shard that needs longer than this is wedged, not
# slow — the old 30-minute ceiling was margin for the Windows leg, which no
# longer runs here (see platform-windows).
timeout-minutes: 15
strategy:
fail-fast: false
matrix:
shard: [1, 2, 3, 4, 5]
steps:
- name: Checkout
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7
with:
# No job here pushes, and the self-hosted box keeps its checkout
# between jobs, so leaving a usable token in .git/config is avoidable
# residue. Matches the convention already used by the other workflows.
persist-credentials: false
ref: ${{ needs.changes.outputs.checkout_ref }}
# tests/ci-workflows/release-version-line.test.ts compares package.json against the
# newest release tag. actions/checkout fetches no tags by default, so
# without this the check reads an empty tag set and passes on anything -
# the exact regression it exists to catch would ride through CI green.
#
# Tags only, not full history: `fetch-depth: 0` would clone every commit to
# answer a question about refs. A shallow fetch still brings each tag and its
# target commit, which is all the check reads - the tag list, and whether the
# newest tag names HEAD. That second read only happens on a release commit,
# where the tag points at HEAD and the commit is present by definition.
fetch-tags: true
- name: Setup project Bun
uses: ./.github/actions/setup-project-bun
with:
role: test-runner # See the Bun roles contract above test.
# The GUI install is NOT optional here, however unrelated it looks to a
# test shard. Several files under tests/ import JSX-bearing modules from
# gui/src (ProviderRail and friends), and React is declared only in
# gui/package.json. Without this the affected shards die on
# `Cannot find module 'react/jsx-dev-runtime'` while the other shards pass.
- name: Install dependencies
run: bash scripts/ci/bun-install-frozen.sh . gui
# Nor is the build. Tests that fetch the served dashboard read the session
# bootstrap meta tags out of `gui/dist/index.html`, so without a build the
# server has no index to serve and those assertions see an empty string.
# The old three-platform job happened to satisfy this because every leg ran
# the GUI build as part of the same job; splitting the suite away from the
# gates removed that coincidence, so the dependency has to be explicit.
- name: Build GUI
run: |
cd gui
bun run build
- name: Test in fresh-process batches
env:
TEST_SHARD: ${{ matrix.shard }}/5
run: bash scripts/ci/run-bun-test-batches.sh "$TEST_SHARD"
# Fast lane: import-graph tests for the diff; the batched dev dispatch is the backstop.
test-changed:
name: test changed
needs: changes
if: github.event_name == 'pull_request' && needs.changes.outputs.fast == 'true'
runs-on: ${{ vars.LIDGE_RUNNERS == 'on' && (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository || contains(fromJSON('["OWNER","MEMBER","COLLABORATOR"]'), github.event.pull_request.author_association)) && fromJSON('["self-hosted","linux","x64","lidge"]') || 'ubuntu-latest' }}
timeout-minutes: 30
steps:
- uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7
with:
persist-credentials: false
ref: ${{ needs.changes.outputs.checkout_ref }}
fetch-depth: 2 # merge commit + base tip, which the selection diffs against
- uses: ./.github/actions/setup-project-bun
with:
role: test-runner # See the Bun roles contract above test.
- name: Install dependencies and build the GUI the tests serve
run: bash scripts/ci/bun-install-frozen.sh . gui && cd gui && bun run build
- name: Test the files this pull request reaches
run: bash scripts/ci/run-changed-tests.sh
# Bun 1.3.14 has shown a Linux isolate/epoll race around the storage-policy
# harness. Keep the entire six-file family in one fresh process so a runtime
# failure is bounded to this job instead of poisoning a general test shard.
storage-policy:
name: storage policy
needs: changes
if: github.event_name != 'pull_request' || needs.changes.outputs.ci == 'true'
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- name: Checkout
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7
with:
persist-credentials: false
ref: ${{ needs.changes.outputs.checkout_ref }}
- name: Setup project Bun
uses: ./.github/actions/setup-project-bun
with:
role: test-runner # See the Bun roles contract above test.
- name: Install dependencies
run: bash scripts/ci/bun-install-frozen.sh . gui
- name: Build GUI
run: |
cd gui
bun run build
- name: Test storage policy API
run: |
bun test --isolate \
./tests/storage/api-storage-policy-already-running.test.ts \
./tests/storage/api-storage-policy-mutation-busy.test.ts \
./tests/storage/api-storage-policy-put-race.test.ts \
./tests/storage/api-storage-policy-run.test.ts \
./tests/storage/api-storage-policy.test.ts \
./tests/storage/api-storage.test.ts
# Bun 1.3.14 has shown a Linux isolate wedge around startServer() plus the user
# cost overlay reconciler. Keep api-usage in one fresh process so a runtime
# failure is bounded to this job instead of poisoning a general test shard.
api-usage:
name: api usage
needs: changes
if: github.event_name != 'pull_request' || needs.changes.outputs.ci == 'true'
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- name: Checkout
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7
with:
persist-credentials: false
ref: ${{ needs.changes.outputs.checkout_ref }}
- name: Setup project Bun
uses: ./.github/actions/setup-project-bun
with:
role: test-runner # See the Bun roles contract above test.
- name: Install dependencies
run: bash scripts/ci/bun-install-frozen.sh . gui
- name: Build GUI
run: |
cd gui
bun run build
- name: Test api usage API
run: bun test --isolate ./tests/server/api-usage.test.ts
# Everything that is not the suite: type safety, privacy, lint, build, smoke.
# One runner, once per push. Splitting these across the shards would repeat a
# fixed couple of minutes four times to save nothing.
gates:
name: gates
needs: changes
if: github.event_name != 'pull_request' || needs.changes.outputs.ci == 'true'
runs-on: ${{ vars.LIDGE_RUNNERS == 'on' && (github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository || contains(fromJSON('["OWNER","MEMBER","COLLABORATOR"]'), github.event.pull_request.author_association)) && fromJSON('["self-hosted","linux","x64","lidge"]') || 'ubuntu-latest' }}
timeout-minutes: 15
steps:
- name: Checkout
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7
with:
# No job here pushes, and the self-hosted box keeps its checkout
# between jobs, so leaving a usable token in .git/config is avoidable
# residue. Matches the convention already used by the other workflows.
persist-credentials: false
ref: ${{ needs.changes.outputs.checkout_ref }}
# Release history tests verify old tag and dev-baseline trees.
fetch-depth: 0
- name: Setup project Bun
uses: ./.github/actions/setup-project-bun
with:
role: test-runner # See the Bun roles contract above test.
- name: Install dependencies
run: bash scripts/ci/bun-install-frozen.sh . gui
- name: GUI lint
if: needs.changes.outputs.gui == 'true'
run: |
cd gui
bun run lint
- name: Typecheck
run: |
bun x tsc --noEmit
bun x tsc --noEmit -p tests/tsconfig.doctor-service-memory-contract.json
bun x tsc --ignoreConfig --noEmit --strict --target ESNext --module ESNext --moduleResolution bundler --types bun-types --skipLibCheck scripts/ci/docker-smoke.ts
- name: GUI tests
run: cd gui && bun test --isolate tests
- name: Privacy scan
run: bun run privacy:scan
# The ocx skill ships a capability -> route map generated from src/cli/capabilities.ts.
# `bun run test` already covers this via tests/ci-workflows/skill-ocx.test.ts; this step exists so the
# failure names the fix instead of surfacing as a byte-comparison diff in a test log.
- name: Check the generated ocx skill surface is current
run: bun run skill:surface:check
- name: Test release evidence, history and docs deployment
run: node --test .github/scripts/release-dispatch-guard.test.cjs .github/scripts/release-evidence.test.cjs .github/scripts/release-history.test.cjs .github/scripts/release-resume.test.cjs .github/workflows/deploy-docs.test.cjs
- name: Check release helper syntax
run: bun build scripts/release.ts --target=bun --outdir=.tmp/ci-release-script-check
- name: GUI build
if: needs.changes.outputs.gui == 'true'
run: |
cd gui
bun run build
- name: Record dashboard preview source
if: needs.changes.outputs.gui == 'true'
run: |
git rev-parse HEAD > gui/dist/build-commit.txt
git rev-parse HEAD:gui > gui/dist/build-gui-tree.txt
- name: Upload dashboard preview
if: needs.changes.outputs.gui == 'true'
uses: actions/upload-artifact@043fb46d1a93c77aae656e7c1c64a875d1fc6a0a # v7.0.1
with:
name: dashboard-preview-${{ github.sha }}
path: gui/dist
retention-days: 7
if-no-files-found: error
- name: CLI help smoke
run: bun run src/cli/index.ts help
platform-macos:
name: macos ${{ matrix.shard }}/4
needs: changes
# Never on pull requests: macOS legs run through manual dispatch.
if: github.event_name != 'pull_request'
runs-on: macos-latest
# Four shards. Three replaced two after run 38214884055 hit this cap with
# 68 files left and no failing tests (#6978). The suite outgrew three too:
# run 40727740334 took 13.1-16.4m, 40743681086 12.7-13.7m, and
# 40756291846 15.0-17.1m. In dev lane=all run 40766068492 (b16bc0978b),
# macos 1/3 (123090588998) reached batch 73/88 and macos 2/3
# (123090589363) batch 93/93 before this cap cancelled them, with no failing
# tests. The cap stays 20: the suite needs another shard, not a longer wait,
# and a wedged shard (#4956) is still cut off as early as before. Four suite
# shards + widget/bundle request five macOS jobs for five runner slots; each
# run pays one extra shard's setup overhead. The full-membership control runs
# the same bounded batches without sharding, only on a lane=macos-control
# dispatch.
timeout-minutes: 20
strategy:
fail-fast: false
matrix:
shard: [1, 2, 3, 4]
steps:
- name: Checkout
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7
with:
# No job here pushes, and the self-hosted box keeps its checkout
# between jobs, so leaving a usable token in .git/config is avoidable
# residue. Matches the convention already used by the other workflows.
persist-credentials: false
ref: ${{ needs.changes.outputs.checkout_ref }}
# tests/ci-workflows/release-version-line.test.ts compares package.json against the
# newest release tag. actions/checkout fetches no tags by default, so
# without this the check reads an empty tag set and passes on anything -
# the exact regression it exists to catch would ride through CI green.
#
# Tags only, not full history: `fetch-depth: 0` would clone every commit to
# answer a question about refs. A shallow fetch still brings each tag and its
# target commit, which is all the check reads - the tag list, and whether the
# newest tag names HEAD. That second read only happens on a release commit,
# where the tag points at HEAD and the commit is present by definition.
fetch-tags: true
- name: Setup project Bun
uses: ./.github/actions/setup-project-bun
with:
role: test-runner # See the Bun roles contract above test.
- name: Install dependencies
run: |
bun install --frozen-lockfile
cd gui
bun install --frozen-lockfile
# Same reason as the shards: the suite serves gui/dist and reads it back.
- name: Build GUI
run: |
cd gui
bun run build
- name: Setup bounded batch utilities
run: |
brew list coreutils >/dev/null 2>&1 || brew install coreutils
echo "$(brew --prefix coreutils)/libexec/gnubin" >> "$GITHUB_PATH"
- name: Test in fresh-process batches
env:
TEST_SHARD: ${{ matrix.shard }}/4
BUN_TEST_FILE_SCOPE: all
BUN_TEST_BATCH_SIZE: '12'
BUN_TEST_PARALLEL: '1'
BUN_TEST_BATCH_TIMEOUT_SECONDS: '300'
OCX_TEST_NO_QUEUE: '1'
OCX_TEST_FULL_SUITE: '1'
run: bash scripts/ci/run-bun-test-batches.sh "$TEST_SHARD"
- name: CLI help smoke
run: bun run src/cli/index.ts help
macos-control:
name: macos control
needs: changes
# Diagnostic-only: it runs on an explicit lane=macos-control dispatch and nowhere
# else, so a new lane defaults to skipping it. It used to ride lane=all as well,
# where it reran the whole suite that the four macOS shards had already passed
# on the same commit, on one worker, for 50-60 minutes, and every release waited
# for it. Dispatch it on its own when a sharding-sensitive defect is suspected.
if: >-
github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' && github.event.inputs.lane == 'macos-control'
runs-on: macos-latest
# Unsharded full-membership control, one worker in sequential fresh batches.
# Long-lived Bun isolate pools repeatedly wedged while synchronously reaping
# child processes. Batching bounds that lifetime without retrying failures or
# excluding tests. This no longer claims one whole-suite process as evidence.
timeout-minutes: 75
steps:
- name: Checkout
uses: actions/checkout@9c091bb21b7c1c1d1991bb908d89e4e9dddfe3e0 # v7
with:
# No job here pushes, and the self-hosted box keeps its checkout
# between jobs, so leaving a usable token in .git/config is avoidable
# residue. Matches the convention already used by the other workflows.
persist-credentials: false
ref: ${{ needs.changes.outputs.checkout_ref }}
# tests/ci-workflows/release-version-line.test.ts compares package.json against the
# newest release tag. actions/checkout fetches no tags by default, so
# without this the check reads an empty tag set and passes on anything -
# the exact regression it exists to catch would ride through CI green.
#
# Tags only, not full history: `fetch-depth: 0` would clone every commit to
# answer a question about refs. A shallow fetch still brings each tag and its
# target commit, which is all the check reads - the tag list, and whether the
# newest tag names HEAD. That second read only happens on a release commit,
# where the tag points at HEAD and the commit is present by definition.
fetch-tags: true
- name: Setup project Bun
uses: ./.github/actions/setup-project-bun
with:
role: test-runner # See the Bun roles contract above test.
- name: Install dependencies
run: |
bun install --frozen-lockfile
cd gui
bun install --frozen-lockfile
# Same reason as the shards: the suite serves gui/dist and reads it back.
- name: Build GUI
run: |
cd gui
bun run build
- name: Setup bounded batch utilities
run: |
brew list coreutils >/dev/null 2>&1 || brew install coreutils
echo "$(brew --prefix coreutils)/libexec/gnubin" >> "$GITHUB_PATH"
- name: Test in unsharded fresh-process batches
env: