diff options
author | Kirill Rysin <35688753+naspirato@users.noreply.github.com> | 2024-06-19 22:20:58 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-06-19 20:20:58 +0000 |
commit | 57278d73a2020c7e12fdea425b1fef82a658b826 (patch) | |
tree | 856a394e4e50dddff5dbf161b39d9f8cfb2c88f5 | |
parent | 62869e935a423d6e7e714313aa480ce10986e1d2 (diff) | |
download | ydb-57278d73a2020c7e12fdea425b1fef82a658b826.tar.gz |
Buid diff table in pr (#5709)
-rwxr-xr-x | .github/scripts/get_build_diff.py | 42 |
1 files changed, 28 insertions, 14 deletions
diff --git a/.github/scripts/get_build_diff.py b/.github/scripts/get_build_diff.py index 30ba3f46c4..7c02904950 100755 --- a/.github/scripts/get_build_diff.py +++ b/.github/scripts/get_build_diff.py @@ -36,41 +36,55 @@ def main(): current_size_stripped_bytes = int(current_sizes_result["size_stripped_bytes"]) bytes_diff = current_size_bytes - main_size_bytes + stripped_bytes_diff = current_size_stripped_bytes - main_size_stripped_bytes + diff_perc = Decimal(bytes_diff * 100 / main_size_bytes).quantize( Decimal(".001"), rounding=ROUND_HALF_UP ) + stripped_diff_perc = Decimal( + stripped_bytes_diff * 100 / main_size_stripped_bytes + ).quantize(Decimal(".001"), rounding=ROUND_HALF_UP) human_readable_size = bytes_to_human_iec(current_size_bytes) human_readable_size_diff = bytes_to_human_iec(bytes_diff) - - if bytes_diff >= 0: + human_readable_stripped_size_diff = bytes_to_human_iec(stripped_bytes_diff) + if bytes_diff > 0: sign = "+" if bytes_diff >= red_treshold: color = "red" + summary_core = f" >= {bytes_to_human_iec(red_treshold)} vs {branch}: **Alert**" elif bytes_diff >= yellow_treshold: color = "yellow" + summary_core = f" >= {bytes_to_human_iec(yellow_treshold)} vs {branch}: **Warning**" else: color = "green" + summary_core = f" < {bytes_to_human_iec(yellow_treshold)} vs {branch}: **OK**" else: sign = "" color = "green" + summary_core = f" <= 0 Bytes vs {branch}: **OK**" + + if stripped_diff_perc > 0: + stripped_sign = "+" + else: + stripped_sign = "" + + summary_start = f"ydbd size **{human_readable_size}** changed by **{sign}{human_readable_size_diff}**, which is" + summary = f"{summary_start}{summary_core}" comment = ( - f"merge: {current_pr_commit_sha} ydbd size {human_readable_size} **{sign}{human_readable_size_diff} {sign}{diff_perc}%%** vs build {branch}: {main_github_sha}\n\n" - "<details><summary>Build size details</summary><p>\n\n" - f"{branch}: {main_github_sha} ydbd build size:\n" - f" - binary size **{format_number(main_size_bytes)}** Bytes \n" - f" - stripped binary size **{format_number(main_size_stripped_bytes)}** Bytes\n\n" - f"merge: {current_pr_commit_sha} ydbd build size:\n" - f" - binary size **{format_number(current_size_bytes)}** Bytes \n" - f" - stripped binary size **{format_number(current_size_stripped_bytes)}** Bytes\n\n" - "[ydbd size dashboard](https://datalens.yandex/cu6hzmpaki700)\n\n" - "</p></details>" + f"{summary}\n" + f"|[ydbd size dash](https://datalens.yandex/cu6hzmpaki700)|{branch}: {main_github_sha} |merge: {current_pr_commit_sha} |diff | diff %%|\n" + f"|:--- | ---: | ---: | ---: | ---: |\n" + f"|ydbd size|**{format_number(main_size_bytes)}** Bytes |**{format_number(current_size_bytes)}** Bytes|**{sign}{human_readable_size_diff}**|**{sign}{diff_perc}%%**|\n" + f"|ydbd stripped size|**{format_number(main_size_stripped_bytes)}** Bytes|**{format_number(current_size_stripped_bytes)}** Bytes|**{stripped_sign}{human_readable_stripped_size_diff}**|**{stripped_sign}{stripped_diff_perc}%%**|\n\n" ) print(f"{color};;;{comment}") else: - print(f'Error: Cant get build data: {branch}_sizes_result = {main_sizes_result}, current_sizes_result = {current_sizes_result}') - + print( + f"Error: Cant get build data: {branch}_sizes_result = {main_sizes_result}, current_sizes_result = {current_sizes_result}" + ) + if __name__ == "__main__": main() |