plan_my_stuff 0.29.0 → 0.30.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: 98cbaeb499aa1b3b22018b7145d2d8e0bd86051a237230d1b5cac3e884109e10
4
- data.tar.gz: a66aa1aec786adca0853eed340e1f35e2639c7aca6aafae88a421b4cc2136b5d
3
+ metadata.gz: bf390e409623eaacc5e3dcd727984ed93212cdc23847fc9a848de150d1c025af
4
+ data.tar.gz: 70eeabeadf4d593c5a97806ad013e24da2175123e4f6e5bf071b3beee9da2937
5
5
  SHA512:
6
- metadata.gz: 8f4e1995d828ae83edfc94a9d2d0805b5787165e28f062bd0100f586de2c19e49fb6f9167ac0ee0ea88be5001012ffab5371315d2dcaee4b081a13e6be53a993
7
- data.tar.gz: 95474b37f6f2bbd4c6074f3049086b1d643617c7c0a6dbf8562e9e0c29f9ad7bcbcabcedfda29f8e55cfcf12d5f0024a41cd69d0c9527dff91948a83e8dcde46
6
+ metadata.gz: 928aa5abb220e785a6bb04586645af1a5bdc0c3a889f49d08ddc4882ecb0b21f5aa0bf53a724749d2458905ad58da4a116e09e31aeb59686ddeda1b16f53b9e1
7
+ data.tar.gz: 66d5e0ec45da7e3b5ed2e9d2a0e1a088012008a5bca1ff5dd4773d66fd3d84ad08ffb977c29ff9276611d011b25a543464d00c0063fda29786a6610d27c6166f
data/CHANGELOG.md CHANGED
@@ -1,5 +1,23 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.30.0
4
+
5
+ ### Added
6
+
7
+ - The AWS deployment-completed webhook now fires a single `pipeline_deployment_completed.plan_my_stuff` batch event
8
+ after the per-item sweep, carrying every item that actually transitioned (payload: `:project_items`, `:issue_numbers`,
9
+ `:commit_sha`). Per-item `pipeline_completed.plan_my_stuff` events still fire. The batch event is skipped when nothing
10
+ transitioned, giving subscribers (release-notes mailer, Slack summary, changelog generator) one clean
11
+ "deployment finished" signal without debouncing N per-item events (closes #97).
12
+
13
+ ### Changed
14
+
15
+ - `PlanMyStuff::Notifications.instrument` now accepts an `Array` resource. The payload key is the pluralized element
16
+ key (a batch of project items keys as `:project_items`, a batch of issues as `:issues`), so batch events carry a full
17
+ set under one key.
18
+ - `PlanMyStuff::Pipeline.instrument` now accepts an `Array` of items for a batch event; the payload carries
19
+ `:issue_numbers` (the linked number of every item) in place of the single-item `:issue_number`.
20
+
3
21
  ## 0.29.0
4
22
 
5
23
  ### Changed
data/README.md CHANGED
@@ -698,7 +698,15 @@ The engine mounts two webhook endpoints when the pipeline is enabled:
698
698
  - `POST /webhooks/github` — takes GitHub `pull_request` events. On `closed` against a tracked branch, the gem calls `IssueLinker` to extract `#123` references from the PR body and commit messages, then transitions each linked issue (e.g. merged to main -> `start_deployment!`).
699
699
  - `POST /webhooks/aws` — takes CodeDeploy/SNS lifecycle events. On a successful deployment, the gem flips matching items to `Completed`.
700
700
 
701
- See `designs/release_cycle/plan.md` for the full design, including the `projects_v2_item` path that fires `Pipeline.take!` when a human drags an item to Started on github.com.
701
+ On a successful AWS deployment the gem completes each matching item individually (one
702
+ `pipeline_completed.plan_my_stuff` event apiece), then fires a single
703
+ `pipeline_deployment_completed.plan_my_stuff` batch event carrying every item that actually transitioned
704
+ (payload: `:project_items`, `:issue_numbers`, `:commit_sha`). It is skipped when nothing transitioned, so subscribers
705
+ (release-notes mailer, Slack summary, changelog generator) get one clean "deployment finished" signal
706
+ without debouncing the per-item events.
707
+
708
+ See `designs/release_cycle/plan.md` for the full design, including the `projects_v2_item` path that fires
709
+ `Pipeline.take!` when a human drags an item to Started on github.com.
702
710
 
703
711
  ### "Take" button
704
712
 
@@ -147,7 +147,10 @@ module PlanMyStuff
147
147
  end
148
148
 
149
149
  # Finds "Release in Progress" items whose linked issue commit SHA matches the configured production
150
- # commit SHA (prefix match), then completes deployment for each.
150
+ # commit SHA (prefix match), then completes deployment for each. After the per-item sweep, fires one batch
151
+ # +pipeline_deployment_completed.plan_my_stuff+ event carrying every item that actually transitioned
152
+ # (+complete_deployment!+ returns +nil+ when auto-complete is off, so those are excluded). The batch event is
153
+ # skipped when nothing transitioned so subscribers only see real deployments.
151
154
  #
152
155
  # @return [void]
153
156
  #
@@ -162,13 +165,22 @@ module PlanMyStuff
162
165
  return
163
166
  end
164
167
 
165
- release_in_progress_items.each do |item|
168
+ completed_items = release_in_progress_items.filter_map do |item|
166
169
  next if item.draft?
167
170
 
168
171
  next unless item.issue.metadata.commit_sha&.start_with?(sha)
169
172
 
170
- PlanMyStuff::Pipeline.complete_deployment!(item)
173
+ result = PlanMyStuff::Pipeline.complete_deployment!(item)
174
+ item if result.present?
171
175
  end
176
+
177
+ return if completed_items.empty?
178
+
179
+ PlanMyStuff::Pipeline.instrument(
180
+ 'deployment_completed',
181
+ completed_items,
182
+ commit_sha: sha,
183
+ )
172
184
  end
173
185
 
174
186
  # Finds all pipeline project items at "Release in Progress" status.
@@ -21,7 +21,8 @@ module PlanMyStuff
21
21
  # Fires +<event>.plan_my_stuff+ with a normalized payload.
22
22
  #
23
23
  # @param event [String] e.g. +'issue_created'+
24
- # @param resource [Object] domain object (+Issue+, +Comment+, +ProjectItem+, ...)
24
+ # @param resource [Object] domain object (+Issue+, +Comment+, +ProjectItem+, ...), or an +Array+ of resources for a
25
+ # batch event (keyed by the pluralized element key, e.g. +:project_items+)
25
26
  # @param user [Object, nil] explicit actor; falls back to +config.current_user+
26
27
  # @param extra [Hash] additional payload entries (+changes:+, +labels:+, +user_ids:+, ...)
27
28
  #
@@ -63,7 +64,9 @@ module PlanMyStuff
63
64
  payload.merge(extra)
64
65
  end
65
66
 
66
- # Maps a resource object to its payload key.
67
+ # Maps a resource object to its payload key. An +Array+ recurses on its first element and pluralizes that key, so
68
+ # batch events carry the full set under one key (a batch of project items keys as +:project_items+, a batch of
69
+ # issues as +:issues+, an empty/unknown batch as +:resources+).
67
70
  #
68
71
  # @param resource [Object]
69
72
  #
@@ -74,6 +77,7 @@ module PlanMyStuff
74
77
  when PlanMyStuff::Issue then :issue
75
78
  when PlanMyStuff::Comment then :comment
76
79
  when PlanMyStuff::BaseProjectItem then :project_item
80
+ when Array then :"#{infer_resource_key(resource.first)}s"
77
81
  else :resource
78
82
  end
79
83
  end
@@ -55,13 +55,17 @@ module PlanMyStuff
55
55
  # canonical status is added to the payload as +:status+. Otherwise +event+ is used verbatim as the suffix (e.g.
56
56
  # +"removed"+, +"removed_late"+, +"testing"+).
57
57
  #
58
+ # +resource+ is normally a single project item (payload carries +:issue_number+). Pass an +Array+ for a batch
59
+ # event (e.g. the deployment-completed sweep) and the payload instead carries +:issue_numbers+ -- the linked
60
+ # number of every item.
61
+ #
58
62
  # @param event [String] status name or literal event suffix
59
- # @param project_item [PlanMyStuff::BaseProjectItem]
63
+ # @param resource [PlanMyStuff::BaseProjectItem, Array<PlanMyStuff::BaseProjectItem>] item or batch of items
60
64
  # @param extra [Hash] additional payload entries
61
65
  #
62
66
  # @return [void]
63
67
  #
64
- def instrument(event, project_item, **extra)
68
+ def instrument(event, resource, **extra)
65
69
  extra_to_use = { **extra }
66
70
  event_to_use = event
67
71
  if PlanMyStuff::Pipeline::Status::ALL.include?(event_to_use)
@@ -69,10 +73,17 @@ module PlanMyStuff
69
73
  event_to_use = PlanMyStuff::Pipeline::Status.key_for(event_to_use)
70
74
  end
71
75
 
76
+ number_fields =
77
+ if resource.is_a?(Array)
78
+ { issue_numbers: resource.map(&:number) }
79
+ else
80
+ { issue_number: resource.number }
81
+ end
82
+
72
83
  PlanMyStuff::Notifications.instrument(
73
84
  "pipeline_#{event_to_use}",
74
- project_item,
75
- issue_number: project_item.number,
85
+ resource,
86
+ **number_fields,
76
87
  **extra_to_use,
77
88
  )
78
89
  end
@@ -3,7 +3,7 @@
3
3
  module PlanMyStuff
4
4
  module VERSION
5
5
  MAJOR = 0
6
- MINOR = 29
6
+ MINOR = 30
7
7
  TINY = 0
8
8
 
9
9
  # Set PRE to nil unless it's a pre-release (beta, rc, etc.)
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: plan_my_stuff
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.29.0
4
+ version: 0.30.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Brands Insurance