Skip to content

Commit

Permalink
resolve requested changes from #237 (review)
Browse files Browse the repository at this point in the history
  • Loading branch information
vsc46128 vscuser committed Jan 25, 2024
1 parent 85fc161 commit 6fda60a
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 7 deletions.
11 changes: 6 additions & 5 deletions eessi_bot_event_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
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
srequest_bot_build_issue_comment, submit_build_jobs
import tasks.deploy as deploy
from tasks.deploy import deploy_built_artefacts
from tools import config
Expand Down Expand Up @@ -479,15 +479,16 @@ def handle_bot_command_show_config(self, event_info, bot_command):

def handle_bot_command_status(self, event_info, bot_command):
"""
Handles bot command 'status' by running the handler for events of
type pull_request with the action opened.
Handles bot command 'status' by querying the github API
for the comments in a pr.
Args:
event_info (dict): event received by event_handler
bot_command (EESSIBotCommand): command to be handled
Returns:
(string): table which collects the status of each target
github.IssueComment.IssueComment (note, github refers to
PyGithub, not the github from the internal connections module)
"""
self.log("processing bot command 'status'")
gh = github.get_instance()
Expand All @@ -506,7 +507,7 @@ def handle_bot_command_status(self, event_info, bot_command):
comment_status += f"{status_table['status'][x]}|"
comment_status += f"{status_table['url'][x]}|"

self.log(f"PR opened: comment '{comment_status}'")
self.log(f"Overview of finished builds: comment '{comment_status}'")
repo = gh.get_repo(repo_name)
pull_request = repo.get_pull(pr_number)
issue_comment = pull_request.create_issue_comment(comment_status)
Expand Down
15 changes: 13 additions & 2 deletions tasks/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -763,6 +763,17 @@ def check_build_permission(pr, event_info):


def request_bot_build_issue_comments(repo_name, pr_number):
"""
Query the github API for the issue_comments in a pr.
Archs:
repo_name (string): name of the repository (format USER_OR_ORGANISATION/REPOSITORY)
pr_number (int): number og the pr
Returns:
status_table (dict): dictionary with 'arch', 'date', 'status', 'url' and 'result'
for all the finished builds;
"""
status_table = {'arch': [], 'date': [], 'status': [], 'url': [], 'result': []}
cfg = config.read_config()

Expand All @@ -780,7 +791,7 @@ def request_bot_build_issue_comments(repo_name, pr_number):
if config.read_config()["submitted_job_comments"]['initial_comment'][:20] in comment['body']:

# get archictecture from comment['body']
first_line = comment['body'][:comment['body'].find('/n')]
first_line = comment['body'].split('\n')[0]
arch_map = get_architecture_targets(cfg)
for arch in arch_map.keys():
target_arch = '/'.join(arch.split('/')[1:])
Expand Down Expand Up @@ -815,7 +826,7 @@ def request_bot_build_issue_comments(repo_name, pr_number):
status_table['url'].append(comment['html_url'])
if 'FAILURE' in row['comment']:
status_table['result'].append(':cry: FAILURE')
elif 'SUCCES' in row['comment']:
elif 'SUCCESS' in value['comment']:
status_table['result'].append(':grin: SUCCESS')
elif 'UNKNOWN' in row['comment']:
status_table['result'].append(':shrug: UNKNOWN')
Expand Down

0 comments on commit 6fda60a

Please sign in to comment.