-
Notifications
You must be signed in to change notification settings - Fork 27
495 lines (447 loc) · 17.3 KB
/
run_book_tests.yml
File metadata and controls
495 lines (447 loc) · 17.3 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
name: Run all book tests (matrix, per chapter)
on:
# Automatically run this action when a new push is made to repo
push:
# Run tests every 6 months after prerelease comes out to check for regressions.
# Prerelease for "a" release is out by Jan 1. for "b" release by Jul 1
schedule:
- cron: "0 0 1 1,7 *"
# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
jobs:
book-tests:
name: Run ${{ matrix.chapter }} tests
runs-on: ubuntu-latest
strategy:
fail-fast: false # keep running other chapters if one fails
matrix:
include:
- chapter: Chapter02
test_folder: test/book/chapter02
products: >
Image_Processing_Toolbox
MATLAB
Navigation_Toolbox
Symbolic_Math_Toolbox
junit: test-results/Chapter02.xml
cobertura: code-coverage/Chapter02.xml
- chapter: Chapter03
test_folder: test/book/chapter03
products: >
MATLAB
Optimization_Toolbox
Robotics_System_Toolbox
junit: test-results/Chapter03.xml
cobertura: code-coverage/Chapter03.xml
- chapter: Chapter04
test_folder: test/book/chapter04
products: >
MATLAB
Simulink
Robotics_System_Toolbox
UAV_Toolbox
junit: test-results/Chapter04.xml
cobertura: code-coverage/Chapter04.xml
- chapter: Chapter05
test_folder: test/book/chapter05
products: >
MATLAB
Simulink
Image_Processing_Toolbox
Navigation_Toolbox
Robotics_System_Toolbox
junit: test-results/Chapter05.xml
cobertura: code-coverage/Chapter05.xml
- chapter: Chapter06
test_folder: test/book/chapter06
products: >
MATLAB
Computer_Vision_Toolbox
Image_Processing_Toolbox
Navigation_Toolbox
Robotics_System_Toolbox
Statistics_and_Machine_Learning_Toolbox
Symbolic_Math_Toolbox
junit: test-results/Chapter06.xml
cobertura: code-coverage/Chapter06.xml
- chapter: Chapter07
test_folder: test/book/chapter07
products: >
MATLAB
Simulink
Robotics_System_Toolbox
Symbolic_Math_Toolbox
junit: test-results/Chapter07.xml
cobertura: code-coverage/Chapter07.xml
- chapter: Chapter08
test_folder: test/book/chapter08
products: >
Automated_Driving_Toolbox
Computer_Vision_Toolbox
Control_System_Toolbox
Deep_Learning_Toolbox
Image_Processing_Toolbox
MATLAB
Model_Predictive_Control_Toolbox
Navigation_Toolbox
Optimization_Toolbox
Parallel_Computing_Toolbox
Simulink
Robotics_System_Toolbox
ROS_Toolbox
Signal_Processing_Toolbox
Statistics_and_Machine_Learning_Toolbox
Symbolic_Math_Toolbox
UAV_Toolbox
junit: test-results/Chapter08.xml
cobertura: code-coverage/Chapter08.xml
- chapter: Chapter09
test_folder: test/book/chapter09
products: >
Automated_Driving_Toolbox
Computer_Vision_Toolbox
Control_System_Toolbox
Deep_Learning_Toolbox
Image_Processing_Toolbox
MATLAB
Model_Predictive_Control_Toolbox
Navigation_Toolbox
Optimization_Toolbox
Parallel_Computing_Toolbox
Simulink
Robotics_System_Toolbox
ROS_Toolbox
Signal_Processing_Toolbox
Statistics_and_Machine_Learning_Toolbox
Symbolic_Math_Toolbox
UAV_Toolbox
junit: test-results/Chapter09.xml
cobertura: code-coverage/Chapter09.xml
- chapter: Chapter10
test_folder: test/book/chapter10
products: >
Automated_Driving_Toolbox
Computer_Vision_Toolbox
Control_System_Toolbox
Deep_Learning_Toolbox
Image_Processing_Toolbox
MATLAB
Model_Predictive_Control_Toolbox
Navigation_Toolbox
Optimization_Toolbox
Parallel_Computing_Toolbox
Simulink
Robotics_System_Toolbox
ROS_Toolbox
Signal_Processing_Toolbox
Statistics_and_Machine_Learning_Toolbox
Symbolic_Math_Toolbox
UAV_Toolbox
junit: test-results/Chapter10.xml
cobertura: code-coverage/Chapter10.xml
- chapter: Chapter11
test_folder: test/book/chapter11
products: >
Automated_Driving_Toolbox
Computer_Vision_Toolbox
Control_System_Toolbox
Deep_Learning_Toolbox
Image_Processing_Toolbox
MATLAB
Model_Predictive_Control_Toolbox
Navigation_Toolbox
Optimization_Toolbox
Parallel_Computing_Toolbox
Simulink
Robotics_System_Toolbox
ROS_Toolbox
Signal_Processing_Toolbox
Statistics_and_Machine_Learning_Toolbox
Symbolic_Math_Toolbox
UAV_Toolbox
junit: test-results/Chapter11.xml
cobertura: code-coverage/Chapter11.xml
- chapter: Chapter12
test_folder: test/book/chapter12
products: >
Automated_Driving_Toolbox
Computer_Vision_Toolbox
Control_System_Toolbox
Deep_Learning_Toolbox
Image_Processing_Toolbox
MATLAB
Model_Predictive_Control_Toolbox
Navigation_Toolbox
Optimization_Toolbox
Parallel_Computing_Toolbox
Simulink
Robotics_System_Toolbox
ROS_Toolbox
Signal_Processing_Toolbox
Statistics_and_Machine_Learning_Toolbox
Symbolic_Math_Toolbox
UAV_Toolbox
junit: test-results/Chapter12.xml
cobertura: code-coverage/Chapter12.xml
- chapter: Chapter13
test_folder: test/book/chapter13
products: >
Automated_Driving_Toolbox
Computer_Vision_Toolbox
Control_System_Toolbox
Deep_Learning_Toolbox
Image_Processing_Toolbox
MATLAB
Model_Predictive_Control_Toolbox
Navigation_Toolbox
Optimization_Toolbox
Parallel_Computing_Toolbox
Simulink
Robotics_System_Toolbox
ROS_Toolbox
Signal_Processing_Toolbox
Statistics_and_Machine_Learning_Toolbox
Symbolic_Math_Toolbox
UAV_Toolbox
junit: test-results/Chapter13.xml
cobertura: code-coverage/Chapter13.xml
- chapter: Chapter14
test_folder: test/book/chapter14
products: >
Automated_Driving_Toolbox
Computer_Vision_Toolbox
Control_System_Toolbox
Deep_Learning_Toolbox
Image_Processing_Toolbox
MATLAB
Model_Predictive_Control_Toolbox
Navigation_Toolbox
Optimization_Toolbox
Parallel_Computing_Toolbox
Simulink
Robotics_System_Toolbox
ROS_Toolbox
Signal_Processing_Toolbox
Statistics_and_Machine_Learning_Toolbox
Symbolic_Math_Toolbox
UAV_Toolbox
junit: test-results/Chapter14.xml
cobertura: code-coverage/Chapter14.xml
- chapter: Chapter15
test_folder: test/book/chapter15
products: >
Automated_Driving_Toolbox
Computer_Vision_Toolbox
Control_System_Toolbox
Deep_Learning_Toolbox
Image_Processing_Toolbox
MATLAB
Model_Predictive_Control_Toolbox
Navigation_Toolbox
Optimization_Toolbox
Parallel_Computing_Toolbox
Simulink
Robotics_System_Toolbox
ROS_Toolbox
Signal_Processing_Toolbox
Statistics_and_Machine_Learning_Toolbox
Symbolic_Math_Toolbox
UAV_Toolbox
junit: test-results/Chapter15.xml
cobertura: code-coverage/Chapter15.xml
- chapter: Chapter16
test_folder: test/book/chapter16
products: >
Automated_Driving_Toolbox
Computer_Vision_Toolbox
Control_System_Toolbox
Deep_Learning_Toolbox
Image_Processing_Toolbox
MATLAB
Model_Predictive_Control_Toolbox
Navigation_Toolbox
Optimization_Toolbox
Parallel_Computing_Toolbox
Simulink
Robotics_System_Toolbox
ROS_Toolbox
Signal_Processing_Toolbox
Statistics_and_Machine_Learning_Toolbox
Symbolic_Math_Toolbox
UAV_Toolbox
junit: test-results/Chapter16.xml
cobertura: code-coverage/Chapter16.xml
- chapter: ChapterAppendices
test_folder: test/book/chapterAppendices
products: >
Automated_Driving_Toolbox
Computer_Vision_Toolbox
Control_System_Toolbox
Deep_Learning_Toolbox
Image_Processing_Toolbox
MATLAB
Model_Predictive_Control_Toolbox
Navigation_Toolbox
Optimization_Toolbox
Parallel_Computing_Toolbox
Simulink
Robotics_System_Toolbox
ROS_Toolbox
Signal_Processing_Toolbox
Statistics_and_Machine_Learning_Toolbox
Symbolic_Math_Toolbox
UAV_Toolbox
junit: test-results/ChapterAppendices.xml
cobertura: code-coverage/ChapterAppendices.xml
# Automated_Driving_Toolbox
# Computer_Vision_Toolbox
# Control_System_Toolbox
# Deep_Learning_Toolbox
# Image_Processing_Toolbox
# MATLAB
# Model_Predictive_Control_Toolbox
# Navigation_Toolbox
# Optimization_Toolbox
# Parallel_Computing_Toolbox
# Simulink
# Robotics_System_Toolbox
# ROS_Toolbox
# Signal_Processing_Toolbox
# Statistics_and_Machine_Learning_Toolbox
# Symbolic_Math_Toolbox
# UAV_Toolbox
# ...one row per tChapterXX.m
steps:
- name: Check out RVC3-MATLAB repository
uses: actions/checkout@v4
- run: echo "The ${{ github.repository }} repository has been cloned to the runner."
- name: Update apt package cache
# Run apt-get update to get the latest package cache
run: |
sudo apt-get update
- name: Start display server
# Start a display server so Java Swing is available for testing
run: |
sudo apt-get install xvfb
Xvfb :99 &
echo "DISPLAY=:99" >> $GITHUB_ENV
- name: Install GStreamer and plugins for VideoReader
run: |
sudo apt-get install libgstreamer-plugins-bad1.0-0 gstreamer1.0-plugins-ugly
- name: Set up MATLAB
# This uses the latest release of MATLAB. Can specify "release" if needed.
# Use v2 for Java Swing access
uses: matlab-actions/setup-matlab@v2
with:
# Define products for each chapter in strategy matrix above
products: ${{ matrix.products }}
# Run tests with prerelease as soon as available; switch to GR once it's live
release: latest-including-prerelease
- name: Print out ver details
uses: matlab-actions/run-command@v1
with:
command: ver; exit;
- name: Run MATLAB Tests for ${{ matrix.chapter }}
uses: matlab-actions/run-tests@v2
with:
# Only tests for this chapter
select-by-folder: ${{ matrix.test_folder }}
# Per-chapter logs
test-results-junit: ${{ matrix.junit }}
code-coverage-cobertura: ${{ matrix.cobertura }}
source-folder: toolbox; toolbox/internal; test/tools
startup-options: -webfigures
# Run tests in parallel. Requires Parallel_Computing_Toolbox in "products" list above
use-parallel: false
- name: Upload logs and coverage for ${{ matrix.chapter }}
if: always()
uses: actions/upload-artifact@v4
with:
name: book-${{ matrix.chapter }}
path: |
${{ matrix.junit }}
${{ matrix.cobertura }}
test-dashboard:
name: Book test dashboard
needs: book-tests
runs-on: ubuntu-latest
if: always() # run even if some chapter jobs failed
steps:
- name: Download all test artifacts
uses: actions/download-artifact@v4
with:
path: artifacts # everything ends up under ./artifacts/
- name: Summarize JUnit failures into run summary
run: |
python - << 'PY'
import os
import pathlib
import xml.etree.ElementTree as ET
artifacts_root = pathlib.Path("artifacts")
chapters = {} # chapter -> {"passed": bool, "failures": [..]}
# Look for JUnit XML files inside any artifact
for junit in artifacts_root.rglob("test-results/*.xml"):
chapter = junit.stem # e.g. "Chapter10"
tree = ET.parse(junit)
root = tree.getroot()
failures = []
# Handle both <testsuite> root and <testsuites> -> <testsuite>
testsuites = []
if root.tag == "testsuite":
testsuites = [root]
else:
testsuites = list(root.iter("testsuite"))
for ts in testsuites:
for case in ts.iter("testcase"):
case_name = case.get("name", "")
classname = case.get("classname", "")
for failure in case.findall("failure"):
msg = (failure.get("message") or "").strip()
text = (failure.text or "").strip()
detail = msg or text or "Test failed"
failures.append({
"classname": classname,
"name": case_name,
"detail": detail,
})
chapters[chapter] = {
"passed": len(failures) == 0,
"failures": failures,
}
lines = []
lines.append("# Book Test Dashboard\n")
if not chapters:
lines.append("_No JUnit result files found in artifacts. "
"Check that the matrix jobs ran and uploaded artifacts._")
else:
# Sort chapters like Chapter01, Chapter02, ...
for chapter in sorted(chapters.keys()):
info = chapters[chapter]
if info["passed"]:
lines.append(f"- ✅ **{chapter}** – all tests passed")
else:
fails = info["failures"]
lines.append(f"- ❌ **{chapter}** – {len(fails)} failing test(s)")
for f in fails:
name = f["name"] or "<unnamed>"
cls = f["classname"] or "<no class>"
detail = f["detail"].replace("\n", " ")
# Keep detail short-ish
if len(detail) > 160:
detail = detail[:157] + "..."
lines.append(
f" - `{cls}.{name}` – {detail}"
)
lines.append("\n---\n")
lines.append(
"🔎 For full logs and coverage for a chapter, open the "
"_Run ChapterXX tests_ job and download the "
"artifact named `book-ChapterXX`."
)
summary_path = os.environ.get("GITHUB_STEP_SUMMARY")
if summary_path:
with open(summary_path, "w", encoding="utf-8") as f:
f.write("\n".join(lines))
else:
print("\\n".join(lines))
PY