arduino / report-size-deltas

GitHub Actions action that comments on pull requests with a report of change in memory usage of Arduino sketches
Other
14 stars 8 forks source link

Handle sketches reports with missing size data #31

Closed per1234 closed 1 year ago

per1234 commented 1 year ago

Previously, the action's code assumed that the sketches reports artifacts would always contain size deltas data. If a report was present that did not contain this data, the action would fail with a KeyError error for keys missing from the report.

For example:

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:

This meant that the action is broken by any sketches reports produced by compiling for either of those boards.

One possible fix would be to make the arduino/compile-sketches action add all expected objects to the sketches report even when the compilation does not produce any data to populated them with. But this seems like the wrong approach. So the alternative approach was taken of making the arduino/report-size-deltas action check for the presence of the data. If it is not present, a "N/A" is added to the report in place of the data.

codecov-commenter commented 1 year ago

Codecov Report

Patch coverage: 100.00% and no project coverage change.

Comparison is base (1cb4a4f) 100.00% compared to head (d7b275e) 100.00%.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #31 +/- ## ========================================= Coverage 100.00% 100.00% ========================================= Files 2 2 Lines 707 726 +19 ========================================= + Hits 707 726 +19 ``` | [Impacted Files](https://codecov.io/gh/arduino/report-size-deltas/pull/31?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=arduino) | Coverage Δ | | |---|---|---| | [reportsizedeltas/reportsizedeltas.py](https://codecov.io/gh/arduino/report-size-deltas/pull/31?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=arduino#diff-cmVwb3J0c2l6ZWRlbHRhcy9yZXBvcnRzaXplZGVsdGFzLnB5) | `100.00% <100.00%> (ø)` | | | [reportsizedeltas/tests/test\_reportsizedeltas.py](https://codecov.io/gh/arduino/report-size-deltas/pull/31?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=arduino#diff-cmVwb3J0c2l6ZWRlbHRhcy90ZXN0cy90ZXN0X3JlcG9ydHNpemVkZWx0YXMucHk=) | `100.00% <100.00%> (ø)` | | Help us with your feedback. Take ten seconds to tell us [how you rate us](https://about.codecov.io/nps?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=arduino). Have a feature suggestion? [Share it here.](https://app.codecov.io/gh/feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=arduino)

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Do you have feedback about the report comment? Let us know in this issue.