Skip to content

Commit 7df5255

Browse files
committed
Handle missing sizes summary in sketches reports
In addition to the per-sketch memory usage data, the sketches report includes per-board data that summarizes the per-sketch data. Previous versions of the arduino/compile-sketches action did not add the key for the summary data to the report when none of the compilations produced size data. When the arduino/report-size-deltas action attempted to parse a sketches report with this format, it would error: ``` Traceback (most recent call last): File "/reportsizedeltas/reportsizedeltas.py", line 737, in <module> main() # pragma: no cover File "/reportsizedeltas/reportsizedeltas.py", line 32, in main report_size_deltas.report_size_deltas() File "/reportsizedeltas/reportsizedeltas.py", line 95, in report_size_deltas self.report_size_deltas_from_workflow_artifacts() File "/reportsizedeltas/reportsizedeltas.py", line 149, in report_size_deltas_from_workflow_artifacts sketches_reports = self.get_sketches_reports(artifact_folder_object=artifact_folder_object) File "/reportsizedeltas/reportsizedeltas.py", line 295, in get_sketches_reports not in report_data[self.ReportKeys.boards][0][self.ReportKeys.sizes][0]) KeyError: 'sizes' ``` The most common cause of a compilation not producing size data is a compilation error. In this case the default arduino/compile-sketches workflow configuration would not upload a sketches report workflow artifact (because the upload is done in a subsequent step and GitHub Actions exits the job immediately when a step fails) so the arduino/report-size-deltas action's inability to handle the resulting report format was only an issue in unusual workflow configurations. There is another cause of a compilation not producing size data: the boards platform was not configured to produce the data. Previously, all known Arduino boards platforms produced at least some size data so the problem of the action's lack of compatibility with these boards was only hypothetical. However, the "Arduino Mbed OS Portenta Boards" platform now contains two boards which are missing the configuration to produce the size data: - Portenta H7 - Portenta X8 This meant that the action is broken by any sketches reports produced by compiling for either of those boards. The arduino/compile-sketches action was changed to always add a `boards[*].sizes` object to the sketches report, even when it doesn't have any size data to fill it. So the problem will no longer occur with sketches reports produced by the new version of that action. However, repositories may still contain sketches report artifacts with the old format so the arduino/report-size-deltas action must be able to continue to work in the presence of these reports. That is accomplished by skipping any report that is missing a `boards[*].sizes` key.
1 parent 9595935 commit 7df5255

File tree

2 files changed

+57
-0
lines changed

2 files changed

+57
-0
lines changed

reportsizedeltas/reportsizedeltas.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,8 @@ def get_sketches_reports(self, artifact_folder_object):
291291
report_data = json.load(report_file)
292292
if (
293293
(self.ReportKeys.boards not in report_data)
294+
or (self.ReportKeys.sizes
295+
not in report_data[self.ReportKeys.boards][0])
294296
or (self.ReportKeys.maximum
295297
not in report_data[self.ReportKeys.boards][0][self.ReportKeys.sizes][0])
296298
):
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
{
2+
"commit_hash": "54815a7d1a30fcb0d77d98242b158e7845c0516d",
3+
"commit_url": "https://example.com/foo",
4+
"boards": [
5+
{
6+
"board": "arduino:mbed_portenta:envie_m7",
7+
"sketches": [
8+
{
9+
"name": "examples/Bar",
10+
"compilation_success": true,
11+
"sizes": [
12+
{
13+
"name": "flash",
14+
"maximum": "N/A",
15+
"current": {
16+
"absolute": "N/A",
17+
"relative": "N/A"
18+
}
19+
},
20+
{
21+
"name": "RAM for global variables",
22+
"maximum": "N/A",
23+
"current": {
24+
"absolute": "N/A",
25+
"relative": "N/A"
26+
}
27+
}
28+
]
29+
},
30+
{
31+
"name": "examples/Foo",
32+
"compilation_success": true,
33+
"sizes": [
34+
{
35+
"name": "flash",
36+
"maximum": "N/A",
37+
"current": {
38+
"absolute": "N/A",
39+
"relative": "N/A"
40+
}
41+
},
42+
{
43+
"name": "RAM for global variables",
44+
"maximum": "N/A",
45+
"current": {
46+
"absolute": "N/A",
47+
"relative": "N/A"
48+
}
49+
}
50+
]
51+
}
52+
]
53+
}
54+
]
55+
}

0 commit comments

Comments
 (0)