Skip to content

Commit 68365ab

Browse files
committed
Rename all occurrences of "size deltas report" to "deltas report"
The report may contain deltas data other than size, so the previous name was too constraining. The only remaining use of "size deltas report" is the default sketches report path: 'size-deltas-reports'. For backwards compatibility, the `enable-size-deltas-report` input will still be supported, but a warning will be displayed in the workflow run log notifying the user of the name change.
1 parent 62cc4d7 commit 68365ab

File tree

4 files changed

+67
-45
lines changed

4 files changed

+67
-45
lines changed

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,9 +114,9 @@ Path in which to save a JSON formatted file containing data from the sketch comp
114114

115115
### `github-token`
116116

117-
GitHub access token used to get information from the GitHub API. Only needed for private repositories with `enable-size-deltas-report` set to `true`. It will be convenient to use [`${{ secrets.GITHUB_TOKEN }}`](https://help.github.com/en/actions/configuring-and-managing-workflows/authenticating-with-the-github_token). Default `""`.
117+
GitHub access token used to get information from the GitHub API. Only needed for private repositories with `enable-deltas-report` set to `true`. It will be convenient to use [`${{ secrets.GITHUB_TOKEN }}`](https://help.github.com/en/actions/configuring-and-managing-workflows/authenticating-with-the-github_token). Default `""`.
118118

119-
### `enable-size-deltas-report`
119+
### `enable-deltas-report`
120120

121121
Set to `true` to cause the action to determine the change in memory usage of the compiled sketches. If the workflow is triggered by a `pull_request` event, the comparison is between the pull request branch and the tip of the pull request's base branch. If the workflow is triggered by a `push` event, the comparison is between the pushed commit and its immediate parent. 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`.
122122

@@ -137,7 +137,7 @@ Storing the memory usage change report as a [workflow artifact](https://help.git
137137
```yaml
138138
- uses: arduino/actions/libraries/compile-examples@master
139139
with:
140-
enable-size-deltas-report: true
140+
enable-deltas-report: true
141141
- if: github.event_name == 'pull_request'
142142
uses: actions/upload-artifact@v1
143143
with:

action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ inputs:
2525
github-token:
2626
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.'
2727
default: ''
28-
enable-size-deltas-report:
28+
enable-deltas-report:
2929
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 and the immediate parent commit of a push'
3030
default: false
3131
runs:

compilesketches/compilesketches.py

Lines changed: 16 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,11 @@ def main():
2828
"sketches-report-path instead.")
2929
os.environ["INPUT_SKETCHES-REPORT-PATH"] = os.environ["INPUT_SIZE-DELTAS-REPORT-FOLDER-NAME"]
3030

31+
if "INPUT_ENABLE-SIZE-DELTAS-REPORT" in os.environ:
32+
print("::warning::The enable-size-deltas-report input is deprecated. Use the equivalent input: "
33+
"enable-deltas-report instead.")
34+
os.environ["INPUT_ENABLE-DELTAS-REPORT"] = os.environ["INPUT_ENABLE-SIZE-DELTAS-REPORT"]
35+
3136
if "INPUT_ENABLE-SIZE-TRENDS-REPORT" in os.environ:
3237
print("::warning::The size trends report feature has been moved to a dedicated action. See the documentation "
3338
"at https://github.com/arduino/actions/tree/report-size-trends-action/libraries/report-size-trends")
@@ -40,7 +45,7 @@ def main():
4045
sketch_paths=os.environ["INPUT_SKETCH-PATHS"],
4146
verbose=os.environ["INPUT_VERBOSE"],
4247
github_token=os.environ["INPUT_GITHUB-TOKEN"],
43-
enable_size_deltas_report=os.environ["INPUT_ENABLE-SIZE-DELTAS-REPORT"],
48+
enable_deltas_report=os.environ["INPUT_ENABLE-DELTAS-REPORT"],
4449
sketches_report_path=os.environ["INPUT_SKETCHES-REPORT-PATH"]
4550
)
4651

@@ -60,7 +65,7 @@ class CompileSketches:
6065
recursively for sketches.
6166
verbose -- set to "true" for verbose output ("true", "false")
6267
github_token -- GitHub access token
63-
enable_size_deltas_report -- set to "true" to cause the action to determine the change in memory usage
68+
enable_deltas_report -- set to "true" to cause the action to determine the change in memory usage
6469
("true", "false")
6570
sketches_report_path -- folder to save the sketches report to
6671
"""
@@ -106,7 +111,7 @@ class ReportKeys:
106111
latest_release_indicator = "latest"
107112

108113
def __init__(self, cli_version, fqbn_arg, platforms, libraries, sketch_paths, verbose, github_token,
109-
enable_size_deltas_report, sketches_report_path):
114+
enable_deltas_report, sketches_report_path):
110115
"""Process, store, and validate the action's inputs."""
111116
self.cli_version = cli_version
112117

@@ -129,13 +134,13 @@ def __init__(self, cli_version, fqbn_arg, platforms, libraries, sketch_paths, ve
129134
else:
130135
self.github_api = github.Github(login_or_token=github_token)
131136

132-
self.enable_size_deltas_report = parse_boolean_input(boolean_input=enable_size_deltas_report)
133-
# The enable-size-deltas-report input has a default value so it should always be either True or False
134-
if self.enable_size_deltas_report is None:
135-
print("::error::Invalid value for enable-size-deltas-report input")
137+
self.enable_deltas_report = parse_boolean_input(boolean_input=enable_deltas_report)
138+
# The enable-deltas-report input has a default value so it should always be either True or False
139+
if self.enable_deltas_report is None:
140+
print("::error::Invalid value for enable-deltas-report input")
136141
sys.exit(1)
137142

138-
if self.enable_size_deltas_report:
143+
if self.enable_deltas_report:
139144
self.deltas_base_ref = self.get_deltas_base_ref()
140145
else:
141146
# If deltas reports are not enabled, there is no use for the base ref and it could result in an GitHub API
@@ -882,7 +887,7 @@ def get_sketch_report(self, compilation_result):
882887
"""
883888
current_sizes = self.get_sizes_from_output(compilation_result=compilation_result)
884889
previous_sizes = None
885-
if self.do_size_deltas_report(compilation_result=compilation_result, current_sizes=current_sizes):
890+
if self.do_deltas_report(compilation_result=compilation_result, current_sizes=current_sizes):
886891
# Get data for the sketch at the base ref
887892
# Get the head ref
888893
repository = git.Repo(path=os.environ["GITHUB_WORKSPACE"])
@@ -1003,15 +1008,15 @@ def get_size_data_from_output(self, compilation_output, memory_type, size_data_t
10031008

10041009
return size_data
10051010

1006-
def do_size_deltas_report(self, compilation_result, current_sizes):
1011+
def do_deltas_report(self, compilation_result, current_sizes):
10071012
"""Return whether size deltas reporting is enabled.
10081013
10091014
Keyword arguments:
10101015
compilation_result -- object returned by compile_sketch()
10111016
current_sizes -- memory usage data from the compilation
10121017
"""
10131018
return (
1014-
self.enable_size_deltas_report
1019+
self.enable_deltas_report
10151020
and compilation_result.success
10161021
and any(size.get(self.ReportKeys.absolute) != self.not_applicable_indicator for
10171022
size in current_sizes)

compilesketches/tests/test_compilesketches.py

Lines changed: 47 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ def get_compilesketches_object(
2929
github_token="",
3030
github_api=unittest.mock.sentinel.github_api,
3131
deltas_base_ref="foodeltasbaseref",
32-
enable_size_deltas_report="false",
32+
enable_deltas_report="false",
3333
sketches_report_path="foo report_folder_name"
3434
):
3535
with unittest.mock.patch("compilesketches.CompileSketches.get_deltas_base_ref",
@@ -42,7 +42,7 @@ def get_compilesketches_object(
4242
sketch_paths=sketch_paths,
4343
verbose=verbose,
4444
github_token=github_token,
45-
enable_size_deltas_report=enable_size_deltas_report,
45+
enable_deltas_report=enable_deltas_report,
4646
sketches_report_path=sketches_report_path)
4747

4848
compilesketches_object.github_api = github_api
@@ -80,6 +80,9 @@ def test_directories_are_same():
8080

8181

8282
@pytest.mark.parametrize("use_size_report_sketch", [True, False])
83+
@pytest.mark.parametrize("use_enable_size_deltas_report, expected_enable_deltas_report",
84+
[(True, "FooEnableSizeDeltasReport"),
85+
(False, "FooEnableDeltasReport")])
8386
@pytest.mark.parametrize("use_size_deltas_report_folder_name, expected_sketches_report_path",
8487
[(True, "FooSizeDeltasReportFolderName"),
8588
(False, "FooSketchesReportPath")])
@@ -88,6 +91,8 @@ def test_main(capsys,
8891
monkeypatch,
8992
mocker,
9093
use_size_report_sketch,
94+
use_enable_size_deltas_report,
95+
expected_enable_deltas_report,
9196
use_size_deltas_report_folder_name,
9297
expected_sketches_report_path,
9398
use_enable_size_trends_report):
@@ -98,7 +103,8 @@ def test_main(capsys,
98103
sketch_paths = "foo/Sketch bar/OtherSketch"
99104
verbose = "true"
100105
github_token = "FooGitHubToken"
101-
enable_size_deltas_report = "true"
106+
enable_size_deltas_report = "FooEnableSizeDeltasReport"
107+
enable_deltas_report = "FooEnableDeltasReport"
102108
sketches_report_path = "FooSketchesReportPath"
103109
size_deltas_report_folder_name = "FooSizeDeltasReportFolderName"
104110

@@ -115,7 +121,9 @@ def compile_sketches(self):
115121
monkeypatch.setenv("INPUT_VERBOSE", verbose)
116122
if use_size_report_sketch:
117123
monkeypatch.setenv("INPUT_SIZE-REPORT-SKETCH", "foo")
118-
monkeypatch.setenv("INPUT_ENABLE-SIZE-DELTAS-REPORT", enable_size_deltas_report)
124+
if use_enable_size_deltas_report:
125+
monkeypatch.setenv("INPUT_ENABLE-SIZE-DELTAS-REPORT", enable_size_deltas_report)
126+
monkeypatch.setenv("INPUT_ENABLE-DELTAS-REPORT", enable_deltas_report)
119127
monkeypatch.setenv("INPUT_SKETCHES-REPORT-PATH", sketches_report_path)
120128
if use_size_deltas_report_folder_name:
121129
monkeypatch.setenv("INPUT_SIZE-DELTAS-REPORT-FOLDER-NAME", size_deltas_report_folder_name)
@@ -138,6 +146,14 @@ def compile_sketches(self):
138146
+ "::warning::The size-deltas-report-folder-name input is deprecated. Use the equivalent input: "
139147
"sketches-report-path instead."
140148
)
149+
if use_enable_size_deltas_report:
150+
if expected_output != "":
151+
expected_output = expected_output + "\n"
152+
expected_output = (
153+
expected_output
154+
+ "::warning::The enable-size-deltas-report input is deprecated. Use the equivalent input: "
155+
"enable-deltas-report instead."
156+
)
141157
if use_enable_size_trends_report:
142158
if expected_output != "":
143159
expected_output = expected_output + "\n"
@@ -157,7 +173,7 @@ def compile_sketches(self):
157173
sketch_paths=sketch_paths,
158174
verbose=verbose,
159175
github_token=github_token,
160-
enable_size_deltas_report=enable_size_deltas_report,
176+
enable_deltas_report=expected_enable_deltas_report,
161177
sketches_report_path=expected_sketches_report_path
162178
)
163179
CompileSketches.compile_sketches.assert_called_once()
@@ -175,7 +191,7 @@ def test_compilesketches():
175191
verbose = "false"
176192
github_token = "fooGitHubToken"
177193
expected_deltas_base_ref = unittest.mock.sentinel.deltas_base_ref
178-
enable_size_deltas_report = "true"
194+
enable_deltas_report = "true"
179195
sketches_report_path = "FooSketchesReportFolder"
180196

181197
with unittest.mock.patch("compilesketches.CompileSketches.get_deltas_base_ref",
@@ -189,7 +205,7 @@ def test_compilesketches():
189205
sketch_paths=sketch_paths,
190206
verbose=verbose,
191207
github_token=github_token,
192-
enable_size_deltas_report=enable_size_deltas_report,
208+
enable_deltas_report=enable_deltas_report,
193209
sketches_report_path=sketches_report_path
194210
)
195211

@@ -201,15 +217,15 @@ def test_compilesketches():
201217
assert compile_sketches.sketch_paths == expected_sketch_paths_list
202218
assert compile_sketches.verbose is False
203219
assert compile_sketches.deltas_base_ref == expected_deltas_base_ref
204-
assert compile_sketches.enable_size_deltas_report is True
220+
assert compile_sketches.enable_deltas_report is True
205221
assert compile_sketches.sketches_report_path == pathlib.PurePath(sketches_report_path)
206222

207-
# Test invalid enable_size_deltas_report value
223+
# Test invalid enable_deltas_report value
208224
with pytest.raises(expected_exception=SystemExit, match="1"):
209-
get_compilesketches_object(enable_size_deltas_report="fooInvalidEnableSizeDeltasBoolean")
225+
get_compilesketches_object(enable_deltas_report="fooInvalidEnableSizeDeltasBoolean")
210226

211227
# Test deltas_base_ref when size deltas report is disabled
212-
compile_sketches = get_compilesketches_object(enable_size_deltas_report="false")
228+
compile_sketches = get_compilesketches_object(enable_deltas_report="false")
213229
assert compile_sketches.deltas_base_ref is None
214230

215231

@@ -1312,8 +1328,8 @@ class CompilationData:
13121328
assert compilation_result.output == stdout
13131329

13141330

1315-
@pytest.mark.parametrize("do_size_deltas_report", [True, False])
1316-
def test_get_sketch_report(mocker, do_size_deltas_report):
1331+
@pytest.mark.parametrize("do_deltas_report", [True, False])
1332+
def test_get_sketch_report(mocker, do_deltas_report):
13171333
original_git_ref = unittest.mock.sentinel.original_git_ref
13181334
sizes_list = [unittest.mock.sentinel.sketch_report_list1, unittest.mock.sentinel.sketch_report_list2]
13191335
sketch = "/foo/SketchName"
@@ -1345,8 +1361,8 @@ def checkout(self):
13451361

13461362
mocker.patch("compilesketches.CompileSketches.get_sizes_from_output", autospec=True,
13471363
side_effect=sizes_list)
1348-
mocker.patch("compilesketches.CompileSketches.do_size_deltas_report", autospec=True,
1349-
return_value=do_size_deltas_report)
1364+
mocker.patch("compilesketches.CompileSketches.do_deltas_report", autospec=True,
1365+
return_value=do_deltas_report)
13501366
mocker.patch("git.Repo", autospec=True, return_value=Repo())
13511367
mocker.patch("compilesketches.CompileSketches.checkout_deltas_base_ref", autospec=True)
13521368
mocker.patch("compilesketches.CompileSketches.compile_sketch", autospec=True,
@@ -1357,10 +1373,11 @@ def checkout(self):
13571373
sketch_report = compile_sketches.get_sketch_report(compilation_result=compilation_result)
13581374

13591375
get_sizes_from_output_calls = [unittest.mock.call(compile_sketches, compilation_result=compilation_result)]
1360-
compilesketches.CompileSketches.do_size_deltas_report.assert_called_once_with(compile_sketches,
1361-
compilation_result=compilation_result,
1362-
current_sizes=sizes_list[0])
1363-
if do_size_deltas_report:
1376+
# noinspection PyUnresolvedReferences
1377+
compilesketches.CompileSketches.do_deltas_report.assert_called_once_with(compile_sketches,
1378+
compilation_result=compilation_result,
1379+
current_sizes=sizes_list[0])
1380+
if do_deltas_report:
13641381
git.Repo.assert_called_once_with(path=os.environ["GITHUB_WORKSPACE"])
13651382
compile_sketches.checkout_deltas_base_ref.assert_called_once()
13661383
compile_sketches.compile_sketch.assert_called_once_with(compile_sketches, sketch_path=compilation_result.sketch)
@@ -1576,10 +1593,10 @@ def test_get_size_data_from_output(capsys, compilation_output, memory_type, size
15761593

15771594

15781595
@pytest.mark.parametrize(
1579-
"enable_size_deltas_report,"
1596+
"enable_deltas_report,"
15801597
"compilation_success,"
15811598
"current_sizes,"
1582-
"do_size_deltas_report_expected",
1599+
"do_deltas_report_expected",
15831600
[("true",
15841601
True,
15851602
[{compilesketches.CompileSketches.ReportKeys.name: "foo",
@@ -1605,19 +1622,19 @@ def test_get_size_data_from_output(capsys, compilation_output, memory_type, size
16051622
compilesketches.CompileSketches.ReportKeys.absolute: compilesketches.CompileSketches.not_applicable_indicator}],
16061623
False)]
16071624
)
1608-
def test_do_size_deltas_report(monkeypatch,
1609-
enable_size_deltas_report,
1610-
compilation_success,
1611-
current_sizes,
1612-
do_size_deltas_report_expected):
1613-
compile_sketches = get_compilesketches_object(enable_size_deltas_report=enable_size_deltas_report)
1625+
def test_do_deltas_report(monkeypatch,
1626+
enable_deltas_report,
1627+
compilation_success,
1628+
current_sizes,
1629+
do_deltas_report_expected):
1630+
compile_sketches = get_compilesketches_object(enable_deltas_report=enable_deltas_report)
16141631

16151632
compilation_result = type("CompilationResult", (),
16161633
{"sketch": "/foo/SketchName",
16171634
"success": compilation_success,
16181635
"output": "foo compilation output"})
1619-
assert compile_sketches.do_size_deltas_report(compilation_result=compilation_result,
1620-
current_sizes=current_sizes) == do_size_deltas_report_expected
1636+
assert compile_sketches.do_deltas_report(compilation_result=compilation_result,
1637+
current_sizes=current_sizes) == do_deltas_report_expected
16211638

16221639

16231640
def test_checkout_deltas_base_ref(monkeypatch, mocker):
@@ -1635,7 +1652,7 @@ def fetch(self):
16351652
def checkout(self):
16361653
pass # pragma: no cover
16371654

1638-
compile_sketches = get_compilesketches_object(enable_size_deltas_report="true", deltas_base_ref=deltas_base_ref)
1655+
compile_sketches = get_compilesketches_object(enable_deltas_report="true", deltas_base_ref=deltas_base_ref)
16391656

16401657
mocker.patch("git.Repo", autospec=True, return_value=Repo())
16411658
mocker.patch.object(Repo, "fetch")

0 commit comments

Comments
 (0)