Repository navigation
1900 lines (1760 loc) · 88.2 KB
/
Copy pathci.yml
File metadata and controls
1900 lines (1760 loc) · 88.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
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.
# * Full cross-platform (macOS/Windows) CI runs ONLY via manual
# workflow_dispatch and on push to main/preview (release lines).
# * NEVER add a dev 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
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 `[main, dev]` silently excluded 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, using the same allowlist as the push trigger. 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. Every macOS and Windows
# job (and the macOS/Windows legs of the keyring, npm-global, setup-action
# and remote-helper matrices) is skipped on `pull_request` and runs after
# merge instead, via workflow_dispatch, the main/preview `push:` below and
# the nightly schedule.
#
# `push:` is pinned to the release lines. dev is deliberately absent:
# cross-platform evidence for dev is run by hand via workflow_dispatch.
# main and preview MUST stay: release.yml requires a successful push-event
# Cross-platform CI run for the exact release SHA and states that a
# pull-request run does not qualify, so removing either branch breaks
# publication.
push:
branches: [main, preview]
paths:
- "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"
workflow_dispatch:
inputs:
lane:
description: "all (default), release-gates, or macos-control"
type: choice
default: all
options: [all, release-gates, macos-control]
# Nightly safety net. The Windows shards run on a pull request only when the
# changes job judges it Windows-sensitive, so anything that slips past that
# filter must still be caught within a day: a scheduled run requests the full
# lane=all matrix (nine Windows shards and the macOS control included).
#
# GitHub runs schedules from the DEFAULT branch, which is main, so this
# trigger activates only once this file reaches main by promotion, and the
# workflow definition is main's. Every test checkout reads
# needs.changes.outputs.checkout_ref, which the changes job resolves to ONE
# dev commit on a schedule, so the run tests dev and every job tests the same
# SHA. Its check runs attach to main's head commit; release.yml accepts only a
# push-event run, so a scheduled run can never qualify a release.
schedule:
- cron: "17 18 * * *"
permissions:
contents: read
# Retrigger CI after dir-fsync / oauth deadline follow-ups (tip 34a1ac46).
concurrency:
# `push` and `pull_request` 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.
#
# A scheduled run is keyed the same way. Keyed on the ref it would share
# refs/heads/main with a promotion push and, with cancel-in-progress, cancel
# the very run release.yml waits for.
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.
#
# `push` on main/preview requires the push permission, and
# `workflow_dispatch` requires write access, so both carry a trusted author.
# A schedule runs main's workflow against a dev commit that already merged
# through review, the same trust as a push.
# A trusted author is not audited code: merging a contributor PR into `dev`
# fires `push`, and its dependencies and postinstall hooks then run here.
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:
- 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 this push 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
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 }}
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 scheduled run starts from main, so its path filter diffs main and would
# scope jobs by the wrong commit. The nightly safety net selects every scope
# instead, here and in the validation steps below, so it is the full matrix.
gui: ${{ github.event_name == 'schedule' && 'true' || steps.filter.outputs.gui }}
packaging: ${{ github.event_name == 'schedule' && 'true' || steps.filter.outputs.packaging }}
docs: ${{ github.event_name == 'schedule' && 'true' || steps.filter.outputs.docs }}
structure: ${{ github.event_name == 'schedule' && '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 }}
# Whether this pull request needs the nine 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: 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 `main`. A push to `dev` would then be diffed against
# `main`, so every area touched since the last promotion keeps reading
# as "changed" — the scoped jobs would run on nearly every dev push 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. On a branch push it means "compare against the previous commit
# on this branch", which is the intent.
base: ${{ github.ref }}
filters: |
# Mirrors the push trigger's path allowlist. 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; they are still covered on every promotion push to main and
# preview and by workflow_dispatch, which always request this job.
# 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` triggers
# only on `push` to `main`. 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 promotion.
#
# `.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 stays PULL-REQUEST scope only, like `docs` above: the
# push trigger's `paths:` is pinned to mirror `ci` exactly, and
# `dev`, `main` and `preview` are all protected to require a pull
# request, so every `structure/` change is read at the pull request
# before it can reach an integration line.
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/**'
# Paths whose change selects the nine 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' && 'true' || steps.filter.outputs.ci }}
DESKTOP_SCOPE: ${{ github.event_name == 'schedule' && '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' && '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' && 'true' || steps.filter.outputs.setup_action }}
REMOTE_HELPER: ${{ github.event_name == 'schedule' && 'true' || steps.filter.outputs.remote_helper }}
run: |
set -euo pipefail
for pair in "setup_action=$SETUP_ACTION" "remote_helper=$REMOTE_HELPER"; 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: 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 main's head. 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 roles (#6713): runtime 1.4.2 fixes #6684's Windows Bun.fetch streaming;
# the test runner skipped 1.4.2's multi-file --isolate preload segfault (#4821
# reverted #4064; run 37631558263: Linux 1/4, macOS 2/2, Windows 9/9) and runs
# 1.4.3, whose oven-sh/bun#44581 stops Bun.spawnSync losing a child's exit (#4956).
# Rejoin after the upstream runner crash is fixed and a green lane=all dispatch
# proves the unified version, then delete testRunnerBun and the action's role input.
# The suite, split by file across four 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 four times — they are fixed cost, and paying it per shard
# would eat what the sharding saves.
test:
name: test ${{ matrix.shard }}/4
needs: changes
if: github.event_name != 'pull_request' || needs.changes.outputs.ci == 'true'
runs-on: ubuntu-latest
# A quarter 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]
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: |
bun install --frozen-lockfile
cd gui
bun install --frozen-lockfile
# 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 }}/4
run: bash scripts/ci/run-bun-test-batches.sh "$TEST_SHARD"
# 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: |
bun install --frozen-lockfile
cd gui
bun install --frozen-lockfile
- 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: |
bun install --frozen-lockfile
cd gui
bun install --frozen-lockfile
- 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: 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 }}
- 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
- 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: 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 }}/3
needs: changes
# Never on pull requests: macOS legs run after merge, on push to
# main/preview, and on dispatch and the schedule.
if: github.event_name != 'pull_request'
runs-on: macos-latest
# Three shards. Unsharded, this job was the critical path on every green dev
# push (mean 14.9 min against a 4.7 min Linux maximum; devlog
# 260905_test_modularization_and_windows/003), so it was split in two. The
# suite then outgrew two halves: across seventeen dev dispatches from
# 2026-10-04 to 10-12 the slower half's test step went from 867s to 1155s,
# and run 38214884055 cancelled macos 2/2 at this cap with 68 files left
# while every test it had run was passing (#6978). Replaying the duration
# assignment against those runs' measured per-file times puts the slowest of
# three shards at 635-796s of tests, about 14 minutes with setup. 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. The full-membership
# control runs the same bounded batches without sharding on explicit dispatch.
timeout-minutes: 20
strategy:
fail-fast: false
matrix:
shard: [1, 2, 3]
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 }}/3
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 lanes stay off the ordinary release gates: list every lane
# that should run this job, so a new lane defaults to skipping the diagnostic.
# The nightly schedule is the full lane=all matrix, so it runs this job too.
if: >-
github.event_name == 'schedule' || github.event_name == 'workflow_dispatch' && (github.event.inputs.lane == '' || github.event.inputs.lane == 'all' || 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:
TEST_SHARD: 1/1
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
# Windows runs on a Windows-sensitive pull request, on the nightly schedule,
# and on a lane=all (or default) dispatch. It is never part of the push run
# release.yml gates on.
#
# It left the PR lane first (16m23s against a 6-minute Linux critical path;
# the ceiling was raised twice rather than the gap closed — #711 vs #653,
# issue #717, then #827's 20-minute kill), then left the shipping boundary
# when the sharded promotion run surfaced ~207 Windows-only test failures
# that had been invisible while dev skipped the leg. Those are real defects,
# tracked as issue #1059, but they are pre-existing on every released
# version — gating the release on them blocks shipping fixes to the platforms
# that pass, for a platform that has never shipped green.
#
# The leg stays in the workflow, sharded and dispatchable, so the failure
# list can be burned down without losing the ability to measure progress.
# release.yml gates on a successful push-event run of this workflow, which
# now means Linux + macOS + the gates; Windows re-enters the gate when the
# tracked failures are fixed, not before.
#
# Dispatch-only proved too late. #6639, #6556, #6605 and #6606 each landed with