-
Notifications
You must be signed in to change notification settings - Fork 1
571 lines (484 loc) · 18.1 KB
/
Copy pathtelemetry-ci.yml
File metadata and controls
571 lines (484 loc) · 18.1 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
name: Telemetry System CI/CD
on:
workflow_dispatch:
push:
paths:
- 'universal-telemetry-software/**'
- 'pecan/**'
- '.github/workflows/telemetry-ci.yml'
pull_request:
paths:
- 'universal-telemetry-software/**'
- 'pecan/**'
- '.github/workflows/telemetry-ci.yml'
jobs:
detect-changes:
runs-on: ubuntu-latest
outputs:
telemetry: ${{ steps.filter.outputs.telemetry }}
pecan: ${{ steps.filter.outputs.pecan }}
steps:
- uses: actions/checkout@v4
- uses: dorny/paths-filter@v3
id: filter
with:
filters: |
telemetry:
- 'universal-telemetry-software/**'
pecan:
- 'pecan/**'
# ── Build images once, share via artifact ───────────────────────────────
build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
# Build telemetry image with GHA layer cache (benefits publish jobs too)
- name: Build telemetry image
uses: docker/build-push-action@v5
with:
context: ./universal-telemetry-software
outputs: type=docker,dest=/tmp/telemetry.tar
tags: universal-telemetry:test
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Build car-jitsi-client image
run: |
docker build -t car-jitsi-client:test ./universal-telemetry-software/car-jitsi-client
docker save car-jitsi-client:test -o /tmp/jitsi.tar
# Build pecan with the same args used in docker-compose.test.yml
- name: Build pecan image
run: |
docker build \
--build-arg VITE_WS_URL=wss://ws-wfr.0001200.xyz:9443 \
-t pecan:test ./pecan
docker save pecan:test -o /tmp/pecan.tar
- name: Validate compose configurations
working-directory: ./universal-telemetry-software
run: |
docker compose -f docker-compose.yml config --quiet
docker compose -f docker-compose.test.yml config --quiet
docker compose -f docker-compose.prod.yml config --quiet
docker compose -f docker-compose.staging.yml config --quiet
docker compose -f docker-compose.can-test.yml config --quiet
echo "✓ All compose configs valid"
- name: Upload Docker image artifacts
uses: actions/upload-artifact@v4
with:
name: docker-images
path: /tmp/*.tar
retention-days: 1
# ── Unit tests: no containers, fast feedback ─────────────────────────────
unit-tests:
runs-on: ubuntu-latest
needs: build
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Download Docker image artifacts
uses: actions/download-artifact@v4
with:
name: docker-images
path: /tmp
- name: Load Docker images
run: |
docker load -i /tmp/telemetry.tar
docker load -i /tmp/jitsi.tar
- name: Verify car-jitsi-client starts
run: |
docker run --rm --entrypoint node car-jitsi-client:test -e "require('./index.js')" &
PID=$!
sleep 5
kill $PID 2>/dev/null || true
- name: Verify go2rtc config
run: |
docker run --rm -v ${{ github.workspace }}/universal-telemetry-software/go2rtc.yaml:/config/go2rtc.yaml:ro alexxit/go2rtc:latest -c /config/go2rtc.yaml &
PID=$!
sleep 3
kill $PID 2>/dev/null || true
- name: Build and typecheck PECAN
working-directory: ./pecan
run: |
npm ci
npx tsc --noEmit
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Install Python dependencies
run: |
pip install \
pytest pytest-asyncio pytest-timeout \
cantools influxdb-client \
websockets redis requests
- name: Run unit tests
working-directory: ./universal-telemetry-software
run: |
python -m pytest tests/test_leds.py tests/test_influx_bridge.py tests/test_car_mode.py tests/test_dbc_consistency.py -v
# ── Integration tests: full docker-compose stack ─────────────────────────
integration:
runs-on: ubuntu-latest
needs: build
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Download Docker image artifacts
uses: actions/download-artifact@v4
with:
name: docker-images
path: /tmp
# Loading the tars populates Docker's layer cache so compose --build is instant
- name: Load Docker images
run: |
docker load -i /tmp/telemetry.tar
docker load -i /tmp/pecan.tar
# ── Pull heavy images in parallel ────────────────────────────────────
- name: Pull base images
run: |
docker pull influxdb:3.5.0-core &
docker pull redis:8.2 &
wait
echo "✓ Images pulled"
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Install Python dependencies
run: |
pip install \
pytest pytest-asyncio pytest-timeout \
cantools influxdb-client \
websockets redis requests \
playwright
- name: Install Playwright browsers
run: playwright install chromium --with-deps
- name: Start integration test environment
working-directory: ./universal-telemetry-software
run: |
docker compose -f docker-compose.test.yml up -d --build
echo "Waiting for all services (InfluxDB3 needs ~15s)..."
sleep 20
- name: Check container health
working-directory: ./universal-telemetry-software
run: |
docker compose -f docker-compose.test.yml ps
docker compose -f docker-compose.test.yml logs --tail 30
- name: Verify containers
run: |
for container in daq-car daq-base daq-car-redis daq-base-redis daq-pecan-test daq-test-influxdb3; do
if docker ps --format '{{.Names}}' | grep -q "^${container}$"; then
echo "✓ ${container} running"
else
echo "✗ ${container} NOT running"
docker logs ${container} 2>&1 || true
exit 1
fi
done
- name: Run integration tests
working-directory: ./universal-telemetry-software
run: |
python -m pytest tests/test_integration.py tests/test_websocket_v2.py -v -s --timeout=120
- name: Collect logs on failure
if: failure()
working-directory: ./universal-telemetry-software
run: |
mkdir -p test-logs
docker compose -f docker-compose.test.yml logs --no-color > test-logs/docker-compose.log 2>&1
docker logs daq-car > test-logs/car.log 2>&1 || true
docker logs daq-base > test-logs/base.log 2>&1 || true
docker logs daq-car-redis > test-logs/car-redis.log 2>&1 || true
docker logs daq-base-redis > test-logs/base-redis.log 2>&1 || true
docker logs daq-pecan-test > test-logs/pecan.log 2>&1 || true
docker logs daq-test-influxdb3 > test-logs/influxdb3.log 2>&1 || true
- name: Upload integration test logs
if: failure()
uses: actions/upload-artifact@v4
with:
name: integration-test-logs
path: universal-telemetry-software/test-logs/
retention-days: 7
- name: Cleanup integration test stack
if: always()
working-directory: ./universal-telemetry-software
run: |
docker compose -f docker-compose.test.yml down -v
# ── vCAN pipeline tests: real CAN code path ──────────────────────────────
vcan:
runs-on: ubuntu-latest
needs: build
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Download Docker image artifacts
uses: actions/download-artifact@v4
with:
name: docker-images
path: /tmp
- name: Load telemetry image
run: docker load -i /tmp/telemetry.tar
- name: Pull redis image
run: docker pull redis:8.2
- name: Set up virtual CAN interface
run: |
sudo apt-get install -y linux-modules-extra-$(uname -r)
sudo modprobe can
sudo modprobe can_raw
sudo modprobe vcan
sudo ip link add dev can0 type vcan
sudo ip link set up can0
ip link show can0
echo "✓ vcan interface can0 is UP"
- name: Install can-utils
run: sudo apt-get install -y can-utils
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.12'
- name: Install Python dependencies
run: |
pip install \
pytest pytest-asyncio pytest-timeout \
cantools influxdb-client \
websockets redis requests
- name: Start vCAN test stack
working-directory: ./universal-telemetry-software
run: |
docker compose -f docker-compose.can-test.yml up -d --build
echo "Waiting for telemetry container to start CAN reader..."
sleep 15
- name: Verify can0 visible inside container
run: |
if docker exec daq-can-test ip link show can0 2>&1 | grep -q "can0"; then
echo "✓ can0 is visible inside container"
else
echo "✗ can0 NOT visible inside container"
echo "--- Host interfaces ---"
ip link show
echo "--- Container interfaces ---"
docker exec daq-can-test ip link show 2>&1 || true
exit 1
fi
- name: Verify real CAN mode (not simulation)
run: |
if docker logs daq-can-test 2>&1 | grep -q "CAN Reader started on can0"; then
echo "✓ Container is reading real can0"
else
echo "✗ Container did NOT start real CAN reader"
docker logs daq-can-test 2>&1
exit 1
fi
- name: Run vCAN pipeline tests
working-directory: ./universal-telemetry-software
run: |
python -m pytest tests/test_can_pipeline.py -v -s --timeout=60
- name: Run pecan UI vCAN tests
working-directory: ./pecan
run: |
npm ci
npm run test:ci
- name: Collect vCAN test logs on failure
if: failure()
working-directory: ./universal-telemetry-software
run: |
mkdir -p test-logs
docker logs daq-can-test > test-logs/can-test.log 2>&1 || true
docker logs daq-can-test-redis > test-logs/can-test-redis.log 2>&1 || true
- name: Upload vCAN test logs
if: failure()
uses: actions/upload-artifact@v4
with:
name: vcan-test-logs
path: universal-telemetry-software/test-logs/
retention-days: 7
- name: Cleanup vCAN test stack
if: always()
working-directory: ./universal-telemetry-software
run: |
docker compose -f docker-compose.can-test.yml down -v 2>/dev/null || true
sudo ip link delete can0 2>/dev/null || true
publish-telemetry:
needs: [unit-tests, integration, vcan, detect-changes]
runs-on: ubuntu-latest
if: github.event_name == 'workflow_dispatch' || (github.event_name != 'pull_request' && needs.detect-changes.outputs.telemetry == 'true')
permissions:
contents: read
packages: write
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Telemetry
id: meta-telemetry
uses: docker/metadata-action@v5
with:
images: ghcr.io/${{ github.repository }}/universal-telemetry
tags: |
type=raw,value=latest,enable=${{ github.ref == 'refs/heads/main' }}
type=raw,value=test-latest,enable=${{ github.ref != 'refs/heads/main' }}
type=sha
- name: Build and push Telemetry image
uses: docker/build-push-action@v5
with:
context: ./universal-telemetry-software
file: ./universal-telemetry-software/Dockerfile
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.meta-telemetry.outputs.tags }}
labels: ${{ steps.meta-telemetry.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Extract metadata (tags, labels) for Car Jitsi Client
id: meta-car-jitsi
uses: docker/metadata-action@v5
with:
images: ghcr.io/${{ github.repository }}/car-jitsi-client
tags: |
type=raw,value=latest,enable=${{ github.ref == 'refs/heads/main' }}
type=raw,value=test-latest,enable=${{ github.ref != 'refs/heads/main' }}
type=sha
- name: Build and push Car Jitsi Client image
uses: docker/build-push-action@v5
with:
context: ./universal-telemetry-software/car-jitsi-client
file: ./universal-telemetry-software/car-jitsi-client/Dockerfile
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.meta-car-jitsi.outputs.tags }}
labels: ${{ steps.meta-car-jitsi.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
publish-pecan:
needs: [unit-tests, integration, vcan, detect-changes]
runs-on: ubuntu-latest
if: github.event_name == 'workflow_dispatch' || (github.event_name != 'pull_request' && needs.detect-changes.outputs.pecan == 'true')
permissions:
contents: read
packages: write
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Pecan
id: meta-pecan
uses: docker/metadata-action@v5
with:
images: ghcr.io/${{ github.repository }}/pecan
tags: |
type=raw,value=latest,enable=${{ github.ref == 'refs/heads/main' }}
type=raw,value=test-latest,enable=${{ github.ref != 'refs/heads/main' }}
type=sha
- name: Build and push Pecan image
uses: docker/build-push-action@v5
with:
context: ./pecan
file: ./pecan/Dockerfile
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.meta-pecan.outputs.tags }}
labels: ${{ steps.meta-pecan.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
deploy-pecan-pages:
needs: [unit-tests, integration, vcan]
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main'
permissions:
contents: read
pages: write
id-token: write
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
cache-dependency-path: pecan/package-lock.json
- name: Install dependencies
working-directory: ./pecan
run: npm ci
- name: Run tests
working-directory: ./pecan
run: npm run test:ci
- name: Build
working-directory: ./pecan
run: npm run build
env:
VITE_FIREBASE_API_KEY: ${{ secrets.VITE_FIREBASE_API_KEY }}
VITE_FIREBASE_AUTH_DOMAIN: ${{ secrets.VITE_FIREBASE_AUTH_DOMAIN }}
VITE_FIREBASE_PROJECT_ID: ${{ secrets.VITE_FIREBASE_PROJECT_ID }}
VITE_FIREBASE_STORAGE_BUCKET: ${{ secrets.VITE_FIREBASE_STORAGE_BUCKET }}
VITE_FIREBASE_MESSAGING_SENDER_ID: ${{ secrets.VITE_FIREBASE_MESSAGING_SENDER_ID }}
VITE_FIREBASE_APP_ID: ${{ secrets.VITE_FIREBASE_APP_ID }}
- name: Upload artifact
uses: actions/upload-pages-artifact@v3
with:
path: ./pecan/dist
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
deploy-pecan-dev-cloudflare:
needs: [unit-tests, integration, vcan]
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/dev'
permissions:
contents: read
deployments: write
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
cache-dependency-path: pecan/package-lock.json
- name: Install dependencies
working-directory: ./pecan
run: npm ci
- name: Run tests
working-directory: ./pecan
run: npm run test:ci
- name: Build
working-directory: ./pecan
run: npm run build
env:
VITE_FIREBASE_API_KEY: ${{ secrets.VITE_FIREBASE_API_KEY_DEV }}
VITE_FIREBASE_AUTH_DOMAIN: ${{ secrets.VITE_FIREBASE_AUTH_DOMAIN_DEV }}
VITE_FIREBASE_PROJECT_ID: ${{ secrets.VITE_FIREBASE_PROJECT_ID_DEV }}
VITE_FIREBASE_STORAGE_BUCKET: ${{ secrets.VITE_FIREBASE_STORAGE_BUCKET_DEV }}
VITE_FIREBASE_MESSAGING_SENDER_ID: ${{ secrets.VITE_FIREBASE_MESSAGING_SENDER_ID_DEV }}
VITE_FIREBASE_APP_ID: ${{ secrets.VITE_FIREBASE_APP_ID_DEV }}
- name: Deploy to Cloudflare Pages
uses: cloudflare/pages-action@v1
with:
apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }}
accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
projectName: 'pecan-dev'
directory: './pecan/dist'
gitHubToken: ${{ secrets.GITHUB_TOKEN }}
branch: dev