Tools: output ccache and diff size output to github action summary

This commit is contained in:
Pierre Kancir 2024-11-25 16:41:48 +01:00 committed by Peter Barker
parent 2cd0ac1e35
commit bfc94b6e02
2 changed files with 27 additions and 1 deletions

View File

@ -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):

View File

@ -65,11 +65,22 @@ subprocess.run(["ccache", "-C", "-z"])
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)