55import json
66import re
77
8- EXPECTED_ERROR = - 2
98SKIP = - 1
109PASS = 0
1110WARNING = 1
12- ERROR = 2
13- FAILURE = 3
11+ EXPECTED_ERROR = 2
12+ ERROR = 3
13+ FAILURE = 4
1414
1515TEST_STATUS = [
1616 ":green_circle:" ,
1717 ":yellow_circle:" ,
18+ ":red_circle:*" ,
1819 ":red_circle:" ,
1920 ":fire:" ,
20- "[:red_circle:]" , # -2
2121 ":new_moon:" # -1
2222]
2323
2424BOARD_STATUS = [
2525 ":white_check_mark:" ,
26- ":grey_exclamation:" ,
26+ ":white_check_mark:*" ,
27+ ":heavy_check_mark:*" ,
2728 ":x:" ,
2829 ":fire:" ,
29- "[:x:]" , # -2
3030 ":new_moon:" # -1
3131]
3232
@@ -53,6 +53,7 @@ def example_name(sketch_name):
5353TEST_MATRIX = {}
5454BOARD_SUMMARY = {}
5555EXPECTED_ERRORS = set ()
56+ EXPECTED_ERRORS .add (('portentac33' , 'ArduinoCore-zephyr/libraries/Ethernet/examples/UdpNtpClient' ))
5657
5758def log_test (name , board , status , issues , job_link = None ):
5859 """
@@ -62,8 +63,8 @@ def log_test(name, board, status, issues, job_link=None):
6263 if not board in BOARD_SUMMARY :
6364 BOARD_SUMMARY [board ] = {
6465 'tests' : 0 ,
66+ 'expected-errors' : 0 ,
6567 'errors' : 0 ,
66- 'errors-expected' : 0 ,
6768 'warnings' : 0 ,
6869 'job_link' : job_link ,
6970 'status' : 0
@@ -79,7 +80,7 @@ def log_test(name, board, status, issues, job_link=None):
7980 board_info ['warnings' ] += 1
8081 elif status == ERROR :
8182 if (board , name ) in EXPECTED_ERRORS :
82- board_info ['errors- expected' ] += 1
83+ board_info ['expected-errors ' ] += 1
8384 status = EXPECTED_ERROR
8485 else :
8586 board_info ['errors' ] += 1
@@ -139,7 +140,7 @@ def process_build_reports():
139140
140141 reports = report_data .get ('boards' , [{}])[0 ].get ('sketches' , [])
141142 if not reports :
142- log_test ('CI test' , board , FAILURE , "Test report is empty, check full log." , job_link )
143+ log_test ('CI test' , board , FAILURE , "Test report is empty, check CI log." , job_link )
143144 continue # Skip to the next board
144145
145146 # 7. Sketch Loop: Iterate through individual sketch reports
@@ -164,32 +165,41 @@ def process_build_reports():
164165 artifacts = set (item ['artifact' ] for item in ALL_BOARD_DATA )
165166
166167 # Print the recap table
167- print ("<table>\n <tr><th>Artifact</th><th>Board</th><th>Status</th><th>Tests </th><th>Warnings</th><th>Errors</th></tr>" )
168+ print ("<table>\n <tr><th>Artifact</th><th>Board</th><th>Status</th><th>Passed </th><th>Warnings</th><th>Errors</th></tr>" )
168169
169170 for artifact in sorted (list (artifacts ), reverse = True ):
170- artifact_boards = [item for item in ALL_BOARD_DATA if item ['artifact' ] == artifact ]
171+ artifact_boards = [ item ['board' ] for item in ALL_BOARD_DATA if item ['artifact' ] == artifact ]
172+
173+ artifact_status = PASS
174+ for board in artifact_boards :
175+ artifact_status = max (artifact_status , BOARD_SUMMARY [board ]['status' ])
171176
172177 first_line = True
173178 for board in artifact_boards :
174- print (f"<tr>" , f"<td rowspan='{ len (artifact_boards )} '><a href='#{ artifact } '><code>{ artifact } </code></a></td>" if first_line else "" )
179+ print (f"<tr>" , f"<td rowspan='{ len (artifact_boards )} '>{ BOARD_STATUS [ artifact_status ] } <a href='#{ artifact } '><code>{ artifact } </code></a></td>" if first_line else "" )
175180 first_line = False
176181
177- board_name = board ['board' ]
178- summary = BOARD_SUMMARY [board_name ]
182+ summary = BOARD_SUMMARY [board ]
179183 job_link = summary ['job_link' ]
180184 status = summary ['status' ]
181- board_link = f"<a href='{ job_link } '>{ board_name } </a>" if job_link else board_name
185+ board_link = f"<a href='{ job_link } '>{ board } </a>" if job_link else board
182186
183187 print (f"<td><code>{ board_link } </code></td><td align='center'>{ BOARD_STATUS [status ]} </td>" )
184188 if status == FAILURE :
185- print (f"<td colspan=3>{ TEST_MATRIX ['CI test' ][board_name ]['issues' ][0 ]} </td></tr>" )
189+ print (f"<td colspan=3>{ TEST_MATRIX ['CI test' ][board ]['issues' ][0 ]} </td></tr>" )
186190 else :
187- print (f"<td align='right'>{ (summary ['tests' ] - summary ['errors' ]) or '-' } </td><td align='right'>{ summary ['warnings' ] or '-' } </td><td align='right'>{ summary ['errors' ] or '-' } </td></tr>" )
191+ passed = summary ['tests' ] - summary ['errors' ]
192+ passed_str = passed or "-"
193+ warnings_str = summary ['warnings' ] or "-"
194+ errors_str = f"<b>{ summary ['errors' ]} </b>" if summary ['errors' ] else "-"
195+ if summary ['expected-errors' ]:
196+ errors_str += f" (+{ summary ['expected-errors' ]} *)"
197+ print (f"<td align='right'>{ passed_str } </td><td align='right'>{ warnings_str } </td><td align='right'>{ errors_str } </td></tr>" )
188198 print ("</table>\n " )
189199
190200 for artifact in sorted (list (artifacts ), reverse = True ):
191- artifact_boards = [ item for item in ALL_BOARD_DATA
192- if item ['artifact' ] == artifact and BOARD_SUMMARY [item ['board' ]]['status' ] != FAILURE ]
201+ artifact_boards = [ item [ 'board' ] for item in ALL_BOARD_DATA
202+ if item ['artifact' ] == artifact and BOARD_SUMMARY [item ['board' ]]['status' ] != FAILURE ]
193203
194204 if not artifact_boards :
195205 continue
@@ -200,8 +210,7 @@ def process_build_reports():
200210 # Print the test matrix
201211
202212 header_row = "<tr><th colspan=2>Sketch / Board</th>"
203- for board_data in artifact_boards :
204- board = board_data ['board' ]
213+ for board in artifact_boards :
205214 status = BOARD_SUMMARY [board ]['status' ]
206215 header_col = f"<code>{ board } </code>"
207216 if BOARD_SUMMARY [board ]['job_link' ]:
@@ -214,34 +223,33 @@ def process_build_reports():
214223 print ("<table id='#{artifact}'>" )
215224 print (header_row )
216225
217- artifact_matrix = { sketch : results for sketch , results in TEST_MATRIX .items () if any (board_data [ ' board' ] in results for board_data in artifact_boards ) }
226+ artifact_matrix = { sketch : results for sketch , results in TEST_MATRIX .items () if any (board in results for board in artifact_boards ) }
218227
219228 for sketch_name , board_results in artifact_matrix .items ():
220229 sketch_status = SKIP
221230 row_data = ""
222- for board_data in artifact_boards :
223- board_name = board_data ['board' ]
224- test_result = board_results .get (board_name )
231+ for board in artifact_boards :
232+ test_result = board_results .get (board )
225233 status = test_result ['status' ] if test_result else SKIP
226- sketch_status = max (sketch_status , status )
227234 issues = test_result ['issues' ] if test_result else ""
235+
236+ sketch_status = max (sketch_status , status )
228237 sketch_id = sketch_name .replace ('/' , '_' ).replace (' ' , '_' ).replace ('-' , '_' )
229- icon_link = f"<a href='#{ sketch_id } _{ board_name } '>{ TEST_STATUS [status ]} </a>" if issues else TEST_STATUS [status ]
238+ icon_link = f"<a href='#{ sketch_id } _{ board } '>{ TEST_STATUS [status ]} </a>" if issues else TEST_STATUS [status ]
230239 row_data += f"<td align='center'>{ icon_link } </a></td>"
231240 print (f"<tr><td>{ TEST_STATUS [sketch_status ]} </td><td><code>{ example_name (sketch_name )} </code></td>{ row_data } </tr>" )
232241 print ("</table>\n " )
233242
234- print (f"<details><summary><b>Error and warning logs for <code>{ artifact } </code></b></summary>\n " )
243+ print (f"<details><summary>:scroll: <b>Detailed test issues for <code>{ artifact } </code></b></summary>\n " )
235244 print ("<table>" )
236245 print ("<tr><th>Sketch</th><th>Build Details</th></tr>" )
237246 for sketch_name , board_results in artifact_matrix .items ():
238247 row_open = False
239- for board_data in artifact_boards :
240- board_name = board_data ['board' ]
241- if not board_name in board_results :
248+ for board in artifact_boards :
249+ if not board in board_results :
242250 continue
243251
244- test_result = board_results [board_name ]
252+ test_result = board_results [board ]
245253 status = test_result ['status' ]
246254 issues = test_result ['issues' ]
247255 if not issues :
@@ -256,7 +264,7 @@ def process_build_reports():
256264 if job_link :
257265 job_link = f" <a href='{ job_link } '> :scroll:</a>"
258266 sketch_id = sketch_name .replace ('/' , '_' ).replace (' ' , '_' ).replace ('-' , '_' )
259- print (f"<details id='{ sketch_id } _{ board_name } '><summary>{ artifact_count (len (issues ), status , TEST_STATUS )} <code>{ board_name } </code>{ job_link } </summary>" )
267+ print (f"<details id='{ sketch_id } _{ board } '><summary>{ artifact_count (len (issues ), status , TEST_STATUS )} <code>{ board } </code>{ job_link } </summary>" )
260268 print ("\n ```\n " + "\n " .join (issues ) + "\n ```" )
261269 print ("</details>" )
262270
0 commit comments