-
-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add pattern matching support for sketches report artifact names #78
Commits on Jan 22, 2024
-
Refactor artifact ZIP file path code
Previously the code for assembling the ZIP file path was duplicated.
Configuration menu - View commit details
-
Copy full SHA for 9509908 - Browse repository at this point
Copy the full SHA 9509908View commit details -
Work with full workflow artifact data object from GitHub API
The GitHub API is used to discover the sketches report workflow artifacts. The artifact archive is then downloaded from the URL provided by the API response. Previously, the artifact discovery methods only returned the download URL. The API response also contains the somewhat useful information of the artifact name. Previously this information was discarded because the name is already available indirectly from the sketches-reports-source input value. However, that will no longer be the case once pattern matching support for the sketches-reports-source input is added. The code is refactored to pass the full data object received from the API for the artifact between the functions. This gives direct access to the exact artifact name.
Configuration menu - View commit details
-
Copy full SHA for 7a207ae - Browse repository at this point
Copy the full SHA 7a207aeView commit details -
Use pathlib module to work with workflow artifact archive paths
The sketches report workflow artifact is downloaded to a temporary folder and extracted. This requires working with paths. The pathlib module provides convenient and safe path handling and so should be used whenever there is significant involvement of paths in code.
Configuration menu - View commit details
-
Copy full SHA for 2a23433 - Browse repository at this point
Copy the full SHA 2a23433View commit details -
The code iterates through the folder containing the sketches reports. The iteration code returns the full path to each sketches report file. However, for some reason that path was joined to itself when it was passed to `open`. Fortunately the pathlib module is smart enough to handle the joining of two identical absolute paths so this didn't cause a problem but it is pointless and confusing so the redundant path joining code is removed.
Configuration menu - View commit details
-
Copy full SHA for c438d0b - Browse repository at this point
Copy the full SHA c438d0bView commit details -
Move coverage for get_artifact failure to dedicated unit test
Previously, the test_get_artifact unit test was configured to provide coverage for the normal operation of the get_artifact function as well as its behavior when unable to download the workflow artifact. The code used to test the normal operation was almost completely unnecessary for testing the failure condition and the code for adjusting the test behavior depending on which conditions were intended to be covered added significant complexity. Since the failure is expected to occur under normal operating conditions due to transient network outages, it is worth continuing to provide coverage for this. So the chosen approach to providing coverage without negatively impacting the test code is to move it to a dedicated test.
Configuration menu - View commit details
-
Copy full SHA for 761a650 - Browse repository at this point
Copy the full SHA 761a650View commit details -
Add pattern matching support for sketches report artifact names
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 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 "arduino/report-size-deltas" action bump.
Configuration menu - View commit details
-
Copy full SHA for 2251c6c - Browse repository at this point
Copy the full SHA 2251c6cView commit details