Comment progress change on pull requests (#382)

also:
* match jp nuContRmbForceStop
* progress.py: emit progress delta by default
This commit is contained in:
alex 2021-08-24 11:22:24 +01:00 committed by GitHub
parent 29ea27859d
commit 023a516a7c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 83 additions and 19 deletions

42
Jenkinsfile vendored
View File

@ -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()
}
}
}

View File

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

View File

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

View File

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