Rules reflection in summaries
In gitlab-org/quality/triage-ops!483 (merged) I was attempting to write a summarize rule with labels brace expansion, in hoping that we don't have to copy and paste to generate multiple summaries, but then I realized that there's no way for now to access the conditions in the summaries, therefore we cannot make different contents based on the conditions.
Ideally, this should give us the first label in the conditions:
rules.dig('Rule name here', 'conditions', 'labels', 0)
So we can write something like this:
.common_mrs_conditions: &common_mrs_conditions
state: opened
labels:
- group::{ access, manage }
.common_summary_rule_actions: &common_summary_rule_actions
item: |
- [ ] #{full_resource_reference} {{title}}
resource_rules:
merge_requests:
summaries:
- name: Collate merge requests requiring attention for <%= group_label_name %>
destination: gitlab-org/quality/triage-reports
actions:
summarize:
title: |
Stale merge requests report for `{{ LABEL }}` - #{Date.today.iso8601}
summary: |
#{ stale_merge_request_report(rules.dig('Updated more than 4 weeks ago', 'conditions', 'labels', 0)) }
rules:
- name: Updated more than 4 weeks ago
conditions:
<<: *common_mrs_conditions
actions:
summarize:
<<: *common_summary_rule_actions
summary: |
{{items}}
This isn't supported, and it shouldn't be too difficult to implement, as we just need to pass the data along.
I ended up with writing generators with ERB, but an actual feature here is more desirable.