Skip to content

Commit 9ef48b1

Browse files
authored
Bot improvements (pyccel#1949)
Change the key for the `check_runs` dict so that information about the Python version is not lost. This allows results from multiple Python versions to be considered together. This should let the coverage test use results from multiple Python versions. It is extremely difficult to test this kind of PR. Please review as well as you, it will then have to be tested in the devel branch on pyccel#1906 and minor fixes may need to be done quickly after the merge
1 parent 68532aa commit 9ef48b1

File tree

2 files changed

+18
-9
lines changed

2 files changed

+18
-9
lines changed

ci_tools/bot_tools/bot_funcs.py

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -291,10 +291,11 @@ def run_tests(self, tests, python_version = None, force_run = False):
291291
check_runs = {self.get_name_key(c["name"]): c for c in self._GAI.get_check_runs(self._ref)['check_runs']}
292292
already_triggered = [c["name"] for n,c in check_runs.items() if c['status'] in ('completed', 'in_progress') and \
293293
c['conclusion'] != 'cancelled' and \
294-
n != 'coverage']
294+
n != ('coverage', default_python_versions['coverage'])]
295295
already_triggered_names = [self.get_name_key(t) for t in already_triggered]
296-
already_programmed = {c["name"]:c for c in check_runs.values() if c['status'] == 'queued'}
297-
success_names = [n for n,c in check_runs.items() if c['status'] == 'completed' and c['conclusion'] == 'success']
296+
already_programmed = {n:c for n,c in check_runs.items() if c['status'] == 'queued'}
297+
success_names = [n if not isinstance(n, tuple) else n[0] for n,c in check_runs.items()
298+
if c['status'] == 'completed' and c['conclusion'] == 'success']
298299
print(already_triggered)
299300
states = []
300301

@@ -313,11 +314,11 @@ def run_tests(self, tests, python_version = None, force_run = False):
313314

314315
for t in tests:
315316
pv = python_version or default_python_versions[t]
316-
key = f"({t}, {pv})"
317-
if any(key in a for a in already_triggered):
318-
states.append(check_runs[t]['conclusion'])
317+
key = (t, pv)
318+
if key in already_triggered_names:
319+
states.append(check_runs[key]['conclusion'])
319320
continue
320-
name = f"{test_names[t]} {key}"
321+
name = f"{test_names[t]} ({t}, {pv})"
321322
if not force_run and not self.is_test_required(commit_log, name, t, states):
322323
continue
323324
states.append('queued')
@@ -994,7 +995,7 @@ def get_name_key(self, name):
994995
The name which can be used as a key.
995996
"""
996997
if '(' in name:
997-
return name.split('(')[1].split(',')[0]
998+
return name.split('(')[1].split(')')[0].split(', ')
998999
elif 'Codacy' in name:
9991000
return 'Codacy'
10001001
else:

ci_tools/bot_tools/github_api_interactions.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -394,7 +394,15 @@ def get_comments(self, pr_id):
394394
A dictionary containing the comments.
395395
"""
396396
url = f"https://api.github.com/repos/{self._org}/{self._repo}/issues/{pr_id}/comments"
397-
return self._post_request("GET", url).json()
397+
results = []
398+
page = 1
399+
new_results = [None]
400+
while len(new_results) != 0:
401+
request = self._post_request("GET", url, params={'per_page': '100', 'page': str(page)})
402+
new_results = request.json()
403+
results.extend(new_results)
404+
page += 1
405+
return results
398406

399407
def get_review_comments(self, pr_id):
400408
"""

0 commit comments

Comments
 (0)