gitlab-triage 1.46.0 → 1.47.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 82a56fd407f0bb5dd6be0155a71267d214702b0c811a35b8d559d2fda1ae1b58
4
- data.tar.gz: 8efe032a3e69a3ea5537798d0be00f96a976e10dd2d4fbd4c042d8c46fb8637f
3
+ metadata.gz: c3318627182a7f105d948f9c81f43db29dd3f271db82968a0d80623d42a4c6d8
4
+ data.tar.gz: c2c4a9208acef6b922382b8ac5e38a9d398fc55ea6d1fcac6d07bb45b7544712
5
5
  SHA512:
6
- metadata.gz: e3be78f754d51d09ca12902d9414b34d7e342f9aca7a3eb48711a56f25c7669c87e879e52684b1d4bf094eae1e54717258340840f39bafab737f21e4e220ea5e
7
- data.tar.gz: e95dcfc0963e88093fecffab883b34b5ceadf065cc73530bcde23ee74b87199e5cb79c0f8a040f866dc4da50c703ec11fb2ab9209b7d4c9283e8395b73be492c
6
+ metadata.gz: 07c2506ececee5455224d17d52c3fed0ec4be1b1f575bc0edec27dddd8093b824d794cbdc2d084179a881db8eb94e50506a75cebbee558cd66282a25c3a89776
7
+ data.tar.gz: d4f60985c3e2bb01c952fcadb1ac4669e9c792e5457d57f88f1684e87cafeaa0a6c38718a01e5d04e39a2acaed7da731dc2b59a9aa9d40a062c38fa3fb929ac5
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- gitlab-triage (1.46.0)
4
+ gitlab-triage (1.47.0)
5
5
  activesupport (>= 5.1)
6
6
  globalid (~> 1.0, >= 1.0.1)
7
7
  graphql (< 2.1.0)
data/README.md CHANGED
@@ -1186,7 +1186,7 @@ resource_rules:
1186
1186
 
1187
1187
  ##### Delete action
1188
1188
 
1189
- **This action is only applicable for branches.**
1189
+ **This action is only applicable for branches, issues and merge requests.**
1190
1190
 
1191
1191
  Delete the resource.
1192
1192
 
@@ -1220,6 +1220,55 @@ sub-policies' summary.
1220
1220
  Note that only the `summarize` keys in the sub-policies' `actions` is used. Any
1221
1221
  other keys (e.g. `mention`, `comment`, `labels` etc.) are ignored.
1222
1222
 
1223
+ #### Custom type summaries
1224
+
1225
+ By default, summary rules fetch GitLab resources (issues, merge requests, etc.) and use them to generate the summary content. However, you can create summaries that pull data from external sources (like ClickHouse, Prometheus, or custom APIs) without fetching any GitLab resources.
1226
+
1227
+ To create a custom summary, add `type: custom` to your rule definition:
1228
+
1229
+ ```yml
1230
+ resource_rules:
1231
+ issues:
1232
+ summaries:
1233
+ - name: Weekly Report
1234
+ rules:
1235
+ - name: Bug Heatmap
1236
+ conditions:
1237
+ labels:
1238
+ - bug
1239
+ actions:
1240
+ summarize:
1241
+ title: "Bugs"
1242
+ item: "- {{title}}"
1243
+ summary: "{{items}}"
1244
+
1245
+ - name: Quarantined Tests
1246
+ type: custom # Skip resource fetching
1247
+ actions:
1248
+ summarize:
1249
+ title: "Quarantined Tests"
1250
+ summary: |
1251
+ #{ fetch_quarantined_tests_from_clickhouse() }
1252
+ actions:
1253
+ summarize:
1254
+ title: "Weekly Report"
1255
+ summary: |
1256
+ {{items}}
1257
+ ```
1258
+
1259
+ When `type: custom` is specified:
1260
+ - No GitLab resources are fetched
1261
+ - The `conditions` field is optional and ignored
1262
+ - The `item` field in `actions.summarize` is not needed
1263
+ - The summary is always included in the report (as long as it has a title)
1264
+ - You can use Ruby expressions in the `summary` field to fetch data from external sources
1265
+
1266
+ This is useful for:
1267
+ - Including metrics from external monitoring systems
1268
+ - Aggregating data from multiple sources
1269
+ - Generating reports from custom databases
1270
+ - Adding static sections to your triage reports
1271
+
1223
1272
  You can define such policy as follows:
1224
1273
 
1225
1274
  ```yml
@@ -268,7 +268,7 @@ module Gitlab
268
268
  return if rule_definitions.blank?
269
269
 
270
270
  rule_definitions.each do |rule_definition|
271
- resources_for_rule(resource_type, rule_definition) do |resources|
271
+ resources_for_rule(resource_type, rule_definition, in_summary: false) do |resources|
272
272
  policy = Policies::RulePolicy.new(
273
273
  resource_type, rule_definition, resources, network)
274
274
 
@@ -336,7 +336,7 @@ module Gitlab
336
336
  def summary_parts_for_rules(resource_type, rule_definitions)
337
337
  # { summary_rule => resources }
338
338
  parts = rule_definitions.each_with_object({}) do |rule_definition, result|
339
- to_enum(:resources_for_rule, resource_type, rule_definition).each do |rule_resources, expanded_conditions|
339
+ to_enum(:resources_for_rule, resource_type, rule_definition, in_summary: true).each do |rule_resources, expanded_conditions|
340
340
  # We replace the non-expanded rule conditions with the expanded ones
341
341
  result.merge!(rule_definition.merge(conditions: expanded_conditions) => rule_resources)
342
342
  end
@@ -355,15 +355,27 @@ module Gitlab
355
355
  #
356
356
  # @param resource_type [String] The resource type, e.g. +issues+ or +merge_requests+.
357
357
  # @param rule_definition [Hash] A rule definition, e.g. +{ name: 'Foo', conditions: { milestone: 'v1' } }+.
358
+ # @param in_summary [Boolean] Whether this rule is part of a summary definition.
358
359
  #
359
360
  # @yieldparam rule_resources [PoliciesResources::RuleResources] An object which contains an array of resources.
360
361
  # @yieldparam expanded_conditions [Hash] A hash of expanded conditions.
361
362
  # @yieldreturn [nil]
362
363
  #
363
364
  # @return [nil]
364
- def resources_for_rule(resource_type, rule_definition)
365
+ def resources_for_rule(resource_type, rule_definition, in_summary: false)
365
366
  puts Gitlab::Triage::UI.header("Gathering resources for rule: **#{rule_definition[:name]}**", char: '-')
366
367
 
368
+ # Skip resource fetching for custom type rules
369
+ if rule_definition[:type] == 'custom'
370
+ unless in_summary
371
+ raise ArgumentError, "type: custom can only be used in summary rules, not in top-level rules (rule: #{rule_definition[:name]})"
372
+ end
373
+
374
+ puts "\n* Skipping resource fetch for custom type rule"
375
+ yield(PoliciesResources::RuleResources.new([]), {})
376
+ return
377
+ end
378
+
367
379
  ExpandCondition.perform(rule_conditions(rule_definition)) do |expanded_conditions|
368
380
  # retrieving the resources for every rule is inefficient
369
381
  # however, previous rules may affect those upcoming
@@ -20,6 +20,7 @@ module Gitlab
20
20
  @resources = resources
21
21
  @network = network
22
22
  @separator = separator
23
+ @is_custom = policy_spec[:type] == 'custom'
23
24
  end
24
25
 
25
26
  def title
@@ -35,7 +36,7 @@ module Gitlab
35
36
  end
36
37
 
37
38
  def valid?
38
- title =~ /\S+/ && any_resources?
39
+ title =~ /\S+/ && (@is_custom || any_resources?)
39
40
  end
40
41
 
41
42
  def any_resources?
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Gitlab
4
4
  module Triage
5
- VERSION = '1.46.0'
5
+ VERSION = '1.47.0'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: gitlab-triage
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.46.0
4
+ version: 1.47.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - GitLab
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-12-16 00:00:00.000000000 Z
11
+ date: 2026-02-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport