From 023a516a7c9a1b143b6a8d599744dbf13df9a4d6 Mon Sep 17 00:00:00 2001 From: alex Date: Tue, 24 Aug 2021 11:22:24 +0100 Subject: [PATCH] Comment progress change on pull requests (#382) also: * match jp nuContRmbForceStop * progress.py: emit progress delta by default --- Jenkinsfile | 42 ++++++++++++++++--- progress.py | 40 +++++++++++++++++- src/jp/os/nusys/3B150.c | 8 +++- .../os/nusys/3B150/nuContRmbForceStop.s | 12 ------ 4 files changed, 83 insertions(+), 19 deletions(-) delete mode 100644 ver/jp/asm/nonmatchings/os/nusys/3B150/nuContRmbForceStop.s diff --git a/Jenkinsfile b/Jenkinsfile index e7f33aa306..a6bb024017 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -18,6 +18,38 @@ pipeline { sh 'ninja' } } + stage("Comment") { + when { + not { + branch 'master' + } + } + steps { + script { + if (env.CHANGE_ID) { + def us_progress = sh(returnStdout: true, script: "python3 progress.py us --pr-comment").trim() + def jp_progress = sh(returnStdout: true, script: "python3 progress.py jp --pr-comment").trim() + def comment_id = -1 + + for (comment in pullRequest.comments) { + if (comment.user == "BowserSlug") { + comment_id = comment.id + } + } + + def message = "${us_progress}\n${jp_progress}" + + if (message != "\n") { + if (comment_id == -1) { + pullRequest.comment(message) + } else { + pullRequest.editComment(comment_id, message) + } + } + } + } + } + } stage('Report Progress') { when { branch 'master' @@ -51,9 +83,9 @@ pipeline { } } } - post { - always { - cleanWs() - } - } + post { + always { + cleanWs() + } + } } diff --git a/progress.py b/progress.py index edc0893b2e..f0876e36aa 100755 --- a/progress.py +++ b/progress.py @@ -15,9 +15,24 @@ def set_version(version): build_dir = os.path.join(root_dir, "build") elf_path = os.path.join(build_dir, "papermario.elf") +def load_latest_progress(version): + from urllib.request import urlopen + + if version == "current": + from pathlib import Path + + version = Path("ver/current").resolve().parts[-1] + + csv = urlopen(f"https://papermar.io/reports/progress_{version}.csv").read().decode('utf-8') + latest = csv.split("\n")[-2] + + version, timestamp, git_hash, all_funcs, nonmatching_funcs, matching_funcs, total_size, nonmatching_size, matching_size = latest.split(",") + + return (int(all_funcs), int(nonmatching_funcs), int(matching_funcs), int(total_size), int(nonmatching_size), int(matching_size)) + def get_func_sizes(): try: - result = subprocess.run(['objdump', '-x', elf_path], stdout=subprocess.PIPE) + result = subprocess.run(['mips-linux-gnu-objdump', '-x', elf_path], stdout=subprocess.PIPE) nm_lines = result.stdout.decode().split("\n") except: print(f"Error: Could not run objdump on {elf_path} - make sure that the project is built") @@ -83,6 +98,12 @@ def main(args): funcs_matching_ratio = (len(matching_funcs) / len(all_funcs)) * 100 matching_ratio = (matching_size / total_size) * 100 + old_all_funcs, old_nonmatching_funcs, old_matching_funcs, old_total_size, old_nonmatching_size, old_matching_size = load_latest_progress(args.version) + old_matching_ratio = (old_matching_size / old_total_size) * 100 + + ratio_delta = matching_ratio - old_matching_ratio + funcs_delta = len(matching_funcs) - old_matching_funcs + if args.csv: version = 1 git_object = git.Repo().head.object @@ -102,18 +123,35 @@ def main(args): "message": f"{matching_ratio:.2f}%", "color": color.hex, })) + elif args.pr_comment: + if funcs_delta > 0: + if funcs_delta == 1: + s = "" + else: + s = "s" + + print(f"{'🚀' * funcs_delta} This PR matches {funcs_delta} function{s} (+{ ratio_delta:.2f}%) on `{args.version}`.") else: if matching_size + nonmatching_size != total_size: print("Warning: category/total size mismatch!\n") print(f"{len(matching_funcs)} matched functions / {len(all_funcs)} total ({funcs_matching_ratio:.2f}%)") print(f"{matching_size} matching bytes / {total_size} total ({matching_ratio:.2f}%)") + if funcs_delta > 0: + if funcs_delta == 1: + s = "" + else: + s = "s" + + print(f"This local build matches {funcs_delta} function{s} (+{ ratio_delta:.2f}%) over latest `{args.version}`.") + if __name__ == "__main__": parser = argparse.ArgumentParser(description="Reports progress for the project") parser.add_argument("version", default="current", nargs="?") parser.add_argument("--csv", action="store_true") parser.add_argument("--shield-json", action="store_true") + parser.add_argument("--pr-comment", action="store_true") args = parser.parse_args() main(args) diff --git a/src/jp/os/nusys/3B150.c b/src/jp/os/nusys/3B150.c index 3bfe4f81e6..9b1819cd3e 100644 --- a/src/jp/os/nusys/3B150.c +++ b/src/jp/os/nusys/3B150.c @@ -1,6 +1,12 @@ #include "common.h" +#include "nu/nusys.h" -INCLUDE_ASM(s32, "os/nusys/3B150", nuContRmbForceStop); +// TODO +#define nuSiSendMesg func_800602C8 + +void nuContRmbForceStop(void) { + nuSiSendMesg(NU_CONT_RMB_FORCESTOP_MSG, NULL); +} INCLUDE_ASM(s32, "os/nusys/3B150", func_8005FD70); diff --git a/ver/jp/asm/nonmatchings/os/nusys/3B150/nuContRmbForceStop.s b/ver/jp/asm/nonmatchings/os/nusys/3B150/nuContRmbForceStop.s deleted file mode 100644 index 3cbaf58243..0000000000 --- a/ver/jp/asm/nonmatchings/os/nusys/3B150/nuContRmbForceStop.s +++ /dev/null @@ -1,12 +0,0 @@ -.set noat # allow manual use of $at -.set noreorder # don't insert nops after branches - -glabel nuContRmbForceStop -/* 3B150 8005FD50 27BDFFE8 */ addiu $sp, $sp, -0x18 -/* 3B154 8005FD54 24040304 */ addiu $a0, $zero, 0x304 -/* 3B158 8005FD58 AFBF0010 */ sw $ra, 0x10($sp) -/* 3B15C 8005FD5C 0C0180B2 */ jal func_800602C8 -/* 3B160 8005FD60 0000282D */ daddu $a1, $zero, $zero -/* 3B164 8005FD64 8FBF0010 */ lw $ra, 0x10($sp) -/* 3B168 8005FD68 03E00008 */ jr $ra -/* 3B16C 8005FD6C 27BD0018 */ addiu $sp, $sp, 0x18