-
Notifications
You must be signed in to change notification settings - Fork 1
1470 lines (1312 loc) · 62.5 KB
/
Copy pathci.yml
File metadata and controls
1470 lines (1312 loc) · 62.5 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
name: CI
on:
push:
branches:
- main
pull_request:
paths:
- "Sources/**"
- "CLI/**"
- "CLI-MCP/**"
- "programaTests/**"
- "tests/**"
- "tests_v2/**"
- "Resources/**"
- "Assets.xcassets/**"
- "vendor/**"
- "windows/**"
- "core/**"
- "scripts/**"
- ".github/workflows/**"
- "GhosttyTabs.xcodeproj/**"
- "programa.entitlements"
- "programa-Bridging-Header.h"
- "ghostty.h"
- "session_escrow_shim.c"
- "session_escrow_shim.h"
# The bare "ghostty" entry catches submodule pointer bumps, which
# "ghostty/**" alone misses.
- "ghostty"
- "ghostty/**"
- ".gitmodules"
# On-demand runs, so the typing-lag regression can be measured on a branch
# BEFORE it merges. Without this the lag job only ever ran post-merge on main,
# which made "measure p95 before and after" impossible to do pre-merge and left
# perf changes to the keystroke path effectively unverifiable until too late.
workflow_dispatch:
inputs:
notification_ui:
description: Run the focused multi-window notification UI regression on macOS 26.
type: boolean
default: false
windows_only:
description: Run shared-core and Windows checks without the macOS test jobs
type: boolean
default: false
lag_combo:
description: >-
Key the typing-lag harness repeats. "up" (the default, and what
scheduled runs use) exercises the per-event hit-test path. A printable
key such as "a" additionally reaches shouldRefreshAfterTextInput and
therefore forceRefresh, which the arrow key never does -- the only way
to measure the text-input half of the keystroke path.
type: string
default: up
glass_surface:
description: Liquid Glass surface measured as three OFF and three ON lag-harness runs.
type: choice
options:
- window
- sidebar
- tabBar
- browserToolbar
- overlays
default: window
concurrency:
group: ${{ github.workflow }}-${{ github.ref }}
cancel-in-progress: true
permissions:
contents: read
jobs:
change-detection:
runs-on: ubuntu-latest
outputs:
run_app_jobs: ${{ steps.detect.outputs.run_app_jobs }}
run_windows_jobs: ${{ steps.detect.outputs.run_windows_jobs }}
steps:
- name: Checkout
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
with:
fetch-depth: 0
- name: Validate immutable workflow action pins
run: ./scripts/validate-workflow-action-pins.py
- name: Enforce structural lifecycle budgets
run: ./scripts/check-structural-budgets.py
- name: Validate deterministic app discovery
run: ./tests/test_locate_built_app.sh
- name: Detect changed files
id: detect
env:
WINDOWS_ONLY: ${{ github.event_name == 'workflow_dispatch' && inputs.windows_only }}
run: |
set -euo pipefail
if [[ "$WINDOWS_ONLY" == "true" ]]; then
echo "run_app_jobs=false" >> "$GITHUB_OUTPUT"
echo "run_windows_jobs=true" >> "$GITHUB_OUTPUT"
echo "Manual Windows verification: macOS jobs excluded." >> "$GITHUB_STEP_SUMMARY"
exit 0
fi
# Keep full CI for push events and non-PR runs.
if [[ "${{ github.event_name }}" != "pull_request" ]]; then
echo "run_app_jobs=true" >> "$GITHUB_OUTPUT"
echo "run_windows_jobs=true" >> "$GITHUB_OUTPUT"
echo "Changed files: full suite (non-PR context)" >> "$GITHUB_STEP_SUMMARY"
exit 0
fi
BASE_SHA="${{ github.event.pull_request.base.sha }}"
HEAD_SHA="${{ github.event.pull_request.head.sha }}"
git fetch --no-tags origin "${BASE_SHA}" "${HEAD_SHA}"
CHANGED_FILES="$(git diff --name-only "${BASE_SHA}...${HEAD_SHA}")"
CLASSIFICATION="$(printf '%s' "$CHANGED_FILES" | ./scripts/classify_ci_changes.sh)"
APP_OUTPUT="${CLASSIFICATION%%$'\n'*}"
if [[ "$APP_OUTPUT" != "$CLASSIFICATION" ]]; then
echo "CI change classifier returned an invalid output shape" >&2
exit 1
fi
case "$APP_OUTPUT" in
run_app_jobs=true) RUN_APP_JOBS=true ;;
run_app_jobs=false) RUN_APP_JOBS=false ;;
*)
echo "CI change classifier returned an invalid app result" >&2
exit 1
;;
esac
printf '%s\n' "$CLASSIFICATION" >> "$GITHUB_OUTPUT"
# The Windows build reads only windows/, core/ and its build script, so
# a PR that touches none of them (or this workflow) skips it. Pushes to
# main always build it.
RUN_WINDOWS_JOBS=false
if grep -qE '^(windows/|core/|scripts/build-windows\.ps1$|\.github/workflows/ci\.yml$)' <<< "$CHANGED_FILES"; then
RUN_WINDOWS_JOBS=true
fi
echo "run_windows_jobs=${RUN_WINDOWS_JOBS}" >> "$GITHUB_OUTPUT"
{
echo "### CI scope decision"
if [[ "$RUN_APP_JOBS" == "true" ]]; then
echo "Changed file set contains app-relevant changes; running full macOS jobs."
else
echo "Pull request appears docs/workflow/localization-only; skipping heavy app jobs."
fi
echo ""
echo "Changed files:"
if [[ -z "${CHANGED_FILES}" ]]; then
echo "- <none>"
else
printf '%s\n' "${CHANGED_FILES}"
fi
} >> "$GITHUB_STEP_SUMMARY"
workflow-guard-tests:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
- name: Validate GhosttyKit lock ownership
run: ./tests/test_ensure_ghosttykit_locking.sh
- name: Validate create-dmg version pinning
run: ./tests/test_ci_create_dmg_pinned.sh
- name: Validate unit-test runner behavior
run: ./tests/test_ci_unit_test_runner_behavior.sh
- name: Validate GhosttyKit checksum verification
run: ./tests/test_ci_ghosttykit_checksum_verification.sh
- name: Validate release artifact architecture checks
run: ./tests/test_ci_universal_release_settings.sh
- name: Validate rolling release publication
run: ./tests/test_rolling_release_publication.sh
- name: Validate rolling release state transitions
run: node --test scripts/rolling_release_state.test.js
- name: Validate release build identity
run: node --test scripts/release_build_identity.test.js
- name: Validate Sparkle enclosure naming and pruning
run: node --test scripts/sparkle_enclosure.test.js
- name: Validate v2 socket API contract has no drift
run: ./scripts/check-v2-contract.sh
- name: Validate settings and shortcut docs match the code
run: python3 scripts/check-settings-docs.py
shared-core:
runs-on: ubuntu-latest
permissions:
contents: read
steps:
- name: Checkout
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
- name: Set up Rust
uses: dtolnay/rust-toolchain@6bed0761d98439e5a578e2877258200ad565ba87 # stable
- name: Validate shared core
run: |
cargo fmt --manifest-path core/Cargo.toml --all -- --check
# Runs the whole core/ workspace, including programad's unit and
# integration tests (Unix socket + PTY, both available on
# ubuntu-latest) now that it lives at core/crates/programad.
cargo test --manifest-path core/Cargo.toml --workspace --locked
# max_sendmsg_descriptors_close_without_leak and
# too_many_descriptors_are_closed_before_the_reject_returns are
# both #[ignore]d in the run above (see their doc comments in
# fdpass.rs): the first's EPIPE assertion, and the precision of
# the second's fd-count assertion, both want nothing else in the
# process able to fork() while their fixture pipe is alive, which
# the default parallel run can't guarantee against the
# Linux-only session::tests that spawn real PTYs. --test-threads=1
# with no other ignored tests in this binary runs both completely
# alone.
cargo test --manifest-path core/Cargo.toml -p programad --locked --lib -- --ignored --test-threads=1
cargo test --manifest-path core/crates/programa-terminal/Cargo.toml --locked
cargo test --manifest-path core/vendor/alacritty_terminal/Cargo.toml --locked --lib parses_buffered_bytes_before_returning_a_terminal_read_error
- name: Smoke test programad
run: |
set -euo pipefail
cargo build --manifest-path core/Cargo.toml -p programad --locked
socket_dir="$(mktemp -d)"
export XDG_RUNTIME_DIR="$socket_dir"
export XDG_STATE_HOME="$socket_dir/state"
socket_path="$socket_dir/programad.sock"
./core/target/debug/programad --socket "$socket_path" &
daemon_pid=$!
trap 'kill "$daemon_pid" 2>/dev/null || true' EXIT
for _ in $(seq 1 50); do
[ -S "$socket_path" ] && break
sleep 0.1
done
python3 core/crates/programad/tests/smoke.py --socket "$socket_path"
windows-build:
needs: change-detection
if: needs.change-detection.outputs.run_windows_jobs == 'true'
runs-on: windows-latest
timeout-minutes: 30
permissions:
contents: read
steps:
- name: Checkout
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
- name: Set up .NET
uses: actions/setup-dotnet@26b0ec14cb23fa6904739307f278c14f94c95bf1 # v5
with:
dotnet-version: '10.0.x'
- name: Set up Rust
uses: dtolnay/rust-toolchain@6bed0761d98439e5a578e2877258200ad565ba87 # stable
with:
targets: x86_64-pc-windows-msvc
- name: Validate and build Windows executable
shell: pwsh
env:
PROGRAMA_CI_BUILD: ${{ github.run_id }}
PROGRAMA_CI_COMMIT: ${{ github.sha }}
run: |
./scripts/build-windows.ps1 -Version '0.0.0' -Build $env:PROGRAMA_CI_BUILD -Commit $env:PROGRAMA_CI_COMMIT -OutputDirectory "$env:RUNNER_TEMP/programa-windows-ci"
- name: Run WinUI launch smoke test
timeout-minutes: 3
shell: pwsh
run: |
$ErrorActionPreference = 'Stop'
$exe = "$env:RUNNER_TEMP/programa-windows-ci/programa-windows.exe"
$logPath = "$env:LOCALAPPDATA\Programa\launch.log"
if (Test-Path -LiteralPath $logPath) { Remove-Item -LiteralPath $logPath -Force }
# Runs the full WinUI startup path -- Application.Start, MainWindow created and
# activated, one terminal spawned -- unlike --version/--verify-native-libraries,
# which both return before Application.Start is ever called. windows-latest
# runners have an interactive-capable session for UI; if WinUI still refuses to
# show a window here, this still exercises Application.Start and the exception
# handlers added for exactly that case report the real error below instead of
# the process just disappearing.
#
# programa.exe --smoke has its own internal watchdog (25s) that force-exits the
# process even if Application.Start itself never returns. This step-level
# timeout-minutes plus the explicit kill below is defense in depth on top of
# that, not a substitute for it -- a first attempt at this smoke test hung for
# the full 30-minute job timeout because nothing forced the process to exit.
$proc = Start-Process -FilePath $exe -ArgumentList '--smoke' -PassThru -NoNewWindow
$finished = $proc.WaitForExit(60000)
if (-not $finished) {
Write-Output 'Smoke test process did not exit within 60s; killing it.'
try { $proc.Kill($true) } catch { Write-Output "Kill failed: $_" }
$exitCode = -1
} else {
$exitCode = $proc.ExitCode
}
$logContent = if (Test-Path -LiteralPath $logPath) { Get-Content -LiteralPath $logPath -Raw } else { '' }
$ok = ($exitCode -eq 0) -and ($logContent -match 'launch ok: window shown')
if (-not $ok) {
Write-Output "Smoke test FAILED. Exit code: $exitCode"
if ($logContent) {
Write-Output '--- launch.log ---'
Write-Output $logContent
} else {
Write-Output "No launch.log was written at $logPath."
}
throw "WinUI launch smoke test failed (exit code $exitCode, log at $logPath)."
}
Write-Output "Smoke test passed. Exit code: $exitCode"
Write-Output '--- launch.log ---'
Write-Output $logContent
- name: Upload Windows executable
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
with:
name: programa-windows-ci
path: ${{ runner.temp }}/programa-windows-ci/*.exe
if-no-files-found: error
# Build the Debug app + UI test bundle once and share it with every job that
# only needs to *run* it (socket-integration-tests, tests-build-and-lag,
# ui-regressions). Those three jobs used to each pay their own ~7 min
# "Build app" step for an identical build; this collapses that to one.
# unit-tests keeps building its own artifacts: it uses the programa-unit
# scheme/test host, a different target from the programa app scheme built
# here, so its output isn't the same product.
build-app:
needs: change-detection
if: needs.change-detection.outputs.run_app_jobs == 'true'
runs-on: macos-26
timeout-minutes: 30
env:
PROGRAMA_DERIVED_DATA_DIR: ${{ github.workspace }}/.ci-derived-data-app
steps:
- name: Checkout
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
with:
submodules: recursive
- name: Select Xcode
run: |
set -euo pipefail
XCODE_APP="$(ls -d /Applications/Xcode_26*.app 2>/dev/null | sort -V | tail -n 1 || true)"
if [ -z "$XCODE_APP" ] && [ -d "/Applications/Xcode.app" ]; then
XCODE_APP="/Applications/Xcode.app"
fi
if [ -z "$XCODE_APP" ]; then
XCODE_APP="$(ls -d /Applications/Xcode*.app 2>/dev/null | sort | tail -n 1 || true)"
fi
if [ -z "$XCODE_APP" ]; then
echo "No Xcode.app found under /Applications" >&2
exit 1
fi
XCODE_DIR="$XCODE_APP/Contents/Developer"
echo "DEVELOPER_DIR=$XCODE_DIR" >> "$GITHUB_ENV"
export DEVELOPER_DIR="$XCODE_DIR"
sudo xcode-select -s "$XCODE_DIR" || true
xcodebuild -version
- name: Resolve Ghostty revision
id: ghostty-revision
run: |
set -euo pipefail
revision="$(./scripts/ghostty_cache_revision.sh)"
printf 'revision=%s\n' "$revision" >> "$GITHUB_OUTPUT"
- name: Cache GhosttyKit.xcframework
id: cache-ghosttykit-app
uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4
with:
path: GhosttyKit.xcframework
key: ghosttykit-v3-${{ steps.ghostty-revision.outputs.revision }}
- name: Download pre-built GhosttyKit.xcframework
if: steps.cache-ghosttykit-app.outputs.cache-hit != 'true'
run: |
./scripts/download-prebuilt-ghosttykit.sh
- name: Resolve zig version
id: zig-version
run: printf 'version=%s\n' "$(./scripts/required-zig-version.sh)" >> "$GITHUB_OUTPUT"
# install-zig.sh re-checks the tarball against scripts/zig-macos-aarch64.sha256
# on every run, so a cache hit never skips the checksum.
- name: Cache zig toolchain tarball
uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4
with:
path: ~/.cache/programa-zig-dist
key: zig-dist-macos-arm64-${{ steps.zig-version.outputs.version }}
- name: Install zig
run: ./scripts/install-zig.sh
- name: Cache Zig packages
uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4
with:
path: ~/.cache/zig
key: zig-packages-${{ hashFiles('ghostty/build.zig.zon', 'ghostty/build.zig.zon.json') }}
restore-keys: zig-packages-
# The "Copy Ghostty Resources" build phase compiles the Ghostty CLI helper
# (Resources/bin/ghostty) with zig. zig's local cache turns that into a
# no-op while the ghostty revision and zig version stay the same. No
# restore-keys: an exact key keeps the cache from accumulating old builds.
- name: Cache Ghostty CLI helper build
uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4
with:
path: ghostty/.zig-cache
key: ghostty-cli-helper-${{ steps.ghostty-revision.outputs.revision }}-zig${{ steps.zig-version.outputs.version }}
- name: Cache DerivedData
uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4
with:
path: ${{ env.PROGRAMA_DERIVED_DATA_DIR }}
key: deriveddata-build-app-macos26-${{ hashFiles('GhosttyTabs.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved') }}-${{ hashFiles('GhosttyTabs.xcodeproj/project.pbxproj') }}
restore-keys: |
deriveddata-build-app-macos26-${{ hashFiles('GhosttyTabs.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved') }}-
deriveddata-build-app-macos26-
- name: Cache Swift packages
uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4
with:
path: .ci-source-packages
key: spm-build-app-${{ hashFiles('GhosttyTabs.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved') }}
restore-keys: spm-build-app-
- name: Resolve Swift packages
run: |
set -euo pipefail
SOURCE_PACKAGES_DIR="$PWD/.ci-source-packages"
mkdir -p "$SOURCE_PACKAGES_DIR"
for attempt in 1 2 3; do
if xcodebuild -project GhosttyTabs.xcodeproj -scheme programa -configuration Debug \
-clonedSourcePackagesDirPath "$SOURCE_PACKAGES_DIR" \
-resolvePackageDependencies; then
exit 0
fi
if [ "$attempt" -eq 3 ]; then
echo "Failed to resolve Swift packages after 3 attempts" >&2
exit 1
fi
echo "Package resolution failed on attempt $attempt, retrying..."
sleep $((attempt * 5))
done
# build-for-testing (not plain build) so the same artifact also covers
# ui-regressions, which needs the programaUITests bundle + .xctestrun,
# not just the app binary.
- name: Build app and UI test bundle
run: |
set -euo pipefail
SOURCE_PACKAGES_DIR="$PWD/.ci-source-packages"
xcodebuild -project GhosttyTabs.xcodeproj -scheme programa -configuration Debug \
-clonedSourcePackagesDirPath "$SOURCE_PACKAGES_DIR" \
-disableAutomaticPackageResolution \
-derivedDataPath "$PROGRAMA_DERIVED_DATA_DIR" \
-destination "platform=macOS" \
build-for-testing
- name: Package build artifact
run: |
set -euo pipefail
tar -czf app-build.tar.gz -C "$PROGRAMA_DERIVED_DATA_DIR" Build/Products
- name: Upload build artifact
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
with:
name: programa-app-build
path: app-build.tar.gz
if-no-files-found: error
retention-days: 1
# Sharded by test class (see scripts/list-programa-unit-test-classes.sh),
# weight-balanced halves (scripts/unit-test-shard-weights.txt), so the ~11 min "Run unit tests" step runs as two
# parallel matrix jobs instead of serially. The stateful class
# (AppDelegateShortcutRoutingTests) always runs unsharded in shard 1 --
# splitting it would risk cross-shard focus/window-state interference.
# `unit-tests` below is the aggregate gate; downstream jobs still depend on
# that name, not on this one.
unit-tests-shard:
needs: change-detection
if: needs.change-detection.outputs.run_app_jobs == 'true'
strategy:
fail-fast: false
matrix:
shard: [1, 2]
runs-on: macos-26
timeout-minutes: 45
env:
PROGRAMA_DERIVED_DATA_DIR: ${{ github.workspace }}/.ci-derived-data-unit-${{ matrix.shard }}
PROGRAMA_UNIT_TEST_SHARD: ${{ matrix.shard }}
PROGRAMA_UNIT_TEST_SHARD_COUNT: 2
# No unit test runs the Ghostty CLI helper (Resources/bin/ghostty), so the
# shards take the build script's stub instead of compiling it with zig.
# build-app still builds the real helper; its artifact feeds the jobs that
# do run it (theme-picker-helper-regression, socket and UI tests).
PROGRAMA_SKIP_ZIG_BUILD: "1"
steps:
- name: Checkout
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
with:
submodules: recursive
- name: Select Xcode
run: |
set -euo pipefail
# Prefer Xcode 26 (macOS 26 SDK) so NSGlassEffectView / Liquid Glass compiles;
# fall back to the image default when no Xcode 26 install exists.
XCODE_APP="$(ls -d /Applications/Xcode_26*.app 2>/dev/null | sort -V | tail -n 1 || true)"
if [ -z "$XCODE_APP" ] && [ -d "/Applications/Xcode.app" ]; then
XCODE_APP="/Applications/Xcode.app"
fi
if [ -z "$XCODE_APP" ]; then
XCODE_APP="$(ls -d /Applications/Xcode*.app 2>/dev/null | sort | tail -n 1 || true)"
fi
if [ -z "$XCODE_APP" ]; then
echo "No Xcode.app found under /Applications" >&2
exit 1
fi
XCODE_DIR="$XCODE_APP/Contents/Developer"
echo "DEVELOPER_DIR=$XCODE_DIR" >> "$GITHUB_ENV"
export DEVELOPER_DIR="$XCODE_DIR"
sudo xcode-select -s "$XCODE_DIR" || true
xcodebuild -version
- name: Run Bonsplit package tests
if: matrix.shard == 2
run: swift test --package-path vendor/bonsplit
- name: Validate Release reload artifact discovery
run: ./tests/test_reloadp_programa_artifact.sh
- name: Validate Ghostty cache revision
run: ./tests/test_ghostty_cache_revision.sh
- name: Validate CI change classification
run: ./tests/test_ci_change_classification.sh
- name: Validate reload entrypoint artifacts and dependency preparation
run: ./tests/test_reload_entrypoints_artifacts.sh
- name: Resolve Ghostty revision
id: ghostty-revision
run: |
set -euo pipefail
revision="$(./scripts/ghostty_cache_revision.sh)"
printf 'revision=%s\n' "$revision" >> "$GITHUB_OUTPUT"
- name: Cache GhosttyKit.xcframework
id: cache-ghosttykit
uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4
with:
path: GhosttyKit.xcframework
key: ghosttykit-v3-${{ steps.ghostty-revision.outputs.revision }}
- name: Download pre-built GhosttyKit.xcframework
if: steps.cache-ghosttykit.outputs.cache-hit != 'true'
run: |
./scripts/download-prebuilt-ghosttykit.sh
- name: Cache DerivedData
uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4
with:
path: ${{ env.PROGRAMA_DERIVED_DATA_DIR }}
key: deriveddata-tests-macos26-shard${{ matrix.shard }}-${{ hashFiles('GhosttyTabs.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved') }}-${{ hashFiles('GhosttyTabs.xcodeproj/project.pbxproj') }}
restore-keys: |
deriveddata-tests-macos26-shard${{ matrix.shard }}-${{ hashFiles('GhosttyTabs.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved') }}-
deriveddata-tests-macos26-shard${{ matrix.shard }}-
- name: Cache Swift packages
uses: actions/cache@5a3ec84eff668545956fd18022155c47e93e2684 # v4
with:
path: .ci-source-packages
key: spm-shard${{ matrix.shard }}-${{ hashFiles('GhosttyTabs.xcodeproj/project.xcworkspace/xcshareddata/swiftpm/Package.resolved') }}
restore-keys: spm-shard${{ matrix.shard }}-
- name: Resolve Swift packages
run: |
set -euo pipefail
SOURCE_PACKAGES_DIR="$PWD/.ci-source-packages"
mkdir -p "$SOURCE_PACKAGES_DIR"
for attempt in 1 2 3; do
if xcodebuild -project GhosttyTabs.xcodeproj -scheme programa-unit -configuration Debug \
-clonedSourcePackagesDirPath "$SOURCE_PACKAGES_DIR" \
-resolvePackageDependencies; then
exit 0
fi
if [ "$attempt" -eq 3 ]; then
echo "Failed to resolve Swift packages after 3 attempts" >&2
exit 1
fi
echo "Package resolution failed on attempt $attempt, retrying..."
sleep $((attempt * 5))
done
# Build and exercise the standalone CLI before the long XCTest bundle. This
# keeps parser/security regressions observable even when an unrelated UI
# unit test flakes later in the job.
- name: Build programa CLI regression target
id: cli-build
run: |
CLI_REGRESSION_DIR="$RUNNER_TEMP/programa-cli-regression"
rm -rf "$CLI_REGRESSION_DIR"
xcodebuild -project GhosttyTabs.xcodeproj \
-target programa-cli \
-configuration Debug \
SYMROOT="$CLI_REGRESSION_DIR" \
CODE_SIGNING_ALLOWED=NO \
build
- name: Install Fish for shell integration regressions
run: brew install fish
- name: Run typed CLI registry behavior regression
if: ${{ !cancelled() && steps.cli-build.outcome == 'success' }}
run: |
set -euo pipefail
CLI_BIN="$RUNNER_TEMP/programa-cli-regression/Debug/programa"
if [ -z "${CLI_BIN:-}" ] || [ ! -x "$CLI_BIN" ]; then
echo "programa CLI binary not found in DerivedData" >&2
exit 1
fi
PROGRAMA_CLI_BIN="$CLI_BIN" python3 tests/test_cli_registry_behavior.py
- name: Run CLI argument grammar regression
if: ${{ !cancelled() && steps.cli-build.outcome == 'success' }}
run: |
set -euo pipefail
CLI_BIN="$RUNNER_TEMP/programa-cli-regression/Debug/programa"
if [ -z "${CLI_BIN:-}" ] || [ ! -x "$CLI_BIN" ]; then
echo "programa CLI binary not found in DerivedData" >&2
exit 1
fi
PROGRAMA_CLI_BIN="$CLI_BIN" python3 tests/test_cli_argument_grammar.py
- name: Run Codex hook trust regression
if: ${{ !cancelled() && steps.cli-build.outcome == 'success' }}
run: |
set -euo pipefail
CLI_BIN="$RUNNER_TEMP/programa-cli-regression/Debug/programa"
if [ -z "${CLI_BIN:-}" ] || [ ! -x "$CLI_BIN" ]; then
echo "programa CLI binary not found in DerivedData" >&2
exit 1
fi
PROGRAMA_CLI_BIN="$CLI_BIN" python3 tests/test_cli_codex_hook_trust.py
- name: Run CLI sweep regressions
if: ${{ !cancelled() && steps.cli-build.outcome == 'success' }}
run: |
set -euo pipefail
CLI_BIN="$RUNNER_TEMP/programa-cli-regression/Debug/programa"
test -x "$CLI_BIN"
result=0
for t in \
tests/test_cli_noninteractive_install_regression.py \
tests/test_cli_socket_no_autodiscovery_regression.py \
tests/test_cli_wait_surface_agent_state.py \
tests/test_cli_claude_settings_preservation.py \
tests/test_shell_state_report_ordering.py; do
PROGRAMA_CLI_BIN="$CLI_BIN" python3 "$t" || result=1
done
exit "$result"
- name: Run hook confirmation EOF regressions
if: ${{ !cancelled() && steps.cli-build.outcome == 'success' }}
run: |
set -euo pipefail
CLI_BIN="$RUNNER_TEMP/programa-cli-regression/Debug/programa"
test -x "$CLI_BIN"
result=0
for provider in codex claude opencode; do
PROGRAMA_CLI="$CLI_BIN" python3 "tests_v2/test_${provider}_install_integration.py" --eof-only || result=1
done
exit "$result"
- name: Run unit tests
if: ${{ !cancelled() && steps.cli-build.outcome == 'success' }}
env:
PROGRAMA_UNIT_TEST_SCOPE: split-stateful
run: ./scripts/ci-run-unit-tests.sh
- name: Collect ghostty crash reports on failure
if: failure()
run: |
mkdir -p /tmp/programa-unit-xcresults
cp -R "$HOME/.local/state/ghostty/crash" /tmp/programa-unit-xcresults/ghostty-crash 2>/dev/null || true
- name: Collect debug symbols for crash symbolication
if: failure()
# The crash reports above are sentry-native minidumps, which are useless
# without the exact binary that produced them: a CI-only Debug build that
# exists nowhere else. Two separate investigations of the same crash-loop
# burned hours doing unsymbolicated image-offset matching because this
# step did not exist. Copy the built products (Debug carries DWARF inside
# the binaries) plus any dSYMs, so `lldb -o "target create --core <dmp>"`
# can resolve frames to function names.
run: |
set -uo pipefail
DERIVED="${PROGRAMA_DERIVED_DATA_DIR:-$HOME/Library/Developer/Xcode/DerivedData}"
OUT=/tmp/programa-unit-xcresults/symbols
mkdir -p "$OUT"
find "$DERIVED" -maxdepth 5 -type d \( -name '*.app' -o -name '*.dSYM' \) -print0 2>/dev/null \
| xargs -0 -I{} cp -R {} "$OUT/" 2>/dev/null || true
# UUID index so a dump's debug_id can be matched to a file without
# unpacking every bundle.
find "$OUT" -type f -perm +111 -print0 2>/dev/null \
| xargs -0 dwarfdump --uuid 2>/dev/null > "$OUT/uuids.txt" || true
du -sh "$OUT" || true
- name: Upload unit-test result bundles on failure
if: failure()
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4
with:
name: unit-test-xcresults-shard${{ matrix.shard }}-${{ github.run_attempt }}
path: /tmp/programa-unit-xcresults/
if-no-files-found: ignore
retention-days: 7
- name: Run CLI version memory guard regression
run: |
set -euo pipefail
CLI_BIN="$RUNNER_TEMP/programa-cli-regression/Debug/programa"
if [ -z "${CLI_BIN:-}" ] || [ ! -x "$CLI_BIN" ]; then
echo "programa CLI binary not found at the job's exact build path" >&2
exit 1
fi
PROGRAMA_CLI_BIN="$CLI_BIN" python3 tests/test_cli_version_memory_guard.py
# Aggregate gate: downstream jobs and branch protection depend on the name
# "unit-tests", not on the matrix job above, so sharding stays invisible to
# everything that isn't ci.yml itself.
# Shards skipped by change-detection (docs, other workflows) count as a pass;
# a failed or cancelled shard, or a failed change-detection, does not.
unit-tests:
needs:
- change-detection
- unit-tests-shard
if: always()
runs-on: ubuntu-latest
steps:
- name: Check shard results
env:
DETECTION_RESULT: ${{ needs.change-detection.result }}
RUN_APP_JOBS: ${{ needs.change-detection.outputs.run_app_jobs }}
SHARD_RESULT: ${{ needs.unit-tests-shard.result }}
run: |
if [[ "$SHARD_RESULT" == "success" ]]; then
exit 0
fi
if [[ "$SHARD_RESULT" == "skipped" && "$DETECTION_RESULT" == "success" && "$RUN_APP_JOBS" != "true" ]]; then
echo "unit-tests-shard skipped: no app-relevant changes"
exit 0
fi
echo "unit-tests-shard: $SHARD_RESULT (change-detection: $DETECTION_RESULT, run_app_jobs: $RUN_APP_JOBS)" >&2
exit 1
# Independent of unit-tests: same "programa" scheme app build-app already
# produces, so this reuses that artifact instead of paying for its own
# ~3 min build. Split out so it no longer serializes behind the unit-test
# shards either.
theme-picker-helper-regression:
needs:
- build-app
- change-detection
if: needs.change-detection.outputs.run_app_jobs == 'true'
runs-on: macos-26
timeout-minutes: 15
env:
PROGRAMA_DERIVED_DATA_DIR: ${{ github.workspace }}/.ci-derived-data-theme-picker
steps:
- name: Checkout
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
- name: Download build artifact
uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0 # v5
with:
name: programa-app-build
path: .
- name: Extract build artifact
run: |
set -euo pipefail
mkdir -p "$PROGRAMA_DERIVED_DATA_DIR"
tar -xzf app-build.tar.gz -C "$PROGRAMA_DERIVED_DATA_DIR"
- name: Run bundled Ghostty theme picker helper regression
run: |
set -euo pipefail
PROGRAMA_PREBUILT_APP_PATH="$PROGRAMA_DERIVED_DATA_DIR/Build/Products/Debug/Programa DEV.app" \
./tests/test_bundled_ghostty_theme_picker_helper.sh
socket-integration-tests:
needs:
- build-app
- change-detection
if: needs.change-detection.outputs.run_app_jobs == 'true'
# Matches build-app's runner OS: the artifact is a Debug binary built
# against the macOS 26 SDK (Liquid Glass), so it must run on the same
# OS version it was built for.
runs-on: macos-26
timeout-minutes: 40
env:
PROGRAMA_DERIVED_DATA_DIR: ${{ github.workspace }}/.ci-derived-data-socket-integration
steps:
- name: Checkout
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
with:
submodules: recursive
- name: Download build artifact
uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0 # v5
with:
name: programa-app-build
path: .
- name: Extract build artifact
run: |
set -euo pipefail
mkdir -p "$PROGRAMA_DERIVED_DATA_DIR"
tar -xzf app-build.tar.gz -C "$PROGRAMA_DERIVED_DATA_DIR"
- name: Create virtual display
run: |
set -euo pipefail
clang -framework Foundation -framework CoreGraphics \
-o /tmp/create-virtual-display scripts/create-virtual-display.m
/tmp/create-virtual-display &
VDISPLAY_PID=$!
echo "VDISPLAY_PID=$VDISPLAY_PID" >> "$GITHUB_ENV"
sleep 3
kill -0 "$VDISPLAY_PID"
- name: Run tests_v2 curated CI subset
run: ./scripts/run-tests-v2-ci.sh
- name: Verify ordinary-app scrollback privacy and recovery
run: |
set -euo pipefail
APP="$(./scripts/locate-built-app.sh --configuration Debug --primary 'Programa DEV' --derived-data-root "$PROGRAMA_DERIVED_DATA_DIR")"
python3 tests_v2/test_scrollback_privacy_recovery.py --app "$APP"
- name: Cleanup virtual display
if: always()
run: |
set -euo pipefail
if [ -n "${VDISPLAY_PID:-}" ]; then
kill "$VDISPLAY_PID" >/dev/null 2>&1 || true
fi
rm -f /tmp/create-virtual-display
tests-build-and-lag:
needs:
- build-app
- unit-tests
- change-detection
if: (github.event_name == 'workflow_dispatch' || (github.event_name == 'push' && github.ref == 'refs/heads/main')) && needs.change-detection.outputs.run_app_jobs == 'true'
# Run the lag regression on GitHub-hosted runners, against the app built
# once in build-app. Keep lag validation separate from UI regressions so
# functional UI failures and performance regressions stay isolated.
# Broader interactive UI suites still run via test-e2e.yml on
# GitHub-hosted runners.
runs-on: macos-26
timeout-minutes: 90
env:
PROGRAMA_DERIVED_DATA_DIR: ${{ github.workspace }}/.ci-derived-data-lag
steps:
- name: Checkout
uses: actions/checkout@34e114876b0b11c390a56381ad16ebd13914f8d5 # v4
with:
submodules: recursive
- name: Download build artifact
uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0 # v5
with:
name: programa-app-build
path: .
- name: Extract build artifact
run: |
set -euo pipefail
mkdir -p "$PROGRAMA_DERIVED_DATA_DIR"
tar -xzf app-build.tar.gz -C "$PROGRAMA_DERIVED_DATA_DIR"
- name: Create virtual display
run: |
set -euo pipefail
clang -framework Foundation -framework CoreGraphics \
-o /tmp/create-virtual-display scripts/create-virtual-display.m
/tmp/create-virtual-display &
VDISPLAY_PID=$!
echo "VDISPLAY_PID=$VDISPLAY_PID" >> "$GITHUB_ENV"
sleep 3
kill -0 "$VDISPLAY_PID"
- name: Run workspace churn typing-lag regression
run: |
set -euo pipefail
APP="$(./scripts/locate-built-app.sh \
--configuration Debug \
--primary "Programa DEV" \
--derived-data-root "$PROGRAMA_DERIVED_DATA_DIR")"
TAG="ci-lag"
SOCK="/tmp/programa-debug-${TAG}.sock"
BUNDLE_ID="$(
/usr/libexec/PlistBuddy -c 'Print :CFBundleIdentifier' "$APP/Contents/Info.plist" 2>/dev/null \
|| echo 'com.darkroom.programa.debug'
)"
pkill -x "Programa DEV" || true
rm -f "$SOCK" "/tmp/programa-${TAG}.sock" || true
defaults write "$BUNDLE_ID" socketControlMode -string full >/dev/null 2>&1 || true
PROGRAMA_TAG="$TAG" PROGRAMA_SOCKET_PATH="$SOCK" PROGRAMA_UI_TEST_MODE=1 "$APP/Contents/MacOS/Programa DEV" >/tmp/programa-ci-lag.log 2>&1 &
APP_PID=$!
trap 'kill "$APP_PID" >/dev/null 2>&1 || true' EXIT
for _ in {1..240}; do
[ -S "$SOCK" ] && break
sleep 0.25
done
[ -S "$SOCK" ] || { echo "Socket not ready at $SOCK" >&2; exit 1; }
PROGRAMA_SOCKET_PATH="$SOCK" \
PROGRAMA_LAG_MAX_P95_RATIO=1.70 \
PROGRAMA_LAG_MAX_AVG_RATIO=1.70 \
PROGRAMA_LAG_MIN_BASELINE_P95_MS_FOR_RATIO=6.0 \
PROGRAMA_LAG_MIN_BASELINE_AVG_MS_FOR_RATIO=4.0 \
PROGRAMA_LAG_MAX_P95_DELTA_MS=20.0 \
PROGRAMA_LAG_MAX_AVG_DELTA_MS=12.0 \
PROGRAMA_LAG_MAX_CHURN_P95_MS=35 \
PROGRAMA_LAG_KEY_EVENTS=180 \
PROGRAMA_LAG_KEY_COMBO="${{ inputs.lag_combo || 'up' }}" \
python3 tests_v2/test_workspace_churn_up_arrow_lag.py
- name: Compare Liquid Glass OFF and ON (report only)
if: github.event_name == 'workflow_dispatch'
run: |
set -euo pipefail
APP="$(./scripts/locate-built-app.sh \
--configuration Debug \
--primary "Programa DEV" \
--derived-data-root "$PROGRAMA_DERIVED_DATA_DIR")"
PROGRAMA_LAG_KEY_COMBO="${{ inputs.lag_combo || 'up' }}" \
./scripts/run-glass-perf-gate.sh "$APP" "${{ inputs.glass_surface || 'window' }}"
# On-demand only. This measures the refresh call itself with an in-process
# timer rather than an end-to-end socket round trip, because that round trip
# is order-milliseconds and cannot resolve a change of this size -- four runs
# of the forceRefresh change produced completely overlapping ranges (#183).
#
# Runs in its own app instance: the sampler only records when
# PROGRAMA_TYPING_TIMING_LOGS=1, and enabling that for the lag harness above
# would add logging to the very path that harness measures.
#
# Reports numbers, asserts no budget. There is no baseline yet, and a
# threshold invented before any data would be a number from nowhere.
- name: Measure text-input refresh cost (dispatch only)
if: github.event_name == 'workflow_dispatch'
run: |
set -euo pipefail
APP="$(./scripts/locate-built-app.sh \
--configuration Debug \
--primary "Programa DEV" \
--derived-data-root "$PROGRAMA_DERIVED_DATA_DIR")"
TAG="ci-refresh-cost"
SOCK="/tmp/programa-debug-${TAG}.sock"
BUNDLE_ID="$(
/usr/libexec/PlistBuddy -c 'Print :CFBundleIdentifier' "$APP/Contents/Info.plist" 2>/dev/null \
|| echo 'com.darkroom.programa.debug'
)"