-
Notifications
You must be signed in to change notification settings - Fork 14
869 lines (812 loc) · 36.6 KB
/
ci.yml
File metadata and controls
869 lines (812 loc) · 36.6 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
name: CI
on:
push:
branches: [main]
pull_request:
branches: [main]
concurrency:
group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.event.pull_request.number || github.ref }}
cancel-in-progress: ${{ github.event_name == 'pull_request' }}
permissions:
contents: read
env:
DO_NOT_TRACK: '1'
jobs:
ci-scope:
name: CI scope
runs-on: ubuntu-latest
outputs:
library: ${{ steps.scope.outputs.library }}
website: ${{ steps.scope.outputs.website }}
cockpit: ${{ steps.scope.outputs.cockpit }}
cockpit_examples: ${{ steps.scope.outputs.cockpit_examples }}
cockpit_smoke: ${{ steps.scope.outputs.cockpit_smoke }}
cockpit_secret: ${{ steps.scope.outputs.cockpit_secret }}
cockpit_deploy_smoke: ${{ steps.scope.outputs.cockpit_deploy_smoke }}
examples_chat: ${{ steps.scope.outputs.examples_chat }}
cockpit_e2e: ${{ steps.scope.outputs.cockpit_e2e }}
website_e2e: ${{ steps.scope.outputs.website_e2e }}
posthog: ${{ steps.scope.outputs.posthog }}
steps:
- uses: actions/checkout@v6.0.2
with:
fetch-depth: 0
- uses: actions/setup-node@v6.3.0
with:
node-version: 22
cache: npm
# ci-scope.mjs delegates project ownership to `nx show projects --affected`
# (introduced in PR 2 of the ci-scope thin-shim migration), which requires
# nx + the workspace's plugins to be installed. npm ci needs ~15-30s with
# the npm cache warm; ~60s cold. This is the one-time-per-PR cost of using
# nx's project graph as the source of truth instead of a hand-maintained
# classifier walk.
- run: npm ci
- name: Test CI scope classifier
run: node --test scripts/ci-scope.spec.mjs
- name: Detect changed CI surfaces
id: scope
run: |
set -euo pipefail
if [ "${{ github.event_name }}" = "push" ]; then
node scripts/ci-scope.mjs \
--event push \
--output "$GITHUB_OUTPUT"
exit 0
fi
base_sha="${{ github.event.pull_request.base.sha }}"
head_sha="${{ github.event.pull_request.head.sha }}"
if ! git cat-file -e "$base_sha^{commit}" 2>/dev/null || ! git cat-file -e "$head_sha^{commit}" 2>/dev/null; then
base_sha="$(git rev-parse HEAD^1)"
head_sha="$(git rev-parse HEAD^2)"
fi
node scripts/ci-scope.mjs \
--event pull_request \
--base "$base_sha" \
--head "$head_sha" \
--output "$GITHUB_OUTPUT"
- name: Validate CI workflow guards
run: node --test scripts/ci-workflow.spec.mjs
library:
name: Library — lint / test / build
needs: ci-scope
if: github.event_name == 'push' || needs.ci-scope.outputs.library == 'true'
runs-on: ubuntu-latest
env:
LIBS: chat,langgraph,ag-ui,render,a2ui,licensing,telemetry
steps:
- uses: actions/checkout@v6.0.2
- uses: actions/setup-node@v6.3.0
with:
node-version: 22
cache: npm
- run: npm ci
- run: npx nx run-many -t lint --projects=$LIBS
- run: npx nx run-many -t test --projects=$LIBS --coverage
- run: npx nx run-many -t build --projects=$LIBS --configuration=production
- run: node scripts/verify-release-versions.mjs
website:
name: Website — lint / build
needs: ci-scope
if: github.event_name == 'push' || needs.ci-scope.outputs.website == 'true'
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v6.0.2
with:
ref: ${{ github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository && github.head_ref || github.sha }}
- uses: actions/setup-node@v6.3.0
with:
node-version: 22
cache: npm
- run: npm ci
- run: npx nx lint website
- run: npm run generate-api-docs
- name: Commit generated API docs to same-repo PR
if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository
run: |
if git diff --quiet -- apps/website/content/docs/*/api/api-docs.json; then
echo "Generated API docs are already committed."
exit 0
fi
git config user.name "github-actions[bot]"
git config user.email "41898282+github-actions[bot]@users.noreply.github.com"
git add apps/website/content/docs/*/api/api-docs.json
git commit -m "chore(docs): regenerate api docs"
git push origin "HEAD:${{ github.head_ref }}"
- name: Verify generated API docs are committed
run: git diff --exit-code -- apps/website/content/docs/*/api/api-docs.json
- run: npx nx build website
cockpit:
name: Cockpit — build / test
needs: ci-scope
if: github.event_name == 'push' || needs.ci-scope.outputs.cockpit == 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6.0.2
- uses: actions/setup-node@v6.3.0
with:
node-version: 22
cache: npm
- run: npm ci
- run: npx nx build cockpit --skip-nx-cache
- run: npx nx test cockpit --skip-nx-cache
cockpit-examples-build:
name: Cockpit — build all examples
needs: ci-scope
if: github.event_name == 'push' || needs.ci-scope.outputs.cockpit_examples == 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6.0.2
- uses: actions/setup-node@v6.3.0
with:
node-version: 22
cache: npm
- run: npm ci
- run: npx nx run-many -t build --projects='cockpit-*-angular' --skip-nx-cache
cockpit-smoke:
name: Cockpit — representative capability smoke
needs: ci-scope
if: github.event_name == 'push' || needs.ci-scope.outputs.cockpit_smoke == 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6.0.2
- uses: actions/setup-node@v6.3.0
with:
node-version: 22
cache: npm
- run: npm ci
- run: npx nx run-many -t smoke --projects=cockpit-deep-agents-planning-python,cockpit-deep-agents-filesystem-python,cockpit-deep-agents-subagents-python,cockpit-deep-agents-memory-python,cockpit-deep-agents-skills-python,cockpit-deep-agents-sandboxes-python,cockpit-langgraph-persistence-python,cockpit-langgraph-durable-execution-python,cockpit-langgraph-streaming-python,cockpit-langgraph-interrupts-python,cockpit-langgraph-memory-python,cockpit-langgraph-subgraphs-python,cockpit-langgraph-time-travel-python,cockpit-langgraph-deployment-runtime-python --skip-nx-cache
cockpit-secret-integration:
name: Cockpit — secret-gated integration
needs: ci-scope
if: github.event_name == 'push' || needs.ci-scope.outputs.cockpit_secret == 'true'
runs-on: ubuntu-latest
steps:
- name: Check integration secret
id: integration_secret
run: |
if [ -z "${COCKPIT_SECRET_TOKEN}" ]; then
echo "enabled=false" >> "$GITHUB_OUTPUT"
echo "::notice::Skipping secret-gated integration: COCKPIT_SECRET_TOKEN is not configured"
else
echo "enabled=true" >> "$GITHUB_OUTPUT"
fi
env:
COCKPIT_SECRET_TOKEN: ${{ secrets.COCKPIT_SECRET_TOKEN }}
- uses: actions/checkout@v6.0.2
if: steps.integration_secret.outputs.enabled == 'true'
- uses: actions/setup-node@v6.3.0
if: steps.integration_secret.outputs.enabled == 'true'
with:
node-version: 22
cache: npm
- if: steps.integration_secret.outputs.enabled == 'true'
run: npm ci
- if: steps.integration_secret.outputs.enabled == 'true'
run: npx nx run cockpit-langgraph-deployment-runtime-python:integration --skip-nx-cache
env:
COCKPIT_SECRET_TOKEN: ${{ secrets.COCKPIT_SECRET_TOKEN }}
cockpit-deploy-smoke:
name: Cockpit — deploy smoke dry-run
needs: ci-scope
if: github.event_name == 'push' || needs.ci-scope.outputs.cockpit_deploy_smoke == 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6.0.2
- uses: actions/setup-node@v6.3.0
with:
node-version: 22
cache: npm
- run: npm ci
- run: npx tsx apps/cockpit/scripts/deploy-smoke.ts --url https://cockpit.threadplane.ai --dry-run
examples-chat-smoke:
name: examples/chat — python smoke
needs: ci-scope
if: github.event_name == 'push' || needs.ci-scope.outputs.examples_chat == 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6.0.2
- uses: actions/setup-node@v6.3.0
with:
node-version: 22
cache: npm
- name: Install uv
uses: astral-sh/setup-uv@v8.0.0
with:
python-version: '3.12'
- run: npm ci
- working-directory: examples/chat/python
run: uv sync
- run: npx nx run examples-chat-python:smoke --skip-nx-cache
examples-chat-e2e:
name: "examples/chat — e2e (${{ matrix.shard }}/4)"
needs: ci-scope
if: github.event_name == 'push' || needs.ci-scope.outputs.examples_chat == 'true'
runs-on: ubuntu-latest
timeout-minutes: 35
strategy:
fail-fast: false
matrix:
shard: [1, 2, 3, 4]
steps:
- uses: actions/checkout@v6.0.2
- uses: actions/setup-node@v6.3.0
with:
node-version: 22
cache: npm
- name: Install uv
uses: astral-sh/setup-uv@v8.0.0
with:
python-version: '3.12'
- run: npm ci
- working-directory: examples/chat/python
run: uv sync
- run: npx playwright install --with-deps chromium
- run: npx nx e2e examples-chat-angular --skip-nx-cache -- --shard=${{ matrix.shard }}/4
- name: Upload Playwright trace on failure
if: failure()
uses: actions/upload-artifact@v4
with:
name: examples-chat-e2e-trace-shard-${{ matrix.shard }}
path: |
test-results/
examples/chat/angular/e2e/test-results/
retention-days: 7
examples-chat-e2e-summary:
name: "examples/chat — e2e"
needs: [ci-scope, examples-chat-e2e]
if: always() && (github.event_name == 'push' || needs.ci-scope.outputs.examples_chat == 'true')
runs-on: ubuntu-latest
steps:
- name: Aggregate matrix outcome
run: |
if [[ "${{ needs.examples-chat-e2e.result }}" != "success" ]]; then
echo "Matrix outcome: ${{ needs.examples-chat-e2e.result }}"
exit 1
fi
echo "All examples-chat-e2e matrix expansions passed."
cockpit-e2e:
name: "Cockpit — e2e (${{ matrix.cap.angular }})"
needs: ci-scope
if: github.event_name == 'push' || needs.ci-scope.outputs.cockpit_e2e == 'true'
runs-on: ubuntu-latest
strategy:
fail-fast: false
max-parallel: 5
matrix:
cap:
- { angular: cockpit-langgraph-streaming-angular, python: cockpit/langgraph/streaming/python }
- { angular: cockpit-chat-tool-calls-angular, python: cockpit/chat/tool-calls/python }
- { angular: cockpit-chat-subagents-angular, python: cockpit/chat/subagents/python }
- { angular: cockpit-chat-interrupts-angular, python: cockpit/chat/interrupts/python }
- { angular: cockpit-chat-messages-angular, python: cockpit/chat/messages/python }
- { angular: cockpit-chat-input-angular, python: cockpit/chat/input/python }
- { angular: cockpit-chat-threads-angular, python: cockpit/chat/threads/python }
- { angular: cockpit-chat-timeline-angular, python: cockpit/chat/timeline/python }
- { angular: cockpit-chat-theming-angular, python: cockpit/chat/theming/python }
- { angular: cockpit-chat-generative-ui-angular, python: cockpit/chat/generative-ui/python }
- { angular: cockpit-chat-a2ui-angular, python: cockpit/chat/a2ui/python }
- { angular: cockpit-langgraph-persistence-angular, python: cockpit/langgraph/persistence/python }
- { angular: cockpit-langgraph-interrupts-angular, python: cockpit/langgraph/interrupts/python }
- { angular: cockpit-langgraph-memory-angular, python: cockpit/langgraph/memory/python }
- { angular: cockpit-langgraph-durable-execution-angular, python: cockpit/langgraph/durable-execution/python }
- { angular: cockpit-langgraph-subgraphs-angular, python: cockpit/langgraph/subgraphs/python }
- { angular: cockpit-langgraph-time-travel-angular, python: cockpit/langgraph/time-travel/python }
- { angular: cockpit-langgraph-deployment-runtime-angular, python: cockpit/langgraph/deployment-runtime/python }
- { angular: cockpit-deep-agents-planning-angular, python: cockpit/deep-agents/planning/python }
- { angular: cockpit-deep-agents-filesystem-angular, python: cockpit/deep-agents/filesystem/python }
- { angular: cockpit-deep-agents-subagents-angular, python: cockpit/deep-agents/subagents/python }
- { angular: cockpit-deep-agents-memory-angular, python: cockpit/deep-agents/memory/python }
- { angular: cockpit-deep-agents-skills-angular, python: cockpit/deep-agents/skills/python }
- { angular: cockpit-deep-agents-sandboxes-angular, python: cockpit/deep-agents/sandboxes/python }
steps:
- uses: actions/checkout@v6.0.2
- uses: actions/setup-node@v6.3.0
with:
node-version: 22
cache: npm
- name: Install uv
uses: astral-sh/setup-uv@v8.0.0
with:
python-version: '3.12'
- run: npm ci
- name: uv sync per-cap python
working-directory: ${{ matrix.cap.python }}
run: uv sync
- run: npx playwright install --with-deps chromium
- name: nx e2e ${{ matrix.cap.angular }}
run: npx nx e2e "${{ matrix.cap.angular }}" --skip-nx-cache
- name: Upload Playwright trace on failure
if: failure()
uses: actions/upload-artifact@v4
with:
name: cockpit-e2e-trace-${{ matrix.cap.angular }}
path: |
cockpit/**/angular/e2e/test-results/
retention-days: 7
cockpit-e2e-summary:
name: "Cockpit — e2e"
needs: [ci-scope, cockpit-e2e]
if: always() && (github.event_name == 'push' || needs.ci-scope.outputs.cockpit_e2e == 'true')
runs-on: ubuntu-latest
steps:
- name: Aggregate matrix outcome
run: |
if [[ "${{ needs.cockpit-e2e.result }}" != "success" ]]; then
echo "Matrix outcome: ${{ needs.cockpit-e2e.result }}"
exit 1
fi
echo "All cockpit-e2e matrix expansions passed."
website-e2e:
name: Website — e2e
needs: ci-scope
if: github.event_name == 'push' || needs.ci-scope.outputs.website_e2e == 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v6.0.2
- uses: actions/setup-node@v6.3.0
with:
node-version: 22
cache: npm
- run: npm ci
- run: npx playwright install --with-deps chromium
- run: npx nx e2e website --skip-nx-cache
required-pr-checks:
name: CI — required
needs:
- ci-scope
- library
- website
- cockpit
- cockpit-examples-build
- cockpit-smoke
- cockpit-secret-integration
- cockpit-deploy-smoke
- examples-chat-smoke
- examples-chat-e2e
- cockpit-e2e-summary
- website-e2e
- posthog-sync-plan
if: ${{ always() && github.event_name == 'pull_request' }}
runs-on: ubuntu-latest
steps:
- name: Verify scoped CI jobs
env:
RESULT_CI_SCOPE: ${{ needs.ci-scope.result }}
RESULT_LIBRARY: ${{ needs.library.result }}
RESULT_WEBSITE: ${{ needs.website.result }}
RESULT_COCKPIT: ${{ needs.cockpit.result }}
RESULT_COCKPIT_EXAMPLES: ${{ needs.cockpit-examples-build.result }}
RESULT_COCKPIT_SMOKE: ${{ needs.cockpit-smoke.result }}
RESULT_COCKPIT_SECRET: ${{ needs.cockpit-secret-integration.result }}
RESULT_COCKPIT_DEPLOY_SMOKE: ${{ needs.cockpit-deploy-smoke.result }}
RESULT_EXAMPLES_CHAT_SMOKE: ${{ needs.examples-chat-smoke.result }}
RESULT_EXAMPLES_CHAT_E2E: ${{ needs.examples-chat-e2e.result }}
RESULT_COCKPIT_E2E: ${{ needs.cockpit-e2e-summary.result }}
RESULT_WEBSITE_E2E: ${{ needs.website-e2e.result }}
RESULT_POSTHOG: ${{ needs.posthog-sync-plan.result }}
SCOPE_LIBRARY: ${{ needs.ci-scope.outputs.library }}
SCOPE_WEBSITE: ${{ needs.ci-scope.outputs.website }}
SCOPE_COCKPIT: ${{ needs.ci-scope.outputs.cockpit }}
SCOPE_COCKPIT_EXAMPLES: ${{ needs.ci-scope.outputs.cockpit_examples }}
SCOPE_COCKPIT_SMOKE: ${{ needs.ci-scope.outputs.cockpit_smoke }}
SCOPE_COCKPIT_SECRET: ${{ needs.ci-scope.outputs.cockpit_secret }}
SCOPE_COCKPIT_DEPLOY_SMOKE: ${{ needs.ci-scope.outputs.cockpit_deploy_smoke }}
SCOPE_EXAMPLES_CHAT: ${{ needs.ci-scope.outputs.examples_chat }}
SCOPE_COCKPIT_E2E: ${{ needs.ci-scope.outputs.cockpit_e2e }}
SCOPE_WEBSITE_E2E: ${{ needs.ci-scope.outputs.website_e2e }}
SCOPE_POSTHOG: ${{ needs.ci-scope.outputs.posthog }}
run: |
set -euo pipefail
failed=0
require_always() {
local label="$1"
local result="$2"
if [[ "$result" != "success" ]]; then
echo "::error::${label} finished with ${result}; refusing to report CI green."
failed=1
fi
}
require_scoped() {
local scope_key="$1"
local label="$2"
local result="$3"
local scoped="$4"
if [[ "$scoped" == "true" ]]; then
if [[ "$result" != "success" ]]; then
echo "::error::${label} is required by scope ${scope_key} but finished with ${result}."
failed=1
fi
return
fi
if [[ "$result" == "failure" || "$result" == "cancelled" ]]; then
echo "::error::${label} was not selected by scope ${scope_key} but finished with ${result}."
failed=1
fi
}
require_always "CI scope" "$RESULT_CI_SCOPE"
require_scoped "library" "Library — lint / test / build" "$RESULT_LIBRARY" "$SCOPE_LIBRARY"
require_scoped "website" "Website — lint / build" "$RESULT_WEBSITE" "$SCOPE_WEBSITE"
require_scoped "cockpit" "Cockpit — build / test" "$RESULT_COCKPIT" "$SCOPE_COCKPIT"
require_scoped "cockpit_examples" "Cockpit — build all examples" "$RESULT_COCKPIT_EXAMPLES" "$SCOPE_COCKPIT_EXAMPLES"
require_scoped "cockpit_smoke" "Cockpit — representative capability smoke" "$RESULT_COCKPIT_SMOKE" "$SCOPE_COCKPIT_SMOKE"
require_scoped "cockpit_secret" "Cockpit — secret-gated integration" "$RESULT_COCKPIT_SECRET" "$SCOPE_COCKPIT_SECRET"
require_scoped "cockpit_deploy_smoke" "Cockpit — deploy smoke dry-run" "$RESULT_COCKPIT_DEPLOY_SMOKE" "$SCOPE_COCKPIT_DEPLOY_SMOKE"
require_scoped "examples_chat" "examples/chat — python smoke" "$RESULT_EXAMPLES_CHAT_SMOKE" "$SCOPE_EXAMPLES_CHAT"
require_scoped "examples_chat" "examples/chat — e2e" "$RESULT_EXAMPLES_CHAT_E2E" "$SCOPE_EXAMPLES_CHAT"
require_scoped "cockpit_e2e" "Cockpit — e2e" "$RESULT_COCKPIT_E2E" "$SCOPE_COCKPIT_E2E"
require_scoped "website_e2e" "Website — e2e" "$RESULT_WEBSITE_E2E" "$SCOPE_WEBSITE_E2E"
require_scoped "posthog" "PostHog — dashboards-as-code drift check" "$RESULT_POSTHOG" "$SCOPE_POSTHOG"
if [[ "$failed" -ne 0 ]]; then
exit 1
fi
echo "All scoped PR checks passed."
deploy:
name: Deploy → Vercel
needs:
[
library,
website,
cockpit,
cockpit-examples-build,
cockpit-smoke,
cockpit-secret-integration,
cockpit-deploy-smoke,
examples-chat-smoke,
examples-chat-e2e,
cockpit-e2e-summary,
website-e2e,
]
runs-on: ubuntu-latest
# Only deploy on pushes to main, not on pull requests
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
steps:
- uses: actions/checkout@v6.0.2
with:
fetch-depth: 0
- name: Detect deploy-relevant changes
id: deploy_preflight
run: |
base_sha="${{ github.event.before }}"
head_sha="${{ github.sha }}"
if [ -z "$base_sha" ] || [ "$base_sha" = "0000000000000000000000000000000000000000" ]; then
base_sha="$(git rev-parse "$head_sha^")"
fi
if ! git cat-file -e "$base_sha^{commit}" 2>/dev/null; then
git fetch --no-tags origin "$base_sha"
fi
changed_files="$(git diff --name-only "$base_sha" "$head_sha")"
deploy_relevant=false
if printf '%s\n' "$changed_files" | grep -E '^(\.github/workflows/ci\.yml|vercel\.(json|cockpit\.json|examples\.json)|apps/(website|cockpit)/.*|cockpit/.*|examples/chat/.*|libs/.*|scripts/(assemble-examples|deploy-smoke|demo-middleware|langgraph-proxy|rate-limit)\.ts|scripts/assemble-demo\.ts)$' >/dev/null; then
deploy_relevant=true
fi
echo "relevant=$deploy_relevant" >> "$GITHUB_OUTPUT"
if [ "$deploy_relevant" != "true" ]; then
echo "::notice::No deploy-relevant files changed; skipping Vercel dependency setup."
fi
# ── Angular examples deploy ──────────────────────────────────────────
- name: Check if examples changed
id: examples_changed
run: |
base_sha="${{ github.event.before }}"
head_sha="${{ github.sha }}"
if [ -z "$base_sha" ] || [ "$base_sha" = "0000000000000000000000000000000000000000" ]; then
base_sha="$(git rev-parse "$head_sha^")"
fi
changed_files="$(git diff --name-only "$base_sha" "$head_sha")"
examples_changed=false
if printf '%s\n' "$changed_files" | grep -E '^cockpit/.*/angular/' >/dev/null; then
examples_changed=true
fi
if printf '%s\n' "$changed_files" | grep -E '^(vercel\.examples\.json|scripts/assemble-examples\.ts)$' >/dev/null; then
examples_changed=true
fi
# Any libs/ change retriggers examples deploy. Previous hand-maintained
# allow-list silently broke whenever a new lib was added; cost of a
# spurious example rebuild is far cheaper than a missed deploy.
if printf '%s\n' "$changed_files" | grep -E '^libs/' >/dev/null; then
examples_changed=true
fi
echo "changed=$examples_changed" >> "$GITHUB_OUTPUT"
- uses: actions/setup-node@v6.3.0
if: steps.deploy_preflight.outputs.relevant == 'true' || steps.examples_changed.outputs.changed == 'true'
with:
node-version: 22
cache: npm
# Required GitHub secrets (Settings → Secrets and variables → Actions):
# VERCEL_TOKEN — vercel.com/account/tokens
# VERCEL_ORG_ID — Vercel team id
# VERCEL_WEBSITE_PROJECT_ID — website project id
# VERCEL_COCKPIT_PROJECT_ID — cockpit project id
# VERCEL_EXAMPLES_PROJECT_ID — examples project id
- if: steps.deploy_preflight.outputs.relevant == 'true' || steps.examples_changed.outputs.changed == 'true'
run: npm ci
- name: Resolve deploy targets
if: steps.deploy_preflight.outputs.relevant == 'true'
id: affected
run: |
base_sha="${{ github.event.before }}"
head_sha="${{ github.sha }}"
if [ -z "$base_sha" ] || [ "$base_sha" = "0000000000000000000000000000000000000000" ]; then
base_sha="$(git rev-parse "$head_sha^")"
fi
if ! git cat-file -e "$base_sha^{commit}" 2>/dev/null; then
git fetch --no-tags origin "$base_sha"
fi
affected_projects="$(npx nx show projects --affected --base="$base_sha" --head="$head_sha")"
changed_files="$(git diff --name-only "$base_sha" "$head_sha")"
website_changed=false
cockpit_changed=false
if printf '%s\n' "$affected_projects" | grep -Fx 'website' >/dev/null; then
website_changed=true
fi
if printf '%s\n' "$affected_projects" | grep -Fx 'cockpit' >/dev/null; then
cockpit_changed=true
fi
if printf '%s\n' "$changed_files" | grep -E '^(\.github/workflows/ci\.yml|vercel\.json)$' >/dev/null; then
website_changed=true
fi
if printf '%s\n' "$changed_files" | grep -E '^(\.github/workflows/ci\.yml|vercel\.cockpit\.json)$' >/dev/null; then
cockpit_changed=true
fi
echo "website=$website_changed" >> "$GITHUB_OUTPUT"
echo "cockpit=$cockpit_changed" >> "$GITHUB_OUTPUT"
- name: Install Playwright browsers
if: steps.affected.outputs.website == 'true'
run: npx playwright install --with-deps chromium
- name: Prepare website Vercel project
if: steps.affected.outputs.website == 'true'
run: |
mkdir -p .vercel
cat > .vercel/project.json <<EOF
{"projectId":"${{ secrets.VERCEL_WEBSITE_PROJECT_ID }}","orgId":"${{ secrets.VERCEL_ORG_ID }}","projectName":"threadplane"}
EOF
npx vercel pull --yes --environment=production --token=${{ secrets.VERCEL_TOKEN }}
rm -rf .vercel/output
- name: Build and deploy website to Vercel (production)
if: steps.affected.outputs.website == 'true'
id: deploy_website
run: |
npx vercel build --prod --token=${{ secrets.VERCEL_TOKEN }}
url=$(npx vercel deploy --prebuilt --archive=tgz --prod --yes --token=${{ secrets.VERCEL_TOKEN }} | tail -n 1)
echo "deployment_url=$url" >> "$GITHUB_OUTPUT"
- name: Verify deployed website
if: steps.affected.outputs.website == 'true'
run: npx nx e2e website --skip-nx-cache
env:
BASE_URL: https://threadplane.ai
- name: Prepare cockpit Vercel project
if: steps.affected.outputs.cockpit == 'true'
run: |
mkdir -p .vercel
cat > .vercel/project.json <<EOF
{"projectId":"${{ secrets.VERCEL_COCKPIT_PROJECT_ID }}","orgId":"${{ secrets.VERCEL_ORG_ID }}","projectName":"threadplane-cockpit"}
EOF
npx vercel pull --yes --environment=production --token=${{ secrets.VERCEL_TOKEN }}
rm -rf .vercel/output
- name: Build and deploy cockpit to Vercel (production)
if: steps.affected.outputs.cockpit == 'true'
id: deploy_cockpit
run: |
npx vercel build --prod --local-config vercel.cockpit.json --token=${{ secrets.VERCEL_TOKEN }}
url=$(npx vercel deploy --prebuilt --archive=tgz --prod --yes --token=${{ secrets.VERCEL_TOKEN }} | tail -n 1)
echo "deployment_url=$url" >> "$GITHUB_OUTPUT"
- name: Verify deployed cockpit
if: steps.affected.outputs.cockpit == 'true'
run: |
npx tsx apps/cockpit/scripts/deploy-smoke.ts --url https://cockpit.threadplane.ai --retries 20 --retry-delay-ms 5000
- name: Build and assemble Angular examples
if: steps.examples_changed.outputs.changed == 'true'
run: npx tsx scripts/assemble-examples.ts
- name: Deploy Angular examples to Vercel (production)
if: steps.examples_changed.outputs.changed == 'true'
working-directory: deploy/examples
run: |
mkdir -p .vercel
cat > .vercel/project.json <<EOF
{"projectId":"${{ secrets.VERCEL_EXAMPLES_PROJECT_ID }}","orgId":"${{ secrets.VERCEL_ORG_ID }}","projectName":"threadplane-examples"}
EOF
npx vercel pull --yes --environment=production --token=${{ secrets.VERCEL_TOKEN }}
npx vercel deploy --prebuilt --prod --yes --token=${{ secrets.VERCEL_TOKEN }}
demo-deploy:
name: Canonical demo → Vercel
needs: [examples-chat-smoke, examples-chat-e2e]
runs-on: ubuntu-latest
if: ${{ always() && !cancelled() && github.ref == 'refs/heads/main' && github.event_name == 'push' }}
steps:
- name: Require demo prerequisite jobs
run: |
if [ "${{ needs.examples-chat-smoke.result }}" != "success" ]; then
echo "::error::examples/chat — python smoke finished with ${{ needs.examples-chat-smoke.result }}; refusing to deploy the canonical demo."
exit 1
fi
if [ "${{ needs.examples-chat-e2e.result }}" != "success" ]; then
echo "::error::examples/chat — e2e finished with ${{ needs.examples-chat-e2e.result }}; refusing to deploy the canonical demo."
exit 1
fi
- uses: actions/checkout@v6.0.2
- uses: actions/setup-node@v6.3.0
with:
node-version: 22
cache: npm
- run: npm ci
- name: Build and assemble canonical demo
run: npx tsx scripts/assemble-demo.ts
- name: Deploy canonical demo to Vercel (production)
working-directory: deploy/demo
run: |
mkdir -p .vercel
cat > .vercel/project.json <<EOF
{"projectId":"${{ secrets.VERCEL_DEMO_PROJECT_ID }}","orgId":"${{ secrets.VERCEL_ORG_ID }}","projectName":"threadplane-demo"}
EOF
npx vercel pull --yes --environment=production --token=${{ secrets.VERCEL_TOKEN }}
npx vercel deploy --prebuilt --prod --yes --token=${{ secrets.VERCEL_TOKEN }}
- name: Verify canonical demo build stamp
env:
DEMO_URL: https://demo.threadplane.ai
EXPECTED_SHA: ${{ github.sha }}
run: |
node <<'NODE'
const { setTimeout: sleep } = require('node:timers/promises');
async function main() {
const demoUrl = process.env.DEMO_URL;
const expectedSha = process.env.EXPECTED_SHA;
let last = 'no response yet';
for (let attempt = 1; attempt <= 20; attempt += 1) {
try {
const response = await fetch(`${demoUrl}/__build.json?t=${Date.now()}`);
last = `HTTP ${response.status}`;
if (response.ok) {
const metadata = await response.json();
last = JSON.stringify(metadata);
if (metadata.sha === expectedSha) {
console.log(`Canonical demo is serving ${expectedSha}.`);
return;
}
}
} catch (error) {
last = error instanceof Error ? error.message : String(error);
}
console.log(`Waiting for canonical demo stamp ${expectedSha}; attempt ${attempt}/20. Last: ${last}`);
await sleep(5000);
}
throw new Error(`Canonical demo did not serve build stamp ${expectedSha}. Last: ${last}`);
}
main().catch((error) => {
console.error(`::error::${error instanceof Error ? error.message : String(error)}`);
process.exit(1);
});
NODE
minting-deploy:
name: Minting service deploy
needs: [library]
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
steps:
- uses: actions/checkout@v6.0.2
- uses: actions/setup-node@v6.3.0
with:
node-version: 22
cache: npm
- run: npm ci
- name: Deploy minting service to Vercel (production)
working-directory: apps/minting-service
run: |
mkdir -p .vercel
cat > .vercel/project.json <<EOF
{"projectId":"${{ secrets.VERCEL_MINTING_PROJECT_ID }}","orgId":"${{ secrets.VERCEL_ORG_ID }}","projectName":"threadplane-minting-service"}
EOF
npx vercel pull --yes --environment=production --token=${{ secrets.VERCEL_TOKEN }}
npx vercel build --prod --token=${{ secrets.VERCEL_TOKEN }}
npx vercel deploy --prebuilt --prod --yes --token=${{ secrets.VERCEL_TOKEN }}
- name: Verify minting service health
env:
MINTING_URL: https://mint.threadplane.ai
run: |
for i in 1 2 3 4 5; do
if curl -sf -o /dev/null "$MINTING_URL/api/health"; then
echo "Minting service is healthy."
exit 0
fi
echo "Waiting for minting service; attempt $i/5..."
sleep 5
done
echo "::error::Minting service did not respond at $MINTING_URL/api/health"
exit 1
production-smoke:
name: Production smoke
needs: [deploy, demo-deploy]
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
steps:
- uses: actions/checkout@v6.0.2
- uses: actions/setup-node@v6.3.0
with:
node-version: 22
cache: npm
- run: npm ci
- name: Verify shared LangGraph backend
run: npx tsx scripts/verify-shared-deployment.ts
env:
LANGSMITH_API_KEY: ${{ secrets.LANGSMITH_API_KEY }}
- run: npx playwright install --with-deps chromium
- name: Run production smoke tests
run: npx playwright test apps/cockpit/e2e/production-smoke.spec.ts --reporter=list
env:
BASE_URL: https://cockpit.threadplane.ai
EXAMPLES_URL: https://examples.threadplane.ai
DEMO_URL: https://demo.threadplane.ai
OPENAI_API_KEY: ${{ secrets.OPENAI_API_KEY }}
posthog-sync-plan:
name: PostHog — dashboards-as-code drift check
needs: ci-scope
if: github.event_name == 'push' || needs.ci-scope.outputs.posthog == 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Detect PostHog-relevant changes
id: posthog_preflight
run: |
if [ "${{ github.event_name }}" = "push" ]; then
base_sha="${{ github.event.before }}"
head_sha="${{ github.sha }}"
if [ -z "$base_sha" ] || [ "$base_sha" = "0000000000000000000000000000000000000000" ]; then
base_sha="$(git rev-parse "$head_sha^")"
fi
else
base_sha=$(git merge-base origin/main HEAD)
head_sha=$(git rev-parse HEAD)
fi
changed_files="$(git diff --name-only "$base_sha" "$head_sha")"
posthog_relevant=false
if printf '%s\n' "$changed_files" | grep -E '^(tools/posthog/|package(-lock)?\.json|nx\.json|tsconfig\.base\.json|\.github/workflows/ci\.yml)$' >/dev/null; then
posthog_relevant=true
fi
echo "relevant=$posthog_relevant" >> "$GITHUB_OUTPUT"
if [ "$posthog_relevant" != "true" ]; then
echo "::notice::No PostHog tooling files changed — skipping dependency setup and drift check."
fi
- uses: actions/setup-node@v4
if: steps.posthog_preflight.outputs.relevant == 'true'
with:
node-version: '20'
cache: 'npm'
- if: steps.posthog_preflight.outputs.relevant == 'true'
run: npm ci
- name: Detect affected
if: steps.posthog_preflight.outputs.relevant == 'true'
id: affected
run: |
if [ "${{ github.event_name }}" = "push" ]; then
base_sha="${{ github.event.before }}"
head_sha="${{ github.sha }}"
if [ -z "$base_sha" ] || [ "$base_sha" = "0000000000000000000000000000000000000000" ]; then
base_sha="$(git rev-parse "$head_sha^")"
fi
else
base_sha=$(git merge-base origin/main HEAD)
head_sha=$(git rev-parse HEAD)
fi
affected="$(npx nx show projects --affected --base=$base_sha --head=$head_sha)"
if printf '%s\n' "$affected" | grep -Fx 'posthog-tools' >/dev/null; then
echo "is_affected=yes" >> "$GITHUB_OUTPUT"
else
echo "is_affected=no" >> "$GITHUB_OUTPUT"
echo "::notice::posthog-tools not in affected projects — skipping drift check."
fi
- name: posthog:sync --plan
if: steps.affected.outputs.is_affected == 'yes'
env:
POSTHOG_PERSONAL_API_KEY: ${{ secrets.POSTHOG_PERSONAL_API_KEY_READONLY }}
POSTHOG_HOST: https://us.i.posthog.com
POSTHOG_PROJECT_ID: ${{ secrets.POSTHOG_PROJECT_ID }}
run: |
if [ -z "$POSTHOG_PERSONAL_API_KEY" ]; then
echo "::notice::POSTHOG_PERSONAL_API_KEY_READONLY not set — soft skip for contributor PRs."
exit 0
fi
npx nx run posthog-tools:sync:plan