From a49ebef59dbf0e22045aaee72bfdff590ee898c3 Mon Sep 17 00:00:00 2001 From: Jonas Qvigstad Date: Sun, 26 Mar 2023 23:30:26 +0200 Subject: [PATCH 01/10] Comments are now adjusted from cfg file --- eessi_bot_job_manager.py | 63 ++++++++++++++-------------------------- pr_comments.cfg | 25 ++++++++++++++++ tasks/build.py | 10 +++---- 3 files changed, 52 insertions(+), 46 deletions(-) create mode 100644 pr_comments.cfg diff --git a/eessi_bot_job_manager.py b/eessi_bot_job_manager.py index 3415ca19..0516f4cf 100644 --- a/eessi_bot_job_manager.py +++ b/eessi_bot_job_manager.py @@ -291,9 +291,10 @@ def process_new_job(self, new_job): # (c) add a row to the table # add row to status table if we found a comment if "comment_id" in new_job: + comments = config.read_config("pr_comments.cfg")["new_job"] dt = datetime.now(timezone.utc) update = "\n|%s|" % dt.strftime("%b %d %X %Z %Y") - update += "released|job awaits launch by Slurm scheduler|" + update += f"{comments['job_status']}|{comments['comment']}|" update_comment(new_job["comment_id"], pr, update) else: log( @@ -363,12 +364,13 @@ def process_running_jobs(self, running_job): if "comment_id" in running_job: dt = datetime.now(timezone.utc) - running_msg = "job %s is running" % running_job['jobid'] + comments = config.read_config("pr_comments.cfg")["running_job"] + running_msg = comments['comment'].format(job_id=running_job['jobid']) if "comment_body" in running_job and running_msg in running_job["comment_body"]: log("Not updating comment, '%s' already found" % running_msg) else: - update = "\n|%s|" % dt.strftime("%b %d %X %Z %Y") - update += "running|" + running_msg + update = f"\n|{dt.strftime('%b %d %X %Z %Y')}|" + update += f"{comments['job_status']}|{running_msg}|" update_comment(running_job["comment_id"], pullrequest, update) else: log( @@ -463,20 +465,18 @@ def process_finished_job(self, finished_job): dt = datetime.now(timezone.utc) + comments = config.read_config("pr_comments.cfg")["finished_job"] + comment_update = f"\n|{dt.strftime('%b %d %X %Z %Y')}|" + comment_update += f"{comments['job_status']}|" if (no_missing_modules and targz_created and len(eessi_tarballs) == 1): # We've got one tarball and slurm out messages are ok # Prepare a message with information such as # (installation status, tarball name, tarball size) - comment_update = "\n|%s|finished|:grin: SUCCESS " % dt.strftime( - "%b %d %X %Z %Y") - + tarball_name = os.path.basename(eessi_tarballs[0]) tarball_size = os.path.getsize(eessi_tarballs[0]) / 2**30 - comment_update += "tarball %s (%.3f GiB) " % ( - os.path.basename(eessi_tarballs[0]), - tarball_size, - ) - comment_update += "in job dir|" + success_comment = comments["success"].format(tarball_name=tarball_name, tarball_size=tarball_size) + comment_update += f"{success_comment}|" # NOTE explicitly name repo in build job comment? # comment_update += '\nAwaiting approval to # comment_update += ingest tarball into the repository.' @@ -489,52 +489,33 @@ def process_finished_job(self, finished_job): # prepare a message with details about the above conditions and # update PR with a comment - comment_update = "\n|%s|finished|:cry: FAILURE