This repository was archived by the owner on May 24, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 31
822 lines (722 loc) · 38.8 KB
/
Copy pathpolypilot-integration.yml
File metadata and controls
822 lines (722 loc) · 38.8 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
name: "PolyPilot Integration Test"
run-name: "PolyPilot Integration Test${{ inputs.pr_number && format(' — PR #{0}', inputs.pr_number) || '' }}"
on:
workflow_dispatch:
inputs:
pr_number:
description: 'PR number to test (optional — posts results as comment)'
required: false
type: number
ref:
description: 'Git ref to build (branch or SHA). Defaults to main.'
required: false
type: string
default: ''
scenario:
description: 'Test scenario to run (smoke, full, scheduled-tasks)'
required: false
type: choice
options:
- smoke
- full
- scheduled-tasks
default: smoke
push:
branches:
- 'feature/polypilot-ci-integration'
paths:
- '.github/workflows/polypilot-integration.yml'
- 'PolyPilot.Gtk/**'
- 'PolyPilot/**'
jobs:
# ─── Linux/GTK ───────────────────────────────────────────────
integration-linux:
runs-on: ubuntu-latest
timeout-minutes: 30
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: ${{ inputs.ref || github.sha }}
- name: Setup .NET 10
uses: actions/setup-dotnet@v5
with:
dotnet-version: '10.0.x'
dotnet-quality: 'preview'
- name: Install GTK4 dependencies
run: |
sudo apt-get update
sudo apt-get install -y libgtk-4-dev libadwaita-1-dev libwebkitgtk-6.0-dev xvfb
- name: Install MAUI workload
run: dotnet workload install maui-android
- name: Install MauiDevFlow CLI
run: |
dotnet tool install --global Microsoft.Maui.Cli \
--add-source https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet10/nuget/v3/index.json \
--prerelease 2>&1 || {
echo "Install returned non-zero, checking if already installed..."
maui --version || { echo "❌ MauiDevFlow CLI not available"; exit 1; }
}
echo "$HOME/.dotnet/tools" >> $GITHUB_PATH
- name: Build PolyPilot.Gtk (Debug — includes MauiDevFlow)
run: |
dotnet build PolyPilot.Gtk/PolyPilot.Gtk.csproj \
-c Debug \
--disable-build-servers \
-p:UseSharedCompilation=false \
-nodeReuse:false
- name: Find built binary
id: find-binary
run: |
echo "=== Build output ==="
ls -la PolyPilot.Gtk/bin/Debug/net10.0/ 2>/dev/null | head -20 || true
# AssemblyName in PolyPilot.Gtk.csproj is "PolyPilot" (not "PolyPilot.Gtk")
BINARY=$(find PolyPilot.Gtk/bin/Debug -name "PolyPilot" -type f -executable 2>/dev/null | head -1)
if [ -z "$BINARY" ]; then
# On Linux, the native executable may not exist — use dotnet exec with the DLL
DLL=$(find PolyPilot.Gtk/bin/Debug -name "PolyPilot.dll" -type f 2>/dev/null | head -1)
if [ -n "$DLL" ]; then
echo "No native executable found, using dotnet exec: $DLL"
BINARY="dotnet $DLL"
fi
fi
if [ -z "$BINARY" ]; then
echo "❌ No executable binary found in build output"
find PolyPilot.Gtk/bin/Debug -type f 2>/dev/null | head -20
exit 1
fi
echo "binary=$BINARY" >> $GITHUB_OUTPUT
echo "Found binary: $BINARY"
- name: Launch PolyPilot under xvfb
run: |
echo "Starting PolyPilot.Gtk under virtual display..."
export DISPLAY=:99
Xvfb :99 -screen 0 1920x1080x24 &
XVFB_PID=$!
echo "XVFB_PID=$XVFB_PID" >> $GITHUB_ENV
sleep 2
# Launch PolyPilot in background, capture all output
${{ steps.find-binary.outputs.binary }} > /tmp/polypilot-stdout.log 2>/tmp/polypilot-stderr.log &
APP_PID=$!
echo "APP_PID=$APP_PID" >> $GITHUB_ENV
echo "PolyPilot launched with PID $APP_PID"
# Wait for app + DevFlow agent readiness (poll instead of fixed sleep)
echo "Waiting for PolyPilot to start..."
for i in $(seq 1 60); do
if ! kill -0 $APP_PID 2>/dev/null; then
echo "❌ PolyPilot crashed during startup"
echo "=== stdout ===" && cat /tmp/polypilot-stdout.log || true
echo "=== stderr ===" && cat /tmp/polypilot-stderr.log || true
exit 1
fi
if curl -s --max-time 2 http://localhost:9223/api/v1/agent/status > /dev/null 2>&1 || \
curl -s --max-time 2 http://localhost:9223/api/status > /dev/null 2>&1; then
echo "✅ PolyPilot ready after ${i}s"
break
fi
if [ "$i" = "60" ]; then
echo "⚠️ Timed out waiting for DevFlow agent after 60s — continuing with port scan"
fi
sleep 1
done
# Verify process is still running
if kill -0 $APP_PID 2>/dev/null; then
echo "✅ PolyPilot is running"
else
echo "❌ PolyPilot crashed on startup"
echo "=== stdout ===" && cat /tmp/polypilot-stdout.log || true
echo "=== stderr ===" && cat /tmp/polypilot-stderr.log || true
exit 1
fi
# Show app output so far
echo "=== App stdout (first 50 lines) ==="
head -50 /tmp/polypilot-stdout.log || true
echo "=== App stderr ==="
cat /tmp/polypilot-stderr.log || true
- name: Discover MauiDevFlow agent port
id: devflow
run: |
export DISPLAY=:99
echo "Waiting for MauiDevFlow agent..."
# Check for .mauidevflow file (agent writes port here when broker unavailable)
echo "=== Checking for .mauidevflow files ==="
find / -name '.mauidevflow' -maxdepth 5 2>/dev/null || true
find /home -name '.mauidevflow' 2>/dev/null || true
find /tmp -name '.mauidevflow' -o -name 'mauidevflow*' 2>/dev/null || true
# Try broker-based discovery
maui devflow wait --timeout 30 --json > /tmp/devflow-wait.json 2>&1 || true
echo "=== devflow wait output ===" && cat /tmp/devflow-wait.json || true
# Try list
echo "=== devflow list ==="
maui devflow list --json 2>&1 || true
maui devflow list 2>&1 || true
# Port scan
echo "=== Scanning all listening ports ==="
ss -tlnp 2>/dev/null || true
# Try common DevFlow ports
AGENT_PORT=""
for port in 9223 9224 9225 9226 9227 9228 9229 9230 5000 5001 8080; do
if curl -s --max-time 2 http://localhost:$port/api/v1/agent/status > /dev/null 2>&1 || \
curl -s --max-time 2 http://localhost:$port/api/status > /dev/null 2>&1; then
AGENT_PORT=$port
echo "✅ Found agent on port $port"
curl -s http://localhost:$port/api/v1/agent/status 2>/dev/null || \
curl -s http://localhost:$port/api/status
break
fi
done
if [ -z "$AGENT_PORT" ]; then
# Try discovering from app stdout (agent may log its port)
AGENT_PORT=$(grep -oP 'listening on.*?:(\d+)' /tmp/polypilot-stdout.log 2>/dev/null | grep -oP '\d+$' | head -1 || true)
if [ -n "$AGENT_PORT" ]; then
echo "✅ Found agent port from stdout: $AGENT_PORT"
fi
fi
if [ -z "$AGENT_PORT" ]; then
echo "⚠️ Could not discover agent port"
echo "App is running: $(kill -0 $APP_PID 2>/dev/null && echo 'yes' || echo 'no')"
echo "agent_port=" >> $GITHUB_OUTPUT
else
echo "✅ MauiDevFlow agent on port $AGENT_PORT"
echo "agent_port=$AGENT_PORT" >> $GITHUB_OUTPUT
fi
- name: "Smoke Test: Discover API routes"
if: steps.devflow.outputs.agent_port != ''
run: |
PORT=${{ steps.devflow.outputs.agent_port }}
echo "=== Agent Status ==="
curl -s http://localhost:$PORT/api/v1/agent/status | python3 -m json.tool 2>/dev/null || \
curl -s http://localhost:$PORT/api/status | python3 -m json.tool
echo "=== Trying common routes ==="
for route in \
/api/v1/agent/status /api/v1/agent/capabilities \
/api/v1/ui/tree /api/v1/ui/screenshot \
/api/v1/webview/contexts /api/v1/webview/evaluate \
/api/v1/webview/dom \
/api/status /api/tree /api/screenshot \
/api/cdp /api/cdp/status \
/api/logs /api/log \
/ /api; do
RESULT=$(curl -s --max-time 2 -o /dev/null -w "%{http_code}" http://localhost:$PORT$route 2>/dev/null)
if [ "$RESULT" != "000" ] && [ "$RESULT" != "404" ]; then
echo " $route → HTTP $RESULT"
if [ "$RESULT" = "200" ]; then
echo " $(curl -s --max-time 2 http://localhost:$PORT$route | head -c 500)"
fi
fi
done
- name: "Smoke Test: Screenshot via status endpoint"
if: steps.devflow.outputs.agent_port != ''
run: |
PORT=${{ steps.devflow.outputs.agent_port }}
# The screenshot endpoint might return binary data (try v1 first, fallback to old)
curl -s http://localhost:$PORT/api/v1/ui/screenshot -o /tmp/polypilot-ci-screenshot.png 2>&1 || \
curl -s http://localhost:$PORT/api/screenshot -o /tmp/polypilot-ci-screenshot.png 2>&1 || true
if [ -f /tmp/polypilot-ci-screenshot.png ] && [ $(wc -c < /tmp/polypilot-ci-screenshot.png) -gt 100 ]; then
echo "✅ Screenshot saved ($(wc -c < /tmp/polypilot-ci-screenshot.png) bytes)"
else
echo "Screenshot too small or not found, trying other paths..."
curl -s http://localhost:$PORT/api/screenshot -o /tmp/polypilot-ci-screenshot.png 2>&1 || true
curl -s http://localhost:$PORT/api/v1/ui/screenshot -o /tmp/polypilot-ci-screenshot2.png 2>&1 || true
ls -la /tmp/polypilot-ci-screenshot*.png 2>/dev/null || echo "No screenshots captured"
fi
- name: "Smoke Test: CLI with verbose"
if: steps.devflow.outputs.agent_port != ''
run: |
export DISPLAY=:99
PORT=${{ steps.devflow.outputs.agent_port }}
echo "=== Trying CLI with verbose ==="
maui devflow MAUI status --agent-port $PORT --verbose 2>&1 || echo "CLI status failed"
echo "=== Trying CLI tree ==="
maui devflow MAUI tree --depth 3 --agent-port $PORT --verbose 2>&1 || echo "CLI tree failed"
- name: "Diagnostics (if agent not found)"
if: steps.devflow.outputs.agent_port == ''
run: |
echo "=== Process list ==="
ps aux | grep -i polypilot || true
echo "=== Listening ports ==="
ss -tlnp 2>/dev/null || netstat -tlnp 2>/dev/null || true
echo "=== App stderr (if captured) ==="
cat /tmp/polypilot-stderr.log 2>/dev/null || echo "No stderr log"
- name: "Feature Test: Scheduled Tasks"
if: steps.devflow.outputs.agent_port != '' && (inputs.scenario == 'scheduled-tasks' || inputs.scenario == 'full')
run: |
PORT=${{ steps.devflow.outputs.agent_port }}
echo "Running scheduled tasks integration tests via dotnet test"
if [ ! -d "PolyPilot.IntegrationTests" ]; then
echo "Fetching integration tests from main..."
git fetch origin main --depth=1
git checkout origin/main -- PolyPilot.IntegrationTests/
fi
POLYPILOT_AGENT_PORT=$PORT dotnet test PolyPilot.IntegrationTests \
--filter "Category=ScheduledTasks" \
--nologo --verbosity normal 2>&1 || true
- name: Upload screenshot
if: always()
uses: actions/upload-artifact@v4
with:
name: polypilot-screenshot-linux
path: /tmp/polypilot-ci-screenshot.png
if-no-files-found: ignore
- name: Upload app logs
if: always()
uses: actions/upload-artifact@v4
with:
name: polypilot-logs-linux
path: |
/tmp/polypilot-stdout.log
/tmp/polypilot-stderr.log
/tmp/devflow-wait.json
if-no-files-found: ignore
- name: Cleanup
if: always()
run: |
kill $APP_PID 2>/dev/null || true
kill $XVFB_PID 2>/dev/null || true
# ─── Mac Catalyst ────────────────────────────────────────────
integration-maccatalyst:
runs-on: macos-15
timeout-minutes: 30
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: ${{ inputs.ref || github.sha }}
- name: Setup .NET 10
uses: actions/setup-dotnet@v5
with:
dotnet-version: '10.0.x'
dotnet-quality: 'preview'
- name: Select Xcode
run: sudo xcode-select -p
- name: Install MAUI workload
run: dotnet workload install maui
- name: Install MauiDevFlow CLI
run: |
dotnet tool install --global Microsoft.Maui.Cli \
--add-source https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet10/nuget/v3/index.json \
--prerelease 2>&1 || {
echo "Install returned non-zero, checking if already installed..."
maui --version || { echo "❌ MauiDevFlow CLI not available"; exit 1; }
}
echo "$HOME/.dotnet/tools" >> $GITHUB_PATH
- name: Build PolyPilot (Mac Catalyst Debug)
run: |
dotnet build PolyPilot/PolyPilot.csproj \
-f net10.0-maccatalyst \
-c Debug \
--disable-build-servers \
-p:UseSharedCompilation=false \
-p:ValidateXcodeVersion=false \
-p:MtouchLink=SdkOnly \
-nodeReuse:false
- name: Find app bundle
id: find-app
run: |
APP=$(find PolyPilot/bin/Debug/net10.0-maccatalyst -name "*.app" -type d | head -1)
echo "app=$APP" >> $GITHUB_OUTPUT
echo "Found app: $APP"
ls -la "$APP/Contents/MacOS/" || true
- name: Launch PolyPilot (Mac Catalyst)
env:
COPILOT_GITHUB_TOKEN: ${{ secrets.COPILOT_GITHUB_TOKEN }}
run: |
BINARY="${{ steps.find-app.outputs.app }}/Contents/MacOS/PolyPilot"
# Pass token via env — PolyPilot's ServerManager reads COPILOT_GITHUB_TOKEN
# and forwards it to the headless copilot process.
# The token is masked by GitHub Actions (never appears in logs).
"$BINARY" > /tmp/polypilot-stdout.log 2>/tmp/polypilot-stderr.log &
APP_PID=$!
echo "APP_PID=$APP_PID" >> $GITHUB_ENV
echo "PolyPilot launched with PID $APP_PID"
# Wait for app + DevFlow agent readiness (poll instead of fixed sleep)
echo "Waiting for PolyPilot to start..."
for i in $(seq 1 60); do
if ! kill -0 $APP_PID 2>/dev/null; then
echo "❌ PolyPilot crashed during startup"
cat /tmp/polypilot-stderr.log || true
exit 1
fi
if curl -s --max-time 2 http://localhost:9223/api/v1/agent/status > /dev/null 2>&1 || \
curl -s --max-time 2 http://localhost:9223/api/status > /dev/null 2>&1; then
echo "✅ PolyPilot ready after ${i}s"
break
fi
if [ "$i" = "60" ]; then
echo "⚠️ Timed out waiting for DevFlow agent after 60s"
echo "App is still running — continuing with port scan"
fi
sleep 1
done
if kill -0 $APP_PID 2>/dev/null; then
echo "✅ PolyPilot is running"
else
echo "❌ PolyPilot crashed"
cat /tmp/polypilot-stderr.log || true
exit 1
fi
- name: Discover DevFlow agent
id: devflow
run: |
AGENT_PORT=""
for port in 9223 9224 9225 9226 9227 9228 9229 9230; do
if curl -s --max-time 2 http://localhost:$port/api/v1/agent/status > /dev/null 2>&1 || \
curl -s --max-time 2 http://localhost:$port/api/status > /dev/null 2>&1; then
AGENT_PORT=$port
echo "✅ Found agent on port $port"
curl -s http://localhost:$port/api/v1/agent/status 2>/dev/null || \
curl -s http://localhost:$port/api/status | python3 -m json.tool
break
fi
done
echo "agent_port=${AGENT_PORT}" >> $GITHUB_OUTPUT
- name: "Smoke: Status + Tree + Screenshot"
if: steps.devflow.outputs.agent_port != ''
run: |
PORT=${{ steps.devflow.outputs.agent_port }}
echo "=== Status ===" && (curl -s http://localhost:$PORT/api/v1/agent/status 2>/dev/null || curl -s http://localhost:$PORT/api/status) | python3 -m json.tool
echo "=== Tree ===" && (curl -s http://localhost:$PORT/api/v1/ui/tree 2>/dev/null || curl -s http://localhost:$PORT/api/tree) | python3 -c "import sys,json; d=json.load(sys.stdin); print(json.dumps(d[:3], indent=2))" 2>/dev/null || (curl -s http://localhost:$PORT/api/v1/ui/tree 2>/dev/null || curl -s http://localhost:$PORT/api/tree) | head -50
echo "=== Screenshot ===" && curl -s http://localhost:$PORT/api/v1/ui/screenshot -o /tmp/polypilot-ci-screenshot.png 2>/dev/null || curl -s http://localhost:$PORT/api/screenshot -o /tmp/polypilot-ci-screenshot.png && echo "✅ $(wc -c < /tmp/polypilot-ci-screenshot.png) bytes"
- name: "Copilot: Check headless server"
run: |
echo "=== Checking for copilot headless server ==="
# PolyPilot in Persistent mode auto-starts copilot on port 4321
for port in 4321 4322; do
if curl -s --max-time 3 http://127.0.0.1:$port/ > /dev/null 2>&1; then
echo "✅ Copilot server responding on port $port"
else
echo "⚠️ Port $port not responding (may use TCP not HTTP)"
fi
done
# Check for copilot process
echo "=== Copilot processes ==="
ps aux | grep -i copilot | grep -v grep || echo "No copilot processes found"
# Check PID file
echo "=== PID file ==="
cat ~/.polypilot/server.pid 2>/dev/null || echo "No PID file"
# Check app logs for server start
echo "=== Server startup in logs ==="
grep -i 'server\|headless\|persistent\|port\|4321\|copilot' /tmp/polypilot-stdout.log 2>/dev/null | head -20 || true
- name: "Copilot: Verify session via DevFlow"
if: steps.devflow.outputs.agent_port != ''
run: |
PORT=${{ steps.devflow.outputs.agent_port }}
echo "=== Visual tree ==="
(curl -s http://localhost:$PORT/api/v1/ui/tree 2>/dev/null || curl -s http://localhost:$PORT/api/tree) | python3 -c "
import sys, json
tree = json.load(sys.stdin)
def walk(nodes, depth=0):
for n in nodes:
prefix = ' ' * depth
ntype = n.get('type','?')
aid = n.get('automationId','')
text = n.get('text','')[:50]
nid = n.get('id','')
print(f'{prefix}{ntype} [{nid}]' + (f' aid={aid}' if aid else '') + (f' text={text}' if text else ''))
if 'children' in n: walk(n['children'], depth+1)
walk(tree)
" 2>/dev/null | head -30 || echo "Tree parse failed"
- name: "Copilot: Create session via PolyPilot UI"
if: steps.devflow.outputs.agent_port != ''
run: |
PORT=${{ steps.devflow.outputs.agent_port }}
EVAL_URL="http://localhost:$PORT/api/v1/webview/evaluate"
EVAL_URL_FALLBACK="http://localhost:$PORT/api/cdp"
# Evaluate JS via DevFlow preview.7 API (falls back to old CDP route)
webview_eval() {
local expr="$1"
local payload
# v1 endpoint uses CDP command passthrough: {"method":"Runtime.evaluate","params":{"expression":"..."}}
payload=$(python3 -c "import json,sys; print(json.dumps({'method':'Runtime.evaluate','params':{'expression':sys.argv[1]}}))" "$expr")
local result
result=$(curl -s -X POST "$EVAL_URL" -H "Content-Type: application/json" -d "$payload" 2>/dev/null)
if [ $? -eq 0 ] && echo "$result" | python3 -c "import sys,json; d=json.load(sys.stdin); exit(1 if 'error' in d and 'Route not found' in str(d.get('error','')) else 0)" 2>/dev/null; then
echo "$result"
else
# Fallback to old CDP route
curl -s -X POST "$EVAL_URL_FALLBACK" -H "Content-Type: application/json" -d "$payload" 2>/dev/null
fi
}
# Parse v1 response: {"result": <value>} or old CDP: {"result":{"result":{"value":"..."}}}
parse_eval_result() {
python3 -c "
import sys, json
try:
r = json.load(sys.stdin)
# v1 format: {'result': <value>}
if 'result' in r and not isinstance(r['result'], dict):
v = r['result']
elif 'result' in r and isinstance(r['result'], dict) and 'result' in r['result']:
# Old CDP format
v = r['result']['result'].get('value', '')
else:
v = r.get('result', '')
if isinstance(v, str) and v.startswith('{'):
print(json.dumps(json.loads(v), indent=2))
else:
print(v)
except: print(sys.stdin.read() if hasattr(sys.stdin, 'read') else '')
" 2>/dev/null || echo "parse failed"
}
echo "=== Step 1: Page state ==="
webview_eval "JSON.stringify({title: document.title, buttons: [...document.querySelectorAll('button')].map(b => b.title || b.textContent?.trim()?.substring(0,30)).filter(Boolean)})"
echo ""
echo "=== Step 2: Click 'Create something new' ==="
webview_eval "const btn = [...document.querySelectorAll('button')].find(b => b.textContent?.includes('+')); btn?.click(); btn ? 'clicked +' : 'no + btn'"
sleep 2
echo "=== Step 3: Click 'Session' in the popover ==="
webview_eval "const items = [...document.querySelectorAll('.sidebar-new-menu-item')]; const sessionBtn = items.find(b => b.textContent?.includes('Session')); sessionBtn?.click(); sessionBtn ? 'clicked Session' : 'no Session btn. Items: ' + items.map(i => i.textContent?.trim()?.substring(0,20)).join('|')"
sleep 3
echo ""
echo "=== Step 4: Check create form state ==="
webview_eval "JSON.stringify({inputs: [...document.querySelectorAll('input,textarea')].map(i => ({tag: i.tagName, id: i.id, class: i.className, placeholder: i.placeholder})), pageText: document.body?.innerText?.substring(0,500)})" | parse_eval_result
curl -s http://localhost:$PORT/api/v1/ui/screenshot -o /tmp/polypilot-after-create-form.png 2>/dev/null || \
curl -s http://localhost:$PORT/api/screenshot -o /tmp/polypilot-after-create-form.png
echo "Screenshot: $(wc -c < /tmp/polypilot-after-create-form.png) bytes"
echo ""
echo "=== Step 5: Fill session name and submit ==="
# The CreateSessionForm has input fields. Find and fill them.
webview_eval "const nameInput = document.querySelector('input[placeholder*=\"session\"], input[placeholder*=\"name\"], .session-name-input, input.create-session-input'); nameInput ? 'found name input: ' + nameInput.placeholder : 'no name input. All inputs: ' + [...document.querySelectorAll('input')].map(i => i.placeholder || i.className || i.id).join('|')"
# Try filling any visible input
webview_eval "const inp = [...document.querySelectorAll('input:not([type=hidden])')].find(i => i.offsetParent !== null); if (inp) { inp.value = 'CI Test Session'; inp.dispatchEvent(new Event('input', {bubbles:true})); inp.dispatchEvent(new Event('change', {bubbles:true})); 'filled: ' + inp.placeholder; } else { 'no visible input'; }"
sleep 1
# Click the create/submit button
webview_eval "const btn = document.querySelector('.create-btn, .submit-btn, button[type=submit]') || [...document.querySelectorAll('button')].find(b => b.textContent?.includes('Create') && !b.textContent?.includes('something')); btn?.click(); btn ? 'submitted: ' + btn.textContent?.trim()?.substring(0,30) : 'no create btn'"
sleep 5
echo ""
echo "=== Step 6: Check if session was created ==="
webview_eval "JSON.stringify({sessionItems: document.querySelectorAll('.session-item, .session-list-item, .sidebar-session')?.length || 0, cards: document.querySelectorAll('.session-card, .card')?.length || 0, pageText: document.body?.innerText?.substring(0,300)})"
curl -s http://localhost:$PORT/api/v1/ui/screenshot -o /tmp/polypilot-after-create.png 2>/dev/null || \
curl -s http://localhost:$PORT/api/screenshot -o /tmp/polypilot-after-create.png
echo "Screenshot: $(wc -c < /tmp/polypilot-after-create.png) bytes"
echo ""
echo "=== Step 7: Click on the session to expand it ==="
# Click the first session item in the sidebar to open it
webview_eval "const item = document.querySelector('.session-item, .session-list-item, .sidebar-session, [data-session]'); if (item) { item.click(); 'clicked session: ' + (item.dataset?.session || item.textContent?.trim()?.substring(0,30)); } else { 'no session item found'; }"
sleep 3
echo ""
echo "=== Step 8: Find and fill the chat input ==="
# The session card should now have an input
webview_eval "JSON.stringify({inputs: [...document.querySelectorAll('input:not([type=hidden]), textarea')].filter(i => i.offsetParent !== null).map(i => ({tag: i.tagName, id: i.id, class: i.className, placeholder: i.placeholder?.substring(0,50), parent: i.parentElement?.className?.substring(0,30)}))})" | parse_eval_result
# Fill the card input or textarea
webview_eval "const sel = '.card-input input, .card-input textarea, .input-row textarea, .expanded-card .input-area textarea, textarea'; const input = [...document.querySelectorAll(sel)].find(i => i.offsetParent !== null); if (input) { input.value = 'Hello from CI! Testing PolyPilot integration.'; input.dispatchEvent(new Event('input', {bubbles:true})); input.dispatchEvent(new Event('change', {bubbles:true})); 'filled: ' + input.tagName + ' ' + input.id + ' ' + input.className; } else { 'no visible input'; }"
sleep 1
curl -s http://localhost:$PORT/api/v1/ui/screenshot -o /tmp/polypilot-after-fill.png 2>/dev/null || \
curl -s http://localhost:$PORT/api/screenshot -o /tmp/polypilot-after-fill.png
echo "After fill: $(wc -c < /tmp/polypilot-after-fill.png) bytes"
echo ""
echo "=== Step 9: Send the message ==="
# Simulate Enter key to send, or click the send button
webview_eval "const sel = '.card-input input, .card-input textarea, .input-row textarea, .expanded-card .input-area textarea, textarea'; const input = [...document.querySelectorAll(sel)].find(i => i.offsetParent !== null); if (input) { const container = input.closest('.card-input') || input.closest('.input-row'); const sendBtn = container?.querySelector('.send-btn:not(.stop-btn)') || container?.querySelectorAll('button')?.[container?.querySelectorAll('button')?.length - 1]; if (sendBtn) { sendBtn.click(); 'clicked send: ' + sendBtn.className; } else { input.dispatchEvent(new KeyboardEvent('keydown', {key: 'Enter', bubbles: true})); 'dispatched Enter'; } } else { 'no input to send from'; }"
echo ""
echo "=== Step 10: Wait for Copilot response ==="
sleep 20
# Check for messages
webview_eval "JSON.stringify({processingIndicators: document.querySelectorAll('.thinking, .processing, .spinner, .loading')?.length || 0, messages: [...document.querySelectorAll('.message-content, .chat-bubble, .response-text, .markdown-body')].map(m => m.textContent?.substring(0,100)).filter(Boolean), bodySnippet: document.body?.innerText?.substring(0,500)})" | parse_eval_result
curl -s http://localhost:$PORT/api/v1/ui/screenshot -o /tmp/polypilot-after-session.png 2>/dev/null || \
curl -s http://localhost:$PORT/api/screenshot -o /tmp/polypilot-after-session.png
echo "✅ Final screenshot: $(wc -c < /tmp/polypilot-after-session.png) bytes"
- name: "Feature Test: Scheduled Tasks (Mac Catalyst)"
if: steps.devflow.outputs.agent_port != '' && (inputs.scenario == 'scheduled-tasks' || inputs.scenario == 'full')
run: |
PORT=${{ steps.devflow.outputs.agent_port }}
echo "Running integration tests via dotnet test"
# The integration test project lives on main — fetch it if not present
if [ ! -d "PolyPilot.IntegrationTests" ]; then
echo "Fetching integration tests from main..."
git fetch origin main --depth=1
git checkout origin/main -- PolyPilot.IntegrationTests/
fi
# Run ALL integration tests (all categories)
POLYPILOT_AGENT_PORT=$PORT dotnet test PolyPilot.IntegrationTests \
--nologo --verbosity normal 2>&1 || true
- name: Upload artifacts
if: always()
uses: actions/upload-artifact@v4
with:
name: polypilot-maccatalyst
path: |
/tmp/polypilot-ci-screenshot.png
/tmp/polypilot-after-new-session.png
/tmp/polypilot-after-create-form.png
/tmp/polypilot-after-create.png
/tmp/polypilot-after-fill.png
/tmp/polypilot-after-session.png
/tmp/polypilot-scheduled-tasks-*.png
/tmp/polypilot-stdout.log
/tmp/polypilot-stderr.log
if-no-files-found: ignore
- name: Cleanup
if: always()
run: |
kill $APP_PID 2>/dev/null || true
# Also kill any copilot headless server
PID_FILE=~/.polypilot/server.pid
if [ -f "$PID_FILE" ]; then
COPILOT_PID=$(head -1 "$PID_FILE" 2>/dev/null)
kill "$COPILOT_PID" 2>/dev/null || true
fi
# ─── Windows ─────────────────────────────────────────────────
integration-windows:
runs-on: windows-latest
timeout-minutes: 30
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: ${{ inputs.ref || github.sha }}
- name: Setup .NET 10
uses: actions/setup-dotnet@v5
with:
dotnet-version: '10.0.x'
dotnet-quality: 'preview'
- name: Install MAUI workload
run: dotnet workload install maui
- name: Install MauiDevFlow CLI
shell: pwsh
run: |
dotnet tool install --global Microsoft.Maui.Cli `
--add-source https://pkgs.dev.azure.com/dnceng/public/_packaging/dotnet10/nuget/v3/index.json `
--prerelease 2>&1 | Out-Null
if ($LASTEXITCODE -ne 0) {
Write-Host "Install returned non-zero, checking if already installed..."
& maui --version
if ($LASTEXITCODE -ne 0) { Write-Host "❌ MauiDevFlow CLI not available"; exit 1 }
}
$toolsPath = Join-Path $env:USERPROFILE ".dotnet\tools"
"$toolsPath" | Out-File -FilePath $env:GITHUB_PATH -Append
- name: Build PolyPilot (Windows Debug)
run: |
dotnet build PolyPilot/PolyPilot.csproj `
-f net10.0-windows10.0.19041.0 `
-c Debug `
--disable-build-servers `
-p:UseSharedCompilation=false `
-nodeReuse:false
shell: pwsh
- name: Launch PolyPilot (Windows)
shell: pwsh
run: |
$exe = Get-ChildItem -Path "PolyPilot\bin\Debug\net10.0-windows*" -Filter "PolyPilot.exe" -Recurse | Select-Object -First 1
if (-not $exe) {
$exe = Get-ChildItem -Path "PolyPilot\bin\Debug\net10.0-windows*" -Filter "*.exe" -Recurse | Select-Object -First 1
}
Write-Host "Found: $($exe.FullName)"
$proc = Start-Process -FilePath $exe.FullName -PassThru -RedirectStandardOutput "$env:RUNNER_TEMP\polypilot-stdout.log" -RedirectStandardError "$env:RUNNER_TEMP\polypilot-stderr.log"
"APP_PID=$($proc.Id)" | Out-File -FilePath $env:GITHUB_ENV -Append
Write-Host "PolyPilot launched with PID $($proc.Id)"
Start-Sleep -Seconds 20
if (-not $proc.HasExited) {
Write-Host "✅ PolyPilot is running"
} else {
Write-Host "❌ PolyPilot crashed (exit code: $($proc.ExitCode))"
Get-Content "$env:RUNNER_TEMP\polypilot-stderr.log" -ErrorAction SilentlyContinue
exit 1
}
- name: Discover DevFlow agent
id: devflow
shell: pwsh
run: |
$agentPort = ""
foreach ($port in 9223..9230) {
try {
$r = Invoke-WebRequest -Uri "http://localhost:$port/api/v1/agent/status" -TimeoutSec 2 -ErrorAction Stop
if ($r.StatusCode -eq 200) {
$agentPort = $port
Write-Host "✅ Found agent on port $port"
$r.Content | ConvertFrom-Json | ConvertTo-Json -Depth 5
break
}
} catch {
# Fallback to old route
try {
$r = Invoke-WebRequest -Uri "http://localhost:$port/api/status" -TimeoutSec 2 -ErrorAction Stop
if ($r.StatusCode -eq 200) {
$agentPort = $port
Write-Host "✅ Found agent on port $port (legacy route)"
$r.Content | ConvertFrom-Json | ConvertTo-Json -Depth 5
break
}
} catch { }
}
}
"agent_port=$agentPort" | Out-File -FilePath $env:GITHUB_OUTPUT -Append
- name: "Smoke: Status + Tree + Screenshot"
if: steps.devflow.outputs.agent_port != ''
shell: pwsh
run: |
$port = "${{ steps.devflow.outputs.agent_port }}"
Write-Host "=== Status ==="
try { (Invoke-WebRequest "http://localhost:$port/api/v1/agent/status").Content | ConvertFrom-Json | ConvertTo-Json }
catch { (Invoke-WebRequest "http://localhost:$port/api/status").Content | ConvertFrom-Json | ConvertTo-Json }
Write-Host "=== Tree ==="
try { (Invoke-WebRequest "http://localhost:$port/api/v1/ui/tree").Content | Out-String | Select-Object -First 50 }
catch { (Invoke-WebRequest "http://localhost:$port/api/tree").Content | Out-String | Select-Object -First 50 }
Write-Host "=== Screenshot ==="
try { Invoke-WebRequest "http://localhost:$port/api/v1/ui/screenshot" -OutFile "$env:RUNNER_TEMP\polypilot-ci-screenshot.png" }
catch { Invoke-WebRequest "http://localhost:$port/api/screenshot" -OutFile "$env:RUNNER_TEMP\polypilot-ci-screenshot.png" }
$size = (Get-Item "$env:RUNNER_TEMP\polypilot-ci-screenshot.png").Length
Write-Host "✅ Screenshot saved ($size bytes)"
- name: "Feature Test: Scheduled Tasks"
if: steps.devflow.outputs.agent_port != '' && (inputs.scenario == 'scheduled-tasks' || inputs.scenario == 'full')
shell: bash
run: |
PORT=${{ steps.devflow.outputs.agent_port }}
echo "Running scheduled tasks integration tests via dotnet test"
if [ ! -d "PolyPilot.IntegrationTests" ]; then
echo "Fetching integration tests from main..."
git fetch origin main --depth=1
git checkout origin/main -- PolyPilot.IntegrationTests/
fi
POLYPILOT_AGENT_PORT=$PORT dotnet test PolyPilot.IntegrationTests \
--filter "Category=ScheduledTasks" \
--nologo --verbosity normal 2>&1 || true
- name: Upload artifacts
if: always()
uses: actions/upload-artifact@v4
with:
name: polypilot-windows
path: |
${{ runner.temp }}/polypilot-ci-screenshot.png
${{ runner.temp }}/polypilot-stdout.log
${{ runner.temp }}/polypilot-stderr.log
if-no-files-found: ignore
- name: Cleanup
if: always()
shell: pwsh
run: |
$appPid = $env:APP_PID
if ($appPid) { Stop-Process -Id $appPid -Force -ErrorAction SilentlyContinue }
# ─── Report Results to PR ────────────────────────────────────
report:
name: Report Integration Results
runs-on: ubuntu-latest
needs: [integration-linux, integration-maccatalyst, integration-windows]
if: always() && inputs.pr_number
permissions:
pull-requests: write
steps:
- name: Post results to PR
env:
GH_TOKEN: ${{ github.token }}
LINUX: ${{ needs.integration-linux.result }}
CATALYST: ${{ needs.integration-maccatalyst.result }}
WINDOWS: ${{ needs.integration-windows.result }}
PR: ${{ inputs.pr_number }}
run: |
if [ "$LINUX" = "success" ] && [ "$CATALYST" = "success" ] && [ "$WINDOWS" = "success" ]; then
STATUS="✅ All platforms passed"
else
STATUS="❌ Integration test failures"
fi
cat > /tmp/report.md << EOF
## 🧪 Integration Test Report — PR #${PR}
| Platform | Build | Launch | DevFlow | Smoke |
|----------|-------|--------|---------|-------|
| Linux/GTK (xvfb) | $([ "$LINUX" = "success" ] && echo "✅" || echo "❌") | $([ "$LINUX" = "success" ] && echo "✅" || echo "❌") | $([ "$LINUX" = "success" ] && echo "✅" || echo "⚠️") | $([ "$LINUX" = "success" ] && echo "✅" || echo "❌") |
| Mac Catalyst | $([ "$CATALYST" = "success" ] && echo "✅" || echo "❌") | — | — | — |
| Windows | $([ "$WINDOWS" = "success" ] && echo "✅" || echo "❌") | $([ "$WINDOWS" = "success" ] && echo "✅" || echo "❌") | $([ "$WINDOWS" = "success" ] && echo "⚠️" || echo "❌") | $([ "$WINDOWS" = "success" ] && echo "⚠️" || echo "❌") |
**${STATUS}**
[View full run](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }})
EOF
gh pr comment "$PR" --repo "${{ github.repository }}" --body "$(cat /tmp/report.md)"