Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 23 additions & 7 deletions mod_ci/controllers.py
Original file line number Diff line number Diff line change
Expand Up @@ -2170,23 +2170,37 @@ def get_info_for_pr_comment(test: Test) -> PrCommentInfo:
common_failed_tests = []
fixed_tests = []
category_stats = []

# Track processed RegressionTest IDs to ensure uniqueness
extra_failed_ids = set()
common_failed_ids = set()
fixed_test_ids = set()

test_results = get_test_results(test)
platform_column = f"last_passed_on_{test.platform.value}"
for category_results in test_results:
category_name = category_results['category'].name

category_test_pass_count = 0
for test in category_results['tests']:
if not test['error']:
for test_item in category_results['tests']:
if not test_item['error']:
category_test_pass_count += 1
if last_test_master and getattr(test['test'], platform_column) != last_test_master.id:
fixed_tests.append(test['test'])
if last_test_master and getattr(test_item['test'], platform_column) != last_test_master.id:
# Only add if not already processed
if test_item['test'].id not in fixed_test_ids:
fixed_tests.append(test_item['test'])
fixed_test_ids.add(test_item['test'].id)
else:
if last_test_master and getattr(test['test'], platform_column) != last_test_master.id:
common_failed_tests.append(test['test'])
if last_test_master and getattr(test_item['test'], platform_column) != last_test_master.id:
# Only add if not already processed
if test_item['test'].id not in common_failed_ids:
common_failed_tests.append(test_item['test'])
common_failed_ids.add(test_item['test'].id)
else:
extra_failed_tests.append(test['test'])
# Only add if not already processed
if test_item['test'].id not in extra_failed_ids:
extra_failed_tests.append(test_item['test'])
extra_failed_ids.add(test_item['test'].id)

category_stats.append(CategoryTestInfo(category_name, len(category_results['tests']), category_test_pass_count))

Expand All @@ -2204,6 +2218,8 @@ def comment_pr(test: Test) -> str:

test_id = test.id
platform = test.platform.name
# Refresh the test object to ensure all relationships are up-to-date
g.db.refresh(test)
comment_info = get_info_for_pr_comment(test)
template = app.jinja_env.get_or_select_template('ci/pr_comment.txt')
message = template.render(comment_info=comment_info, test_id=test_id, platform=platform)
Expand Down