Skip to content

Commit 07d3be6

Browse files
committed
move out of log group; change units of time
elapsed time is only output if compilation did not fail.
1 parent bbcb464 commit 07d3be6

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

compilesketches/compilesketches.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -898,18 +898,11 @@ def compile_sketch(self, sketch_path, clean_build_cache):
898898
compilation_data = self.run_arduino_cli_command(
899899
command=compilation_command, enable_output=self.RunCommandOutput.NONE, exit_on_failure=False)
900900
diff_time = time.monotonic() - start_time
901-
time_summary = ""
902-
if diff_time > 60:
903-
if diff_time > 360:
904-
time_summary += f"{int(diff_time / 360)} hours "
905-
time_summary += f"{int(diff_time / 60) % 60} minutes "
906-
time_summary += f"{int(diff_time) % 60} seconds."
907901

908902
# Group compilation output to make the log easy to read
909903
# https://github.com/actions/toolkit/blob/master/docs/commands.md#group-and-ungroup-log-lines
910904
print("::group::Compiling sketch:", path_relative_to_workspace(path=sketch_path))
911905
print(compilation_data.stdout)
912-
print("Compilation time elapsed", time_summary)
913906
print("::endgroup::")
914907

915908
class CompilationResult:
@@ -919,6 +912,14 @@ class CompilationResult:
919912

920913
if not CompilationResult.success:
921914
print("::error::Compilation failed")
915+
else:
916+
time_summary = ""
917+
if diff_time > 60:
918+
if diff_time > 360:
919+
time_summary += f"{int(diff_time / 360)} h "
920+
time_summary += f"{int(diff_time / 60) % 60} m "
921+
time_summary += f"{int(diff_time) % 60} s"
922+
print("Compilation time elapsed", time_summary)
922923

923924
return CompilationResult()
924925

compilesketches/tests/test_compilesketches.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1435,11 +1435,12 @@ class CompilationData:
14351435
expected_stdout = (
14361436
"::group::Compiling sketch: " + str(compilesketches.path_relative_to_workspace(path=sketch_path)) + "\n"
14371437
+ str(stdout) + "\n"
1438-
+ "Compilation time elapsed 0 seconds.\n"
14391438
+ "::endgroup::"
14401439
)
14411440
if not expected_success:
14421441
expected_stdout += "\n::error::Compilation failed"
1442+
else:
1443+
expected_stdout += "\nCompilation time elapsed 0s"
14431444
assert capsys.readouterr().out.strip() == expected_stdout
14441445

14451446
assert compilation_result.sketch == sketch_path

0 commit comments

Comments
 (0)