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

Add pattern matching support for sketches report artifact names #78

Closed per1234 closed 9 months ago

per1234 commented 9 months ago

Background

The action was originally designed for a use case where there will only be a single sketches reports workflow artifact. At that time, this was possible even in cases where a job matrix was used to generate multiple parallel jobs to compile a set of sketches for an array of boards because the "actions/upload-artifact" GitHub Actions action allowed a single artifact to be uploaded to multiple times (one upload for the sketches report file of each of the matrix jobs).

Uploading multiple times to a single artifact is prohibited starting from the recently released version 4.0.0 of the "actions/upload-artifact" action. It now becomes necessary for each of the sketch compilation matrix jobs to produce a separate artifact, and for the "arduino/report-size-deltas" action to be able to consume the reports from multiple artifacts.

Changes

Artifact Name Pattern Support

The most convenient way for the user to configure the action to identify the artifacts containing sketches reports is through an artifact name matching pattern. This will allow the user to avoid the need to maintain a list of explicit artifact names in the "arduino/report-size-deltas" workflow that can change over time as coverage for various boards is added to the sketch compilation workflow. The pattern is set via the action's sketches-reports-source input.


NOTE: pattern support is only added for the use case where the action is ran from a scheduled workflow and the action's sketches-reports-source input is defining the artifact names to download. In the use case where the user is running the "arduino/report-size-deltas" action from the same workflow that does the sketch compilations, the action's sketches-reports-source input continues to be used to define the explicit path to the folder that contains the sketches report files. Pattern support was not added in this use case because there is no need for or benefit from such a feature.


Recursive Sketches Reports Path Processing

In the use case where the user is running the "arduino/report-size-deltas" action from the same workflow that does the sketch compilations, the action's sketches-reports-source input is used to define the path to the folder that contains the sketches report files.

In the common use pattern where workflow artifacts are used to transfer the sketches report files from a job matrix that compiles the sketches for multiple boards to the job with the arduino/report-size-deltas step, the "actions/download-artifact" action will be used to download the artifacts into the runner workspace, using that action's artifact name pattern matching capability. By default, the artifacts will each be downloaded to a dedicated folder under the folder specified via the "actions/download-artifact" action's path input. For this reason, it will be convenient for the "arduino/report-size-deltas" action to collect sketches reports recursively from each of the subfolders of the folder specified via the sketches-reports-source input.

The "actions/download-artifact" action does provide a merge-multiple input that could be used to change that action's behavior to putting all the files in the root of the folder specified via its path input. However, requiring this of the "arduino/report-size-deltas" action users is less friendly, and is actually technically inferior in that it introduces the possibility of a filename collision in the event multiple artifacts contain a report file of the same name (as would occur if the sketch compilation job matrix was configured to use the same FQBN in multiple jobs).

Backwards Compatibility

Backwards compatibility for existing workflow is retained because the explicit artifact name in the sketches-reports-source input will also serve as a pattern to match the single artifact.

If the user wants to update the "actions/upload-artifact" action in their sketch compilation workflow, and that workflow uploads multiple times to the same artifact, they will need to migrate the sketch compilation workflow to the new system, and might also update the "arduino/report-size-deltas" action's sketches-reports-source input to reflect that change, but that is a breaking change imposed by the "actions/upload-artifact" action bump, not by the change made here to the "arduino/report-size-deltas" action.

Additional Context

Resolves https://github.com/arduino/report-size-deltas/issues/55

codecov-commenter commented 9 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Comparison is base (c387258) 100.00% compared to head (2251c6c) 100.00%.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #78 +/- ## ========================================= Coverage 100.00% 100.00% ========================================= Files 2 2 Lines 731 740 +9 ========================================= + Hits 731 740 +9 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.