Skip to content

Commit

Permalink
Tools: output ccache and diff size output to github action summary
Browse files Browse the repository at this point in the history
  • Loading branch information
khancyr committed Nov 25, 2024
1 parent c2291be commit 1644b64
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
15 changes: 15 additions & 0 deletions Tools/scripts/build_tests/pretty_diff_size.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,21 @@ def print_table(summary_data_list_second, summary_data_list_master):
print_data.append(col_data)
print(tabulate(print_data, headers=["Binary Name", "Text [B]", "Data [B]", "BSS (B)",
"Total Flash Change [B] (%)", "Flash Free After PR (B)"]))
# Get the GitHub Actions summary file path
summary_file = os.getenv('GITHUB_STEP_SUMMARY')
if summary_file:
# Append the output to the summary file
with open(summary_file, 'a') as f:
f.write("### Diff summary\n")
f.write(tabulate(print_data, headers=[
"Binary Name",
"Text [B]",
"Data [B]",
"BSS (B)",
"Total Flash Change [B] (%)",
"Flash Free After PR (B)"
], tablefmt="github"))
f.write("\n")


def extract_binaries_size(path):
Expand Down
13 changes: 12 additions & 1 deletion Tools/scripts/build_tests/test_ccache.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,22 @@ def build_board(boardname):
build_board(boards[0])
subprocess.run(["ccache", "-z"])
build_board(boards[1])
subprocess.run(["ccache", "-s"])
result = subprocess.run(["ccache", "-s"], capture_output=True, text=True)
print(result.stdout)

# Get the GitHub Actions summary file path
summary_file = os.getenv('GITHUB_STEP_SUMMARY')

post = ccache_stats()
hit_pct = 100 * post[0] / float(post[0]+post[1])
print("ccache hit percentage: %.1f%% %s" % (hit_pct, post))
if summary_file:
# Append the output to the summary file
with open(summary_file, 'a') as f:
f.write(f"### ccache -s Output with {boards}\n")
f.write(f"```\n{result.stdout}\n```\n")
f.write(f"### ccache hit percentage (min {args.min_cache_pct})\n")
f.write("ccache hit percentage: %.1f%% %s\n" % (hit_pct, post))
if hit_pct < args.min_cache_pct:
print("ccache hits too low, need %d%%" % args.min_cache_pct)
sys.exit(1)
Expand Down

0 comments on commit 1644b64

Please sign in to comment.