Skip to content

Commit

Permalink
clean-upp style
Browse files Browse the repository at this point in the history
  • Loading branch information
vsc46128 vscuser committed Jan 25, 2024
1 parent d504f1c commit 87c8e99
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 10 deletions.
3 changes: 2 additions & 1 deletion eessi_bot_event_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,8 @@
# 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
Expand Down
22 changes: 13 additions & 9 deletions tasks/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -761,14 +761,15 @@ def check_build_permission(pr, event_info):
log(f"{fn}(): GH account '{build_labeler}' is authorized to build")
return True


def request_bot_build_issue_comments(repo_name, pr_number):
status_table = {'arch': [], 'date': [], 'status': [], 'url': [], 'result': []}
cfg = config.read_config()
# for loop because github has max 100 items per request.
# if the pr has more than 100 comments we need to use per_page

# for loop because github has max 100 items per request.
# if the pr has more than 100 comments we need to use per_page
# argument at the moment the for loop is for a max of 400 comments could bump this up
for x in range(1,5):
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")

Expand All @@ -790,15 +791,18 @@ def request_bot_build_issue_comments(repo_name, pr_number):

# Convert markdown table to a dictionary
lines = comment_table.split('\n')
ret = []
values = []
keys = []
for i, l in enumerate(lines):
for i, row in enumerate(lines):
if i == 0:
keys = [_i.strip() for _i in l.split('|')]
elif i == 1:
for key in row.split('|'):
keys.append(key.strip())
elif i == 1:
continue
else:
ret.append({keys[_i]: v.strip() for _i, v in enumerate(l.split('|')) if _i > 0 and _i<len(keys)-1})
for j, value in enumerate(l.split('|')):
if j > 0 and j < len(keys) - 1:
values.append({keys[j]: value.strip()})

# add date, status, url to status_table if
for row in ret:
Expand Down

0 comments on commit 87c8e99

Please sign in to comment.