Repository navigation
1419 lines (1316 loc) · 61.7 KB
/
Copy pathpython-tests.yml
File metadata and controls
1419 lines (1316 loc) · 61.7 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: Python Tests
on:
pull_request:
types: [opened, synchronize, reopened, ready_for_review, labeled, unlabeled, closed]
# Inert until the main ruleset enables a merge queue; queue runs are full.
merge_group:
workflow_dispatch:
schedule:
# Complete default-branch qualification and next-Node probe, independent of pushes.
- cron: "17 20 * * *"
push:
branches:
- main
paths:
- ".github/workflows/python-tests.yml"
- ".github/workflows/sonarcloud.yml"
- "sonar-project.properties"
- "apps/**"
- "loopx/**"
- "scripts/**"
- "tests/**"
- "examples/**"
- "package.json"
- "package-lock.json"
- "pyproject.toml"
- "setup.py"
- "MANIFEST.in"
- "tsconfig.control-plane.json"
permissions:
contents: read
concurrency:
# A merged PR's closed event uses main as github.ref; keep its original PR lane.
group: python-tests-${{ github.event_name }}-${{ (github.event_name == 'pull_request' || github.event_name == 'pull_request_target') && format('pr-{0}', github.event.number) || github.ref }}
# Let active main qualification finish; the default single pending slot keeps
# only its latest successor. PR updates still retire that PR's obsolete head.
queue: single
cancel-in-progress: ${{ github.event_name == 'pull_request' || github.event_name == 'pull_request_target' }}
env:
LOOPX_USAGE_PING: "0"
jobs:
changes:
# Closed events cancel the old lane without starting another qualification.
if: github.event_name != 'pull_request_target' && (github.event_name != 'pull_request' || github.event.action != 'closed')
runs-on: ubuntu-latest
timeout-minutes: 3
outputs:
core_tests: ${{ steps.classify.outputs.core_tests }}
backend_tests: ${{ steps.classify.outputs.backend_tests }}
frontend_tests: ${{ steps.classify.outputs.frontend_tests }}
compat_tests: ${{ steps.classify.outputs.compat_tests }}
change_kind: ${{ steps.classify.outputs.change_kind }}
python_tests: ${{ steps.classify.outputs.python_tests }}
stage2c_tests: ${{ steps.classify.outputs.stage2c_tests }}
presentation_tests: ${{ steps.classify.outputs.presentation_tests }}
steps:
- uses: actions/checkout@v7
with:
fetch-depth: 0
- uses: actions/setup-python@v6
with:
python-version: "3.11"
- uses: actions/setup-node@v6
with:
node-version: "24"
- name: Install workflow contract parser
run: python -m pip install --disable-pip-version-check 'pyyaml>=6,<7'
- name: Validate merge gate semantics
run: |
python -m unittest discover -s scripts/ci -p 'test_*.py'
node --test scripts/ci/qualification_summary.test.ts
- name: Classify the exact pull-request change
id: classify
env:
EVENT_NAME: ${{ github.event_name }}
BASE_SHA: ${{ github.event.pull_request.base.sha }}
HEAD_SHA: ${{ github.event.pull_request.head.sha }}
CHECKOUT_SHA: ${{ github.sha }}
FORCE_FULL: ${{ contains(github.event.pull_request.labels.*.name, 'ci:full') }}
shell: bash
run: |
set -euo pipefail
extra=()
if [[ "$FORCE_FULL" == true ]]; then extra+=(--force-full); fi
if [[ "$EVENT_NAME" == pull_request ]]; then
python scripts/ci/review_gate.py classify --base "$BASE_SHA" --head "$HEAD_SHA" --plan impact-plan.json "${extra[@]}" >> "$GITHUB_OUTPUT"
else
python scripts/ci/review_gate.py classify --base "$CHECKOUT_SHA" --head "$CHECKOUT_SHA" --non-pr --plan impact-plan.json >> "$GITHUB_OUTPUT"
fi
python - <<'PY'
import json, os
from pathlib import Path
plan = json.loads(Path("impact-plan.json").read_text())
with open(os.environ["GITHUB_STEP_SUMMARY"], "a") as summary:
summary.write("## CI job exemptions\n\n")
summary.write(f"Change kind: **{plan['change_kind']}**; Python shards: **{plan['python_shards']}**.\n\n")
summary.write(plan['reason'] + ".\n\n")
summary.write(
f"Backend: {plan['backend_tests']}; Frontend browser: {plan['frontend_tests']}; "
f"Compat: {plan['compat_tests']}; Python: {plan['python_tests']}; "
f"Stage2c: {plan['stage2c_tests']}; freshness: {plan['presentation_tests']}.\n\n"
)
summary.write(
plan["coverage_scope"]
+ ". Normal PRs run fast static/contract/TS checks; Nightly schedule, main, merge_group, CI-policy/manifest edits and ci:full run full.\n"
)
PY
- uses: actions/upload-artifact@v7
with:
name: ci-impact-plan
path: impact-plan.json
if-no-files-found: error
retention-days: 7
chat-bundle:
needs: [changes, kernel-static-checks]
# This is the sole admission path to expensive qualification. A client-only
# exemption requires the static lane to be skipped; failed full candidates
# continue only in the existing scheduled/manual diagnostic runs.
if: >-
${{ !cancelled() && needs.changes.result == 'success' &&
(needs.changes.outputs.core_tests == 'true' ||
needs.changes.outputs.python_tests == 'true' ||
needs.changes.outputs.presentation_tests == 'true') &&
((needs.changes.outputs.backend_tests == 'false' && needs.kernel-static-checks.result == 'skipped') ||
(needs.changes.outputs.backend_tests == 'true' &&
(needs.kernel-static-checks.result == 'success' ||
((github.event_name == 'schedule' || github.event_name == 'workflow_dispatch') &&
needs.kernel-static-checks.result == 'failure')))) }}
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- uses: actions/checkout@v7
- uses: actions/setup-python@v6
with:
python-version: "3.11"
- uses: actions/setup-node@v6
with:
node-version: "24"
cache: npm
cache-dependency-path: apps/presentation/dashboard/package-lock.json
- run: python scripts/chat_bundle.py build --install
- run: python scripts/chat_bundle.py verify --source
# Publish as soon as the bundle is built and verified so consumers start
# in parallel with browser qualification; `checks` still requires it.
- uses: actions/upload-artifact@v7
with:
name: chat-bundle-${{ github.sha }}
path: loopx/web/chat/
if-no-files-found: error
retention-days: 7
chat-bundle-browser:
needs: [changes, chat-bundle]
if: needs.changes.outputs.frontend_tests == 'true' && !cancelled() && needs.chat-bundle.result == 'success'
runs-on: ubuntu-latest
# The packaged scenario catalog outgrew one 15-minute runner, so the
# catalog is partitioned like dashboard-browser and the companion smokes
# are spread across the shards. The aggregate needs every shard to pass.
timeout-minutes: 20
strategy:
fail-fast: false
matrix:
shard: [1, 2, 3]
steps:
- uses: actions/checkout@v7
- uses: actions/download-artifact@v7
with:
name: chat-bundle-${{ github.sha }}
path: loopx/web/chat/
- uses: actions/setup-python@v6
with:
python-version: "3.11"
- name: Install checkout for Python-backed browser scenarios
run: |
python -m pip install --disable-pip-version-check -e '.[test]'
echo "LOOPX_TEST_PYTHON=$(python -c 'import sys; print(sys.executable)')" >> "$GITHUB_ENV"
- uses: actions/setup-node@v6
with:
node-version: "24"
cache: npm
cache-dependency-path: apps/presentation/dashboard/package-lock.json
- name: Qualify the actual compiled UI
working-directory: apps/presentation/dashboard
env:
LOOPX_PERSONAL_WORKSPACE_SHARD: "${{ matrix.shard }}/3"
run: |
npm ci --ignore-scripts
./node_modules/.bin/playwright install --with-deps chromium
node ../../../examples/personal-workspace-browser/shard.test.mjs
npm run smoke:personal-workspace-packaged:catalog
- name: Qualify turn acceptance retry and the upgrade window
if: matrix.shard == 1
working-directory: apps/presentation/dashboard
run: |
npm run smoke:chat-turn-acceptance-retry
npm run smoke:chat-upgrade
npm run smoke:delegation-search
npm run smoke:task-inspector-route
npm run smoke:explore-timeline-scan
npm run smoke:conversation-find
node smoke/todo-confirmation-browser-smoke.mjs
- name: Qualify packaged team evidence and feedback recovery
if: matrix.shard == 2
working-directory: apps/presentation/dashboard
run: npm run smoke:personal-workspace-packaged:team
- name: Qualify original-task revalidation with the real worker
if: matrix.shard == 2
env:
LOOPX_PLAYWRIGHT_PACKAGE: ${{ github.workspace }}/apps/presentation/dashboard/node_modules/playwright
LOOPX_USAGE_PING: "0"
run: |
python -m pip install --disable-pip-version-check -e ".[test]"
node apps/presentation/dashboard/smoke/team-task-revalidation-smoke.mjs
- name: Preserve synthetic original-task recovery views
if: always() && matrix.shard == 2
uses: actions/upload-artifact@v7
with:
name: task-revalidation-${{ github.sha }}
path: |
output/playwright/personal-workspace/team-original-worker-finishing-mobile.png
output/playwright/personal-workspace/team-original-worker-finishing-desktop.png
output/playwright/personal-workspace/team-original-recovery-mobile.png
if-no-files-found: ignore
retention-days: 7
- name: Qualify the Goal workspace craft composition
if: matrix.shard == 3
working-directory: apps/presentation/dashboard
run: npm run smoke:personal-workspace-packaged:craft
- name: Qualify packaged ZCode recovery against its persistent owner
if: matrix.shard == 3
env:
LOOPX_USAGE_PING: "0"
DO_NOT_TRACK: "1"
run: |
python -m pip install --disable-pip-version-check -e ".[test]"
npm ci --ignore-scripts
node examples/zcode-persistent-browser-smoke.mjs
kernel-static-checks:
# Reject cheap repository failures before any frontend build or test matrix.
needs: changes
if: needs.changes.outputs.backend_tests == 'true'
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Check out repository
uses: actions/checkout@v7
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: "3.11"
cache: pip
- name: Install test dependencies
run: python -m pip install --disable-pip-version-check -e ".[test]"
- name: Check repository invariants before long tests
run: >-
python -m pytest -q --no-cov
tests/test_stage2c_dependency_lock.py
tests/architecture/test_top_level_module_budget.py
tests/architecture/test_external_request_lint.py
tests/test_repository_instruction_delivery.py
tests/test_contributing_guide.py
- name: Lint external request dispatch boundaries
run: |
python -m ruff check --ignore-noqa --config scripts/ci/external-request-lint.toml loopx packages scripts apps
python -m ruff check --ignore-noqa --config scripts/ci/external-transport-lint.toml loopx packages/*/src
- name: Lint test suite
run: >-
python -m ruff check
tests
loopx/canary
loopx/control_plane
loopx/domain_packs
loopx/presentation
kernel-contracts:
needs: [changes, chat-bundle]
if: needs.changes.outputs.backend_tests == 'true' && !cancelled() && needs.chat-bundle.result == 'success'
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- name: Check out repository
uses: actions/checkout@v7
with:
fetch-depth: 0
- uses: actions/download-artifact@v7
with:
name: chat-bundle-${{ github.sha }}
path: loopx/web/chat/
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: "3.11"
cache: pip
- name: Set up the TypeScript Effect runtime
uses: actions/setup-node@v6
with:
node-version: "24"
cache: npm
cache-dependency-path: package-lock.json
- name: Install test dependencies
run: python -m pip install --disable-pip-version-check -e ".[test]"
- name: Check external provider recovery
run: python -m pytest -q --no-cov tests/extensions/test_governed_capability_execution.py
- name: Verify file authority on the core runtime
run: >-
node --no-warnings --experimental-strip-types --test
tests/control_plane_ts/authority_store.test.ts
tests/control_plane_ts/local_authority_runtime.test.ts
tests/control_plane_ts/sqlite_runtime_admission.test.ts
# `follow-imports=silent` keeps the declared contract set under `strict`
# while letting follow-up imports resolve types without reporting on
# modules this gate never claimed to qualify. Without it the same run
# reports thousands of `strict` findings in legacy modules pulled in by
# import traversal, so the gate never reports its own 17 files clean.
- name: Type-check kernel contracts
run: python -m mypy --follow-imports=silent
# Preserve the kernel gate above, including its import traversal. This
# additive boundary checks the adapters strictly and analyzes legacy
# imports for types without claiming their implementations are qualified.
- name: Type-check Todo CLI adapters
run: >-
python -m mypy --no-incremental --follow-imports=silent
loopx/cli_commands/todo_event.py
loopx/control_plane/todos/markdown.py
- name: Qualify agent-facing CLI output
env:
# Compare the tested revision to its event base, even after main moves
# while this run is queued. Pin the selector's main ref as well.
LOOPX_CLI_OUTPUT_BASE_REF: ${{ github.event.pull_request.base.sha || github.event.merge_group.base_sha || github.sha }}
LOOPX_CLI_OUTPUT_MAIN_REF: ${{ github.event.pull_request.base.sha || github.event.merge_group.base_sha || github.sha }}
run: python examples/control_plane/cli-output-budget-regression-smoke.py
typescript-core:
name: typescript-core (${{ matrix.shard }}/3)
needs: [changes, chat-bundle]
if: needs.changes.outputs.backend_tests == 'true' && !cancelled() && needs.chat-bundle.result == 'success'
runs-on: ubuntu-latest
timeout-minutes: 30
strategy:
fail-fast: false
matrix:
shard: [1, 2, 3]
steps:
- name: Check out repository
uses: actions/checkout@v7
- uses: actions/download-artifact@v7
with:
name: chat-bundle-${{ github.sha }}
path: loopx/web/chat/
- name: Set up Python
uses: actions/setup-python@v6
with:
python-version: "3.11"
cache: pip
- name: Set up the qualified SQLite runtime
uses: actions/setup-node@v6
with:
node-version: "22.22.3"
cache: npm
cache-dependency-path: package-lock.json
- name: Install test dependencies
run: |
python -m pip install --disable-pip-version-check -e ".[test]"
npm ci --ignore-scripts
- name: Lint external JS and TS transports
if: matrix.shard == 1
run: |
node --test scripts/ci/lint-external-transports.test.mjs
node scripts/ci/lint-external-transports.mjs
- name: Type-check the TypeScript Effect core
if: matrix.shard == 1
run: npm run typecheck:control-plane
- name: Qualify the TypeScript Effect core
env:
LOOPX_TEST_REQUIRE_SQLITE_QUALIFIED: "1"
run: |
mapfile -t files < <(python -m scripts.ci.ts_test_shard --shards 3 --shard ${{ matrix.shard }})
test "${#files[@]}" -gt 0
NODE_V8_COVERAGE="$PWD/coverage/v8" node --no-warnings --experimental-sqlite \
--experimental-strip-types --test "${files[@]}"
- uses: actions/upload-artifact@v7
with:
name: typescript-v8-coverage-${{ matrix.shard }}
path: coverage/v8/
if-no-files-found: error
retention-days: 1
typescript-coverage:
needs: [changes, typescript-core]
if: needs.changes.outputs.backend_tests == 'true' && !cancelled() && needs.typescript-core.result == 'success'
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@v7
- uses: actions/setup-node@v6
with:
node-version: "22.22.3"
cache: npm
cache-dependency-path: package-lock.json
- run: npm ci --ignore-scripts
- uses: actions/download-artifact@v7
with:
pattern: typescript-v8-coverage-*
path: coverage/shards
- name: Report complete TypeScript control-plane coverage
run: |
mkdir -p coverage/v8
for shard in 1 2 3; do
dir="coverage/shards/typescript-v8-coverage-${shard}"
compgen -G "${dir}/*.json" > /dev/null
for file in "${dir}"/*.json; do
cp "$file" "coverage/v8/${shard}-$(basename "$file")"
done
done
npx c8 report --temp-directory=coverage/v8 --all \
--include='loopx/control_plane/**/*.ts' \
--exclude='loopx/control_plane/**/*.generated.ts' \
--reporter=lcov --reporter=text --reports-dir=coverage/control-plane
- name: Upload TypeScript control-plane coverage
uses: actions/upload-artifact@v7
with:
name: typescript-control-plane-coverage
path: coverage/control-plane/lcov.info
if-no-files-found: error
retention-days: 3
dashboard-browser:
needs: [changes, chat-bundle]
if: needs.changes.outputs.frontend_tests == 'true' && !cancelled() && needs.chat-bundle.result == 'success'
runs-on: ubuntu-latest
timeout-minutes: 25
strategy:
fail-fast: false
matrix:
shard: [1, 2, 3]
steps:
- name: Check out repository
uses: actions/checkout@v7
- uses: actions/download-artifact@v7
with:
name: chat-bundle-${{ github.sha }}
path: loopx/web/chat/
- uses: actions/setup-python@v6
with:
python-version: "3.11"
- name: Install checkout for Python-backed browser scenarios
run: |
python -m pip install --disable-pip-version-check -e .
echo "LOOPX_TEST_PYTHON=$(python -c 'import sys; print(sys.executable)')" >> "$GITHUB_ENV"
- name: Set up the qualified Node.js runtime
uses: actions/setup-node@v6
with:
node-version: "22.22.3"
cache: npm
cache-dependency-path: |
package-lock.json
apps/presentation/dashboard/package-lock.json
- name: Install Dashboard and coverage dependencies
run: |
npm ci --ignore-scripts
npm ci --ignore-scripts --prefix apps/presentation/dashboard
- name: Check the CSS custom-property classifier contract
run: node scripts/check-css-custom-properties.test.mjs
- name: Reject undefined CSS custom properties
run: node scripts/check-css-custom-properties.mjs dashboard
# The coverage merger consumes the unit report from shard 1 only.
- name: Check Dashboard startup ownership and measure unit coverage once
if: matrix.shard == 1
run: |
node --test examples/personal-workspace-browser/server-startup.test.mjs
npm run test:dashboard:coverage
- name: Measure Dashboard browser interactions
env:
LOOPX_PERSONAL_WORKSPACE_SHARD: "${{ matrix.shard }}/3"
LOOPX_DASHBOARD_COVERAGE: "1"
LOOPX_PLAYWRIGHT_PACKAGE: ${{ github.workspace }}/apps/presentation/dashboard/node_modules/playwright
run: |
node --test examples/personal-workspace-browser/shard.test.mjs examples/personal-workspace-browser/goal-workspace-m2.test.mjs
cd apps/presentation/dashboard
npx playwright install --with-deps chromium --only-shell
node ../../../examples/personal-workspace-browser-smoke.mjs
cp ../../../output/playwright/personal-workspace/acceptance-results.json ../../../coverage/dashboard/acceptance-results.json
- name: Upload Dashboard coverage
uses: actions/upload-artifact@v7
with:
name: dashboard-coverage-${{ matrix.shard }}
path: |
coverage/dashboard/lcov.info
coverage/dashboard/browser-coverage.json
coverage/dashboard/acceptance-results.json
if-no-files-found: error
retention-days: 3
- name: Upload text document visual evidence
if: always() && hashFiles('output/playwright/personal-workspace/document-*.png') != ''
uses: actions/upload-artifact@v7
with:
name: text-document-evidence-${{ matrix.shard }}
path: output/playwright/personal-workspace/document-*.png
if-no-files-found: error
retention-days: 14
dashboard-acceptance:
needs: [changes, dashboard-browser]
if: needs.changes.outputs.frontend_tests == 'true' && !cancelled() && needs.dashboard-browser.result == 'success'
runs-on: ubuntu-latest
timeout-minutes: 5
steps:
- uses: actions/checkout@v7
- uses: actions/setup-node@v6
with:
node-version: "22.22.3"
- run: npm ci --ignore-scripts
- run: node --test scripts/ci/merge-dashboard-coverage.test.mjs
- uses: actions/download-artifact@v7
with:
pattern: dashboard-coverage-*
path: coverage/dashboard-shards
- name: Require every acceptance shard and merge source coverage
run: node scripts/ci/merge-dashboard-coverage.mjs coverage/dashboard-shards coverage/dashboard
- uses: actions/upload-artifact@v7
with:
name: dashboard-coverage
path: coverage/dashboard/*.info
if-no-files-found: error
retention-days: 3
checks:
# Preserve the required check name while exposing independent failure lanes.
# Cancelled main pushes must not retain runner-backed aggregate work.
if: always() && needs.changes.outputs.core_tests == 'true' && (github.event_name != 'push' || !cancelled())
needs: [changes, kernel-static-checks, kernel-contracts, typescript-coverage, dashboard-acceptance, chat-bundle-browser]
runs-on: ubuntu-latest
timeout-minutes: 2
steps:
- uses: actions/checkout@v7
- uses: actions/setup-python@v6
with:
python-version: "3.11"
- name: Require the planned backend and Dashboard qualification
env:
NEEDS_JSON: ${{ toJSON(needs) }}
run: python scripts/ci/review_gate.py verify-core
node-minimum-compatibility:
needs: [changes, chat-bundle]
if: needs.changes.outputs.compat_tests == 'true' && !cancelled() && needs.chat-bundle.result == 'success'
runs-on: ubuntu-latest
# The full suite runs under this exact Node version in typescript-core.
timeout-minutes: 10
steps:
- uses: actions/checkout@v7
- uses: actions/setup-node@v6
with:
node-version: "22.22.3"
cache: npm
cache-dependency-path: package-lock.json
- name: Qualify the public minimum Node.js runtime
env:
LOOPX_TEST_REQUIRE_SQLITE_QUALIFIED: "1"
run: |
npm ci --ignore-scripts
npm run typecheck:control-plane
# Prove the minimum itself admits SQLite and executes both provider
# lifecycle rows. The qualified core lane runs the complete suite.
node --no-warnings --experimental-sqlite --experimental-strip-types --test \
tests/control_plane_ts/sqlite_runtime_admission.test.ts \
tests/control_plane_ts/deferred_hard_lease_lifecycle.test.ts
node-forward-compatibility:
needs: [changes, chat-bundle]
# Probe the future runtime once per night or on demand, outside the PR/main
# critical path. The supported runtime still runs on every full candidate.
if: (github.event_name == 'schedule' || github.event_name == 'workflow_dispatch') && needs.changes.outputs.compat_tests == 'true' && !cancelled() && needs.chat-bundle.result == 'success'
continue-on-error: true
runs-on: ubuntu-latest
# This runs the full core conformance suite. Allow forward-runtime/runner
# variance without dropping cases or changing individual test deadlines.
timeout-minutes: 45
steps:
- uses: actions/checkout@v7
- uses: actions/setup-node@v6
with:
node-version: "26"
cache: npm
cache-dependency-path: package-lock.json
- name: Probe the next Node.js runtime
run: |
npm ci --ignore-scripts
npm run typecheck:control-plane
npm run test:control-plane
test-durations-snapshot:
# Materialize the split baseline exactly once, before the matrix exists.
# Six independent cache restores can disagree, and disagreeing weights
# partition the suite differently per shard: duplicated and dropped cases
# while every shard still exits 0. Publishing one artifact makes the input
# identical for all six, or absent for all six.
# Same admission as the shards: when no Python run is selected there is no
# matrix to feed, and the classifier's answer is already known here.
if: >-
${{ !cancelled() && needs.changes.result == 'success' &&
needs.changes.outputs.python_tests == 'true' }}
needs: [changes]
runs-on: ubuntu-latest
timeout-minutes: 5
outputs:
# The identity each shard must confirm before it splits. Published by the
# one job that produced the artifact, so every shard compares against the
# same expected value instead of merely printing its own.
snapshot_sha256: ${{ steps.digest.outputs.sha256 }}
steps:
- uses: actions/checkout@v7
- name: Restore the newest measured baseline
uses: actions/cache/restore@v4
with:
path: .test_durations
key: python-test-durations-${{ runner.os }}-${{ github.sha }}
restore-keys: |
python-test-durations-${{ runner.os }}-
- name: Pin an empty baseline when no history exists
# pytest-split reads an empty map as equal weights, which is today's
# behaviour, so a first run splits byte-for-byte as it does now.
run: |
if [ ! -s .test_durations ]; then printf '{}\n' > .test_durations; fi
- name: Record the identity of the published snapshot
# The shards cannot prove they used the same input by hashing whatever
# they received: two different-but-valid maps would both pass. This job
# hashes the artifact it is about to upload and exports that digest as a
# job output, so each shard compares against the producer's value.
# The failure is made explicit here rather than left to the shards: this
# job has no `setup-python`, and a shell that swallowed a missing
# interpreter would publish an empty expected value, turning every shard
# red with a misleading message.
id: digest
run: |
set -euo pipefail
sha=$(python3 -c "import hashlib,pathlib; print(hashlib.sha256(pathlib.Path('.test_durations').read_bytes()).hexdigest())")
if [ "${#sha}" -ne 64 ]; then
echo "could not compute a sha256 for the published snapshot: ${sha:-<empty>}" >&2
exit 1
fi
printf 'sha256=%s\n' "$sha" >> "$GITHUB_OUTPUT"
printf 'snapshot sha256=%s\n' "$sha"
- name: Publish the snapshot every shard will use
# Retention must cover the shard rerun window, not just one day. A
# failed job can be re-run hours later and reuses this successful
# producer job instead of running it again; when the artifact had
# already expired, every retried shard failed at the download step and
# the only recovery was a full new run. Seven days matches the bundle
# and the per-shard measurement artifacts this job feeds.
uses: actions/upload-artifact@v7
with:
name: python-durations-baseline
path: .test_durations
include-hidden-files: true
if-no-files-found: error
retention-days: 7
test-shard:
# The bundle admits only statically qualified candidates or explicit
# diagnostics. Python can now overlap TS/browser qualification while its
# six repository-wide slots still bound long-test concurrency.
needs: [changes, chat-bundle, test-durations-snapshot]
if: >-
${{ !cancelled() && needs.changes.result == 'success' &&
needs.changes.outputs.python_tests == 'true' &&
needs.chat-bundle.result == 'success' }}
runs-on: ubuntu-latest
# Share six long-test lanes across current PRs and other workflow runs.
# Do not replace another candidate's pending shard or cancel its active head.
# Workflow-level concurrency still retires obsolete heads of the same PR.
concurrency:
group: loopx-python-test-shard-${{ matrix.shard }}
queue: max
cancel-in-progress: false
# All shards were still progressing at 83-94% when the 45m job
# deadline cancelled run 37916979857. Reserve setup/reporting headroom
# without changing test-level deadlines, collection or worker count; compute
# the remaining cooperative session deadline from the actual job start epoch
# while reserving 5m for partial JUnit/diagnostics flush and artifact upload.
timeout-minutes: 60
strategy:
fail-fast: false
matrix:
shard: [1, 2, 3, 4, 5, 6]
steps:
- name: Record job start time
run: echo "LOOPX_SHARD_JOB_START_EPOCH=$(date -u +%s)" >> "$GITHUB_ENV"
- uses: actions/checkout@v7
with:
fetch-depth: 0
- uses: actions/download-artifact@v7
with:
name: chat-bundle-${{ github.sha }}
path: loopx/web/chat/
- uses: actions/setup-python@v6
with:
python-version: "3.11"
cache: pip
- uses: actions/setup-node@v6
with:
node-version: "24"
cache: npm
cache-dependency-path: package-lock.json
- name: Install test dependencies
run: |
python -m pip install --disable-pip-version-check -e ".[test]"
npm ci --ignore-scripts
- name: Install uv for wheel tests
uses: astral-sh/setup-uv@v7
- name: Prepare native shell isolation
# Ubuntu 24.04 may need an executable-scoped userns profile for bwrap.
# Do not disable AppArmor or the system-wide unprivileged-userns guard.
run: |
if ! command -v bwrap >/dev/null 2>&1; then
sudo apt-get update
sudo apt-get install -y --no-install-recommends bubblewrap
fi
if ! bwrap --unshare-all --ro-bind / / /bin/true; then
sudo tee /etc/apparmor.d/loopx-qualification-bwrap >/dev/null <<'PROFILE'
abi <abi/4.0>,
include <tunables/global>
profile loopx-qualification-bwrap /usr/bin/bwrap flags=(unconfined) {
userns,
}
PROFILE
sudo apparmor_parser -r /etc/apparmor.d/loopx-qualification-bwrap
fi
bwrap --unshare-all --ro-bind / / /bin/true
- name: Take the shared duration snapshot
# One artifact, produced before the matrix started, so every shard
# splits from identical weights. A per-shard cache restore can diverge
# (a cache saved mid-run, or branch-scoped visibility), and divergent
# weights produce different partitions: some cases run twice, others
# never run, while every shard still exits 0.
uses: actions/download-artifact@v7
# Never fall back per shard. The producer always publishes an artifact
# (`{}` when there is no history), so a shard that cannot fetch it has
# lost the shared input the other five used. Continuing would split that
# shard by equal weights while the rest split by measured cost, and the
# resulting partitions overlap: some cases run twice, others never run,
# with all six shards still exiting 0. Fail this shard instead, so the
# incomplete qualification is visible rather than silently partial.
with:
name: python-durations-baseline
path: .
- name: Verify the shared snapshot identity
# A shard can only prove it split from the same map as the other five by
# matching the digest the producer published, not by hashing whatever it
# happened to download. Without the comparison, two shards could each
# receive a different but valid map and both proceed — which is exactly
# the divergent-partition failure this job is meant to rule out.
run: |
python - <<'PY'
import hashlib, json, os, pathlib, sys
snapshot = pathlib.Path(".test_durations")
if not snapshot.is_file() or snapshot.stat().st_size == 0:
sys.exit("shared duration snapshot is missing or empty")
try:
payload = json.loads(snapshot.read_text(encoding="utf-8"))
except json.JSONDecodeError as exc:
sys.exit(f"shared duration snapshot is not valid JSON: {exc}")
if not isinstance(payload, dict):
sys.exit("shared duration snapshot must be a JSON object")
digest = hashlib.sha256(snapshot.read_bytes()).hexdigest()
expected = os.environ.get("EXPECTED_SNAPSHOT_SHA256", "").strip()
if not expected:
sys.exit("producer did not publish a snapshot digest to compare against")
if digest != expected:
sys.exit(
"shared duration snapshot differs from the published one: "
f"expected {expected}, got {digest}"
)
shard = os.environ.get("MATRIX_SHARD", "n/a")
with open(os.environ["GITHUB_STEP_SUMMARY"], "a", encoding="utf-8") as handle:
handle.write(
"| shard | snapshot sha256 | cases |\n"
"| --- | --- | --- |\n"
f"| {shard} | `{digest}` | {len(payload)} |\n"
)
print(f"snapshot sha256={digest} cases={len(payload)}")
PY
env:
MATRIX_SHARD: ${{ matrix.shard }}
EXPECTED_SNAPSHOT_SHA256: ${{ needs.test-durations-snapshot.outputs.snapshot_sha256 }}
- name: Run test shard
# Split the whole collection, not a hand-maintained list of directories.
# Without timing history least_duration alternates equal-weight tests.
# Each runner uses a bounded three-worker pool. Cooperative stacks
# and the dynamic job-budget deadline diagnose slow/blocked cases and
# preserve the upload reserve even when setup steps overrun.
# Upload the raw coverage partition and render reports after combining all shards.
# Anchor coverage to this checkout before relative paths are recorded.
run: >-
python -m scripts.ci.shard_budget
--job-budget-seconds 3600
--upload-reserve-seconds 300
--min-session-seconds 300
--diagnostics-file ci-shard-diagnostics.json
--
-v -n 3 -m "not stage2c_e2e"
-p scripts.ci.pytest_timing
--ci-stall-after 120
--ci-diagnostics-file ci-shard-diagnostics.json
--splits 6 --group ${{ matrix.shard }}
--splitting-algorithm least_duration
--durations-path .test_durations --ci-durations-out .test_durations.shard
--durations=25 --durations-min=1
--junitxml=junit.xml
--cov="$PWD/loopx"
--cov-report=
- name: Upload full-shard outcomes for selection audit
if: ${{ !cancelled() }}
uses: actions/upload-artifact@v7
with:
name: python-junit-${{ matrix.shard }}
path: junit.xml
if-no-files-found: error
retention-days: 7
- name: Upload the measured duration subset
if: always()
uses: actions/upload-artifact@v7
with:
name: python-durations-shard-${{ matrix.shard }}
path: .test_durations.shard
include-hidden-files: true
if-no-files-found: warn
retention-days: 7
- name: Upload shard timeout and progress diagnostics
if: always()
uses: actions/upload-artifact@v7
with:
name: python-diagnostics-${{ matrix.shard }}
path: ci-shard-diagnostics.json
if-no-files-found: warn
retention-days: 7
- name: Upload shard coverage
uses: actions/upload-artifact@v7
with:
name: python-coverage-${{ matrix.shard }}
path: .coverage
include-hidden-files: true
if-no-files-found: error
retention-days: 3
test-durations-merge:
# Feed the next run's split with measured cost instead of equal weights.
# Same admission as the shards: with no Python run there is nothing to
# collect, and that has to be a skip rather than a failed merge — the
# current optional-collection semantics, not a new red check.
# Writes are keyed by run id and attempt. A saved cache key is immutable, so
# a key without the attempt silently skips the save on every re-run — and a
# re-run is exactly when a fresh measurement has to replace the one the
# failed attempt produced. The shared prefix keeps the key restorable by the
# snapshot job's `restore-keys`.
if: >-
${{ always() && needs.changes.outputs.python_tests == 'true' &&
!cancelled() }}
needs: [changes, test-shard]
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- uses: actions/checkout@v7
- name: Collect every shard duration subset
uses: actions/download-artifact@v7
with:
pattern: python-durations-shard-*
path: durations
- name: Collect the estimate this run split from
uses: actions/download-artifact@v7
with:
name: python-durations-baseline
path: baseline
- name: Replace the estimate with this run's measurements
# Fresh measurements win entry by entry, so a stale weight cannot outlive
# the run that measured it. Cases this run never reached keep the estimate
# instead of dropping out of the split.
run: >-
python scripts/ci/merge_test_durations.py
--inputs-dir durations
--previous baseline/.test_durations
--output .test_durations
- name: Save the merged baseline for later runs
uses: actions/cache/save@v4
with:
path: .test_durations
key: python-test-durations-${{ runner.os }}-${{ github.sha }}-${{ github.run_id }}-${{ github.run_attempt }}
pytest:
# Keep the required check name; a skipped/failed shard must not turn it green.
if: always() && needs.changes.outputs.python_tests == 'true' && (github.event_name != 'push' || !cancelled())
needs: [changes, checks, test-shard]
runs-on: ubuntu-latest
timeout-minutes: 10
steps:
- name: Require every upstream check
env:
CHECKS_RESULT: ${{ needs.checks.result }}
SHARDS_RESULT: ${{ needs.test-shard.result }}
run: |
test "$CHECKS_RESULT" = success
test "$SHARDS_RESULT" = success
- uses: actions/checkout@v7
- uses: actions/setup-python@v6
with:
python-version: "3.11"
cache: pip
- run: python -m pip install --disable-pip-version-check -e ".[test]"
- uses: actions/download-artifact@v7
with:
pattern: python-coverage-*
path: coverage-shards
- name: Combine complete coverage and enforce the existing floor
run: |
shards=()
for shard in 1 2 3 4 5 6; do
path="coverage-shards/python-coverage-${shard}/.coverage"
test -s "$path"
shards+=("$path")
done
python -m coverage combine "${shards[@]}"
python -m coverage report --fail-under=19.6
python -m coverage xml -o coverage.xml
- uses: actions/upload-artifact@v7
with:
name: python-coverage-xml
path: coverage.xml
if-no-files-found: error
retention-days: 3
sonar:
needs: pytest
# Queue refs are temporary; analyse PRs and main, not gh-readonly-queue/*.
if: github.event_name != 'merge_group'
uses: ./.github/workflows/sonarcloud.yml
secrets:
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
stage2c-suite:
needs: [changes, chat-bundle]
if: needs.changes.outputs.stage2c_tests == 'true' && !cancelled() && needs.chat-bundle.result == 'success'
name: stage2c (${{ matrix.suite }} ${{ matrix.shard }})
runs-on: ubuntu-latest
timeout-minutes: 30
strategy:
fail-fast: false
matrix:
include:
- {suite: e2e, shard: 1}
- {suite: e2e, shard: 2}
- {suite: mutants, shard: 0}
- {suite: installed, shard: 0}
steps:
- uses: actions/checkout@v7
- uses: actions/download-artifact@v7
with: