Skip to content

Commit 133d0f4

Browse files
committed
Add data for all sketches to the sketches report
Previously, the user was required to select an arbitrary sketch, and only data for that sketch was reported. It's not certain that a single sketch will provide sufficient coverage to produce comprehensive report data.
1 parent 9ce2215 commit 133d0f4

File tree

4 files changed

+52
-115
lines changed

4 files changed

+52
-115
lines changed

README.md

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -109,10 +109,6 @@ List of paths containing sketches to compile. These paths will be searched recur
109109

110110
Set to true to show verbose output in the log. Default `false`
111111

112-
### `size-report-sketch`
113-
114-
Name of the sketch used to compare memory usage change. Default `""`.
115-
116112
### `sketches-report-path`
117113

118114
Path in which to save a JSON formatted file containing data from the sketch compilations. Should be used only to store reports. Relative paths are relative to [`GITHUB_WORKSPACE`](https://help.github.com/en/actions/configuring-and-managing-workflows/using-environment-variables). The folder will be created if it doesn't already exist. This report is used by the `arduino/libraries/report-size-deltas` and `arduino/libraries/report-size-trends` actions. Default `"size-deltas-reports"`.
@@ -123,7 +119,7 @@ GitHub access token used to get information from the GitHub API. Only needed if
123119

124120
### `enable-size-deltas-report`
125121

126-
Set to `true` to cause the action to determine the change in memory usage for the [`size-reports-sketch`](#size-reports-sketch) between the pull request branch and the tip of the pull request's base branch. This may be used with the [`arduino/actions/libraries/report-size-deltas` action](https://github.com/arduino/actions/tree/master/libraries/report-size-deltas). Default `false`.
122+
Set to `true` to cause the action to determine the change in memory usage of the compiled sketches between the pull request branch and the tip of the pull request's base branch. This may be used with the [`arduino/actions/libraries/report-size-deltas` action](https://github.com/arduino/actions/tree/master/libraries/report-size-deltas). Default `false`.
127123

128124
## Example usage
129125

@@ -142,7 +138,6 @@ Storing the memory usage change report as a [workflow artifact](https://help.git
142138
```yaml
143139
- uses: arduino/actions/libraries/compile-examples@master
144140
with:
145-
size-report-sketch: Foobar
146141
enable-size-deltas-report: true
147142
- if: github.event_name == 'pull_request'
148143
uses: actions/upload-artifact@v1

action.yml

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,14 @@ inputs:
1919
verbose:
2020
description: 'Set to true to show verbose output in the log'
2121
default: false
22-
size-report-sketch:
23-
description: 'Name of the sketch used to compare memory usage change'
24-
default: ''
2522
sketches-report-path:
2623
description: 'Path in which to save a JSON formatted file containing data from the sketch compilations'
2724
default: 'size-deltas-reports'
2825
github-token:
2926
description: 'GitHub access token used to get information from the GitHub API. Only needed if you are using the size deltas report feature with a private repository.'
3027
default: ''
3128
enable-size-deltas-report:
32-
description: 'Set to true to cause the action to determine the change in memory usage for the size-reports-sketch'
29+
description: 'Set to true to cause the action to determine the change in memory usage of the compiled sketches between the head and base refs of a PR'
3330
default: false
3431
runs:
3532
using: 'docker'

compilesketches/compilesketches.py

Lines changed: 12 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,9 @@
2020

2121

2222
def main():
23+
if "INPUT_SIZE-REPORT-SKETCH" in os.environ:
24+
print("::warning::The size-report-sketch input is no longer used")
25+
2326
if "INPUT_SIZE-DELTAS-REPORT-FOLDER-NAME" in os.environ:
2427
print("::warning::The size-deltas-report-folder-name input is deprecated. Use the equivalent input: "
2528
"sketches-report-path instead.")
@@ -37,7 +40,6 @@ def main():
3740
sketch_paths=os.environ["INPUT_SKETCH-PATHS"],
3841
verbose=os.environ["INPUT_VERBOSE"],
3942
github_token=os.environ["INPUT_GITHUB-TOKEN"],
40-
report_sketch=os.environ["INPUT_SIZE-REPORT-SKETCH"],
4143
enable_size_deltas_report=os.environ["INPUT_ENABLE-SIZE-DELTAS-REPORT"],
4244
sketches_report_path=os.environ["INPUT_SKETCHES-REPORT-PATH"]
4345
)
@@ -58,9 +60,8 @@ class CompileSketches:
5860
recursively for sketches.
5961
verbose -- set to "true" for verbose output ("true", "false")
6062
github_token -- GitHub access token
61-
report_sketch -- name of the sketch to make the report for
62-
enable_size_deltas_report -- set to "true" to cause the action to determine the change in memory usage for the
63-
report_sketch ("true", "false")
63+
enable_size_deltas_report -- set to "true" to cause the action to determine the change in memory usage
64+
("true", "false")
6465
sketches_report_path -- folder to save the sketches report to
6566
"""
6667

@@ -101,7 +102,7 @@ class ReportKeys:
101102

102103
latest_release_indicator = "latest"
103104

104-
def __init__(self, cli_version, fqbn_arg, platforms, libraries, sketch_paths, verbose, github_token, report_sketch,
105+
def __init__(self, cli_version, fqbn_arg, platforms, libraries, sketch_paths, verbose, github_token,
105106
enable_size_deltas_report, sketches_report_path):
106107
"""Process, store, and validate the action's inputs."""
107108
self.cli_version = cli_version
@@ -125,8 +126,6 @@ def __init__(self, cli_version, fqbn_arg, platforms, libraries, sketch_paths, ve
125126
else:
126127
self.github_api = github.Github(login_or_token=github_token)
127128

128-
self.report_sketch = report_sketch
129-
130129
self.enable_size_deltas_report = parse_boolean_input(boolean_input=enable_size_deltas_report)
131130
# The enable-size-deltas-report input has a default value so it should always be either True or False
132131
if self.enable_size_deltas_report is None:
@@ -135,10 +134,6 @@ def __init__(self, cli_version, fqbn_arg, platforms, libraries, sketch_paths, ve
135134

136135
self.sketches_report_path = pathlib.PurePath(sketches_report_path)
137136

138-
if self.enable_size_deltas_report and self.report_sketch == "":
139-
print("::error::size-report-sketch input was not defined")
140-
sys.exit(1)
141-
142137
def compile_sketches(self):
143138
"""Do compilation tests and record data."""
144139
self.install_arduino_cli()
@@ -151,7 +146,7 @@ def compile_sketches(self):
151146

152147
# Compile all sketches under the paths specified by the sketch-paths input
153148
all_compilations_successful = True
154-
sketches_report = []
149+
sketch_report_list = []
155150

156151
sketch_list = self.find_sketches()
157152
for sketch in sketch_list:
@@ -160,14 +155,11 @@ def compile_sketches(self):
160155
all_compilations_successful = False
161156

162157
# Store the size data for this sketch
163-
sketches_report.append(self.get_sketch_report(compilation_result=compilation_result))
158+
sketch_report_list.append(self.get_sketch_report(compilation_result=compilation_result))
164159

165-
if self.report_sketch != "":
166-
# Make sketch reports
167-
sketch_report = self.get_sketch_report_from_sketches_report(sketches_report=sketches_report)
168-
# TODO: The current behavior is to only write the report for the report sketch, but the plan is to change to
169-
# reporting data for all sketches, thus the passing of sketch_report to the function
170-
self.create_sketches_report_file(sketches_report=sketch_report)
160+
sketches_report = self.get_sketches_report(sketch_report_list=sketch_report_list)
161+
162+
self.create_sketches_report_file(sketches_report=sketches_report)
171163

172164
if not all_compilations_successful:
173165
print("::error::One or more compilations failed")
@@ -802,22 +794,6 @@ def get_sketch_report(self, compilation_result):
802794

803795
return sketch_report
804796

805-
def get_sketch_report_from_sketches_report(self, sketches_report):
806-
"""Return the report for the report sketch
807-
Keyword arguments:
808-
sketches_report -- list containing the reports for all sketches
809-
"""
810-
# TODO: The plan is to switch to reporting memory usage data for all sketches, rather than only a single sketch.
811-
# The current system of unnecessarily storing data for all sketches, then searching back through it for a
812-
# single item to report is in anticipation of that change
813-
for sketch_report in sketches_report:
814-
if self.is_report_sketch(sketch_path=sketch_report[self.ReportKeys.name]):
815-
return sketch_report
816-
817-
# Data for the size reports sketch was not found
818-
print("::error::size-report-sketch:", self.report_sketch, "was not found")
819-
sys.exit(1)
820-
821797
def get_sizes_from_output(self, compilation_result):
822798
"""Parse the stdout from the compilation process and return a list containing memory usage data.
823799
@@ -870,7 +846,7 @@ def get_sizes_from_output(self, compilation_result):
870846
return sizes
871847

872848
def do_size_deltas_report(self, compilation_result, current_sizes):
873-
"""Return whether size deltas reporting is enabled for the given sketch.
849+
"""Return whether size deltas reporting is enabled.
874850
875851
Keyword arguments:
876852
compilation_result -- object returned by compile_sketch()
@@ -879,23 +855,11 @@ def do_size_deltas_report(self, compilation_result, current_sizes):
879855
return (
880856
self.enable_size_deltas_report
881857
and os.environ["GITHUB_EVENT_NAME"] == "pull_request"
882-
and self.is_report_sketch(sketch_path=compilation_result.sketch)
883858
and compilation_result.success
884859
and any(size.get(self.ReportKeys.absolute) != self.not_applicable_indicator for
885860
size in current_sizes)
886861
)
887862

888-
def is_report_sketch(self, sketch_path):
889-
"""Return whether the given sketch is the report sketch.
890-
891-
Keyword arguments:
892-
sketch_path -- path to the sketch
893-
"""
894-
# TODO: yes, it was silly to identify the report sketch only by the name, rather than the path, but the whole
895-
# concept of the size report sketch will be removed soon when the behavior is switched to reporting memory
896-
# usage for all sketches. So for now, it's best to simply continue with the existing behavior.
897-
return pathlib.PurePath(sketch_path).name == self.report_sketch
898-
899863
def checkout_pull_request_base_ref(self):
900864
"""git checkout the base ref of the pull request"""
901865
repository = git.Repo(path=os.environ["GITHUB_WORKSPACE"])

0 commit comments

Comments
 (0)