Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion compilesketches/compilesketches.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import atexit
import time
import contextlib
import enum
import json
Expand Down Expand Up @@ -893,9 +894,11 @@ def compile_sketch(self, sketch_path, clean_build_cache):
if clean_build_cache:
for cache_path in pathlib.Path("/tmp").glob(pattern="arduino*"):
shutil.rmtree(path=cache_path)

start_time = time.monotonic()
compilation_data = self.run_arduino_cli_command(
command=compilation_command, enable_output=self.RunCommandOutput.NONE, exit_on_failure=False)
diff_time = time.monotonic() - start_time

# Group compilation output to make the log easy to read
# https://github.com/actions/toolkit/blob/master/docs/commands.md#group-and-ungroup-log-lines
print("::group::Compiling sketch:", path_relative_to_workspace(path=sketch_path))
Expand All @@ -909,6 +912,14 @@ class CompilationResult:

if not CompilationResult.success:
print("::error::Compilation failed")
else:
time_summary = ""
if diff_time > 60:
if diff_time > 360:
time_summary += f"{int(diff_time / 360)}h "
time_summary += f"{int(diff_time / 60) % 60}m "
time_summary += f"{int(diff_time) % 60}s"
print("Compilation time elapsed:", time_summary)

return CompilationResult()

Expand Down
2 changes: 2 additions & 0 deletions compilesketches/tests/test_compilesketches.py
Original file line number Diff line number Diff line change
Expand Up @@ -1439,6 +1439,8 @@ class CompilationData:
)
if not expected_success:
expected_stdout += "\n::error::Compilation failed"
else:
expected_stdout += "\nCompilation time elapsed: 0s"
assert capsys.readouterr().out.strip() == expected_stdout

assert compilation_result.sketch == sketch_path
Expand Down