diff --git a/eessi_bot_event_handler.py b/eessi_bot_event_handler.py index 1acf7408..631494b0 100644 --- a/eessi_bot_event_handler.py +++ b/eessi_bot_event_handler.py @@ -25,7 +25,7 @@ # Local application imports (anything from EESSI/eessi-bot-software-layer) from connections import github import tasks.build as build -from tasks.build import check_build_permission, get_architecture_targets, get_repo_cfg, submit_build_jobs, request_bot_build_issue_comments +from tasks.build import check_build_permission, get_architecture_targets, get_repo_cfg, \ submit_build_jobs, request_bot_build_issue_comments import tasks.deploy as deploy from tasks.deploy import deploy_built_artefacts from tools import config @@ -493,12 +493,16 @@ def handle_bot_command_status(self, event_info, bot_command): repo_name = event_info['raw_request_body']['repository']['full_name'] pr_number = event_info['raw_request_body']['issue']['number'] status_table = request_bot_build_issue_comments(repo_name, pr_number) - + comment = f"This is the status of all the `bot: build` commands:" comment += f"\n|arch|result|date|status|url|" comment += f"\n|----|------|----|------|---|" - for x in range(0,len(status_table['date'])): - comment += f"\n|{status_table['arch'][x]}|{status_table['result'][x]}|{status_table['date'][x]}|{status_table['status'][x]}|{status_table['url'][x]}|" + for x in range(0, len(status_table['date'])): + comment += f"\n|{status_table['arch'][x]}|" + comment += f"{status_table['result'][x]}|" + comment += f"{status_table['date'][x]}|" + comment += f"{status_table['status'][x]}|" + comment += f"{status_table['url'][x]}|" self.log(f"PR opened: comment '{comment}'") repo = gh.get_repo(repo_name) diff --git a/tasks/build.py b/tasks/build.py index 3a1374dd..1f6ba1f5 100644 --- a/tasks/build.py +++ b/tasks/build.py @@ -771,13 +771,13 @@ def request_bot_build_issue_comments(repo_name, pr_number): for x in range(1,5): curl_cmd = f'curl -L https://api.github.com/repos/{repo_name}/issues/{pr_number}/comments?per_page=100&page={x}' curl_output, curl_error, curl_exit_code = run_cmd(curl_cmd, "fetch all comments") - + comments = json.loads(curl_output) - - for comment in comments: #iterate through the comments to find the one where the status of the build was in + + for comment in comments: # iterate through the comments to find the one where the status of the build was in if config.read_config()["submitted_job_comments"]['initial_comment'][:20] in comment['body']: - #get archictecture from comment['body'] + # get archictecture from comment['body'] first_line = comment['body'][:comment['body'].find('/n')] arch_map = get_architecture_targets(cfg) for arch in arch_map.keys(): @@ -785,21 +785,22 @@ def request_bot_build_issue_comments(repo_name, pr_number): if target_arch in first_line: status_table['arch'].append(target_arch) - #get date, status, url and result from the markdown table + # get date, status, url and result from the markdown table comment_table = comment['body'][comment['body'].find('|'):comment['body'].rfind('|')+1] # Convert markdown table to a dictionary lines = comment_table.split('\n') ret = [] keys = [] - for i,l in enumerate(lines): - if i==0: - keys=[_i.strip() for _i in l.split('|')] - elif i==1: continue + for i, l in enumerate(lines): + if i == 0: + keys = [_i.strip() for _i in l.split('|')] + elif i == 1: + continue else: - ret.append({keys[_i]:v.strip() for _i,v in enumerate(l.split('|')) if _i>0 and _i 0 and _i