Fix empty triage reports for projects with no quarantined tests

Context

After !3804 (merged) was merged, we noticed that empty triage reports were created for 75+ teams when running team summaries against projects like gitlab-org/gitlab-shell and gitlab-org/gitaly. See #1720 (closed) for details.

The root cause is two-fold:

  1. Quarantine data from ClickHouse is filtered by group label, not by project - so gitlab-shell and gitaly reports show the same quarantine data as gitlab-org/gitlab (duplicate/irrelevant data)
  2. The gitlab-triage gem's content_available? always returns true for custom rules, even when they return nil

What's in this MR?

  1. Returns nil from quarantined_tests when there are no quarantined tests - prevents empty quarantine sections
  2. Limits quarantine reporting to gitlab-org/gitlab only - other projects (gitlab-shell, gitaly) would show duplicate data from the main gitlab project, so we skip them entirely
  3. Extracts source_project_path helper - cleaner code for getting the project path from triage context

Combined with gitlab-org/ruby/gems/gitlab-triage!368 (merged) (which fixes content_available? for custom rules), this ensures reports are only created when there is actual actionable content.

Proof of Work

1. Happy path: Team with quarantined tests on gitlab-org/gitlab

Variable Value
TRIAGE_SOURCE_TYPE projects
TRIAGE_SOURCE_PATH 278964
TRIAGE_POLICY_FILE policies/generated/team-summary.yml.erb/tenant_services.yml

Job: https://gitlab.com/gitlab-org/quality/triage-ops/-/jobs/13094889544

Result: Report is created with quarantine section showing "9 quarantined tests" for the tenant_services group.

2. Unsupported project: gitlab-org/gitlab-shell

Variable Value
TRIAGE_SOURCE_TYPE projects
TRIAGE_SOURCE_PATH 14022
TRIAGE_POLICY_FILE policies/generated/team-summary.yml.erb/tenant_services.yml

Job: https://gitlab.com/gitlab-org/quality/triage-ops/-/jobs/13094742947

Result: No report created - quarantine_reporting_supported? returns false for gitlab-shell, so quarantine section is skipped.

3. Team with zero quarantined tests on gitlab-org/gitlab

Variable Value
TRIAGE_SOURCE_TYPE projects
TRIAGE_SOURCE_PATH 278964
TRIAGE_POLICY_FILE policies/generated/team-summary.yml.erb/accessibility.yml

Job: https://gitlab.com/gitlab-org/quality/triage-ops/-/jobs/13094998110

Result: Report is created (because other sections have content), but quarantine section is omitted. The accessibility group has no quarantined tests in ClickHouse (last 30 days), so quarantined_tests returns nil and the section is skipped. Search the job log for "Quarantined Tests" - only the rule header appears, no content is generated.

Edited by David Dieulivol

Merge request reports

Loading