kettle-family 1.3.44 → 1.3.46
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 +4 -4
- checksums.yaml.gz.sig +0 -0
- data/CHANGELOG.md +50 -1
- data/README.md +7 -1
- data/lib/kettle/family/branch_checkout_check.rb +263 -0
- data/lib/kettle/family/bundler_version_check.rb +201 -0
- data/lib/kettle/family/cli.rb +14 -2
- data/lib/kettle/family/rebase_check.rb +171 -0
- data/lib/kettle/family/report.rb +45 -2
- data/lib/kettle/family/version.rb +1 -1
- data/lib/kettle/family/workflow.rb +173 -15
- data/lib/kettle/family/workflow_progress.rb +2 -0
- data/lib/kettle/family.rb +2 -0
- data.tar.gz.sig +0 -0
- metadata +745 -645
- metadata.gz.sig +3 -4
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 422fba51f5f3bfb1295aea45a2b41fdd9602274145333e2cce230325479b5e9b
|
|
4
|
+
data.tar.gz: a42ddba776d64ac4c641a9139321dcc6b1ec0d3d613ac95527eef20b29e4fdb7
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 270849b3df73808ae5d9d7b058d7edddc55c82eaea4754da9c57fa75bb7aaa1c7a68e3e11ce00832d85591d8c57660db1c0c5a59685c405cdbbd4bea82010088
|
|
7
|
+
data.tar.gz: ad1287d9b0aed6f6d0b82815c162e425c1e9b897628069e1910f63b515849329d9e7309d3947e25a1a560609f0dbe6f40dd956538dd1b1c5f79798ccfbcbfc4f
|
checksums.yaml.gz.sig
CHANGED
|
Binary file
|
data/CHANGELOG.md
CHANGED
|
@@ -30,6 +30,51 @@ Please file a bug if you notice a violation of semantic versioning.
|
|
|
30
30
|
|
|
31
31
|
### Security
|
|
32
32
|
|
|
33
|
+
## [1.3.46] - 2026-11-20
|
|
34
|
+
|
|
35
|
+
- TAG: [v1.3.46][1.3.46t]
|
|
36
|
+
- COVERAGE: 94.09% -- 8653/9197 lines in 49 files
|
|
37
|
+
- BRANCH COVERAGE: 79.20% -- 3628/4581 branches in 49 files
|
|
38
|
+
- 41.57% documented
|
|
39
|
+
|
|
40
|
+
### Added
|
|
41
|
+
|
|
42
|
+
- BundlerVersionCheck preflight: executing template and bup runs now stop before touching any member unless the family runs the latest stable Bundler — the installed stable and every member lockfile BUNDLED WITH must match the registrys newest non-held stable — and the failure names kettle-family update-bundler --execute as the remedy. The read-only check command reports the same drift. Plan (non-execute) runs and the remedy commands (bupb, update-bundler) are exempt, and the check fails open when the registry cannot be consulted
|
|
43
|
+
|
|
44
|
+
- BranchCheckoutCheck preflight: executing template, bup, and bump runs now stop before touching any member whose checkout is on an unexpected branch — expected means the default branch, a configured release/stack lane (member_target_branches, member-local release.target_branches, branch_lanes), or a new repeatable --branch MEMBER:BRANCH override. Under local sibling wiring (family *_DEV toggle or K_JEM_TEMPLATING) the check also fails when a member gemspec requirement cannot be satisfied by the sibling checkout version on its current branch (e.g. a member requiring oauth2 ~> 2.0 while oauth2 sits on 1-4-stable at 1.4.12). The read-only check command reports the same drift. Plan (non-execute) runs and release (which checks out its own lanes) are exempt
|
|
45
|
+
|
|
46
|
+
- Add per-member rebase preflight (Kettle::Family::RebaseCheck) gating bump, bup, template, and gha-sha-pins: each member checkout is synced to its upstream before the command touches it; a member that fails to sync is excluded while the rest continue, and the check emits live member_start/command_step/member_complete events on the family event tape. Member commands are spawned with KETTLE_REBASE_NESTED so nested kettle tools skip re-syncing
|
|
47
|
+
|
|
48
|
+
- BundlerVersionCheck preflight now also gates on the installed RubyGems version: when gem -v lags the registry's latest stable rubygems-update, gated commands stop with a diagnostic naming the vendored-uri clash (Gem::URI double-initialization warnings from the mismatched Bundler/RubyGems pair) and the gem update --system remedy. Skipped when the bundled kettle-dev predates the pair lookups or the registry is unreachable
|
|
49
|
+
|
|
50
|
+
### Changed
|
|
51
|
+
|
|
52
|
+
- [kc] kettle-jem/prepare: updated 17 project files:
|
|
53
|
+
- dependencies (17)
|
|
54
|
+
- [kc] kettle-jem/template: updated 12 project files:
|
|
55
|
+
- code and tests (2)
|
|
56
|
+
- dependencies (6)
|
|
57
|
+
- other (2)
|
|
58
|
+
- workflows (2)
|
|
59
|
+
|
|
60
|
+
### Fixed
|
|
61
|
+
|
|
62
|
+
- Family templating seeds corporate sponsors into member kettle-jem configuration, so standalone README generation retains them while preserving member-specific sponsors. (#74)
|
|
63
|
+
- Cold-start templating of a freshly scaffolded member no longer fails with `cannot load such file -- parslet`; standalone `kettle-jem prepare` now uses the family-root bundle instead of the member's bare `Gemfile`.
|
|
64
|
+
|
|
65
|
+
- [kc] lazy-bundler-require: Stop requiring Bundler at load time (BundlerVersionCheck, workflow lockfile parsing): loading Bundler activates the machine's default Bundler, whose vendored uri clashes with RubyGems' own vendored copy when the pair is mismatched, flooding stderr with Gem::URI double-initialization warnings on every CLI invocation
|
|
66
|
+
|
|
67
|
+
## [1.3.45] - 2026-11-16
|
|
68
|
+
|
|
69
|
+
- TAG: [v1.3.45][1.3.45t]
|
|
70
|
+
- COVERAGE: 93.98% -- 8327/8860 lines in 46 files
|
|
71
|
+
- BRANCH COVERAGE: 78.61% -- 3461/4403 branches in 46 files
|
|
72
|
+
- 40.74% documented
|
|
73
|
+
|
|
74
|
+
### Fixed
|
|
75
|
+
|
|
76
|
+
- `mise run pins` now reports updated GitHub Actions and versions per family member without dumping discovery and review data.
|
|
77
|
+
|
|
33
78
|
## [1.3.44] - 2026-11-16
|
|
34
79
|
|
|
35
80
|
- TAG: [v1.3.44][1.3.44t]
|
|
@@ -3472,7 +3517,11 @@ Please file a bug if you notice a violation of semantic versioning.
|
|
|
3472
3517
|
- Fixed CI load failures on engines without compatible `pty` support by falling back to Open3 for interactive release commands.
|
|
3473
3518
|
- Fixed Ruby 3.2 version-bump support by loading Prism lazily and wiring the Prism gem only for MRI versions that need it.
|
|
3474
3519
|
|
|
3475
|
-
[Unreleased]: https://github.com/kettle-dev/kettle-family/compare/v1.3.
|
|
3520
|
+
[Unreleased]: https://github.com/kettle-dev/kettle-family/compare/v1.3.46...HEAD
|
|
3521
|
+
[1.3.46]: https://github.com/kettle-dev/kettle-family/compare/v1.3.45...v1.3.46
|
|
3522
|
+
[1.3.46t]: https://github.com/kettle-dev/kettle-family/releases/tag/v1.3.46
|
|
3523
|
+
[1.3.45]: https://github.com/kettle-dev/kettle-family/compare/v1.3.44...v1.3.45
|
|
3524
|
+
[1.3.45t]: https://github.com/kettle-dev/kettle-family/releases/tag/v1.3.45
|
|
3476
3525
|
[1.3.44]: https://github.com/kettle-dev/kettle-family/compare/v1.3.43...v1.3.44
|
|
3477
3526
|
[1.3.44t]: https://github.com/kettle-dev/kettle-family/releases/tag/v1.3.44
|
|
3478
3527
|
[1.3.43]: https://github.com/kettle-dev/kettle-family/compare/v1.3.42...v1.3.43
|
data/README.md
CHANGED
|
@@ -110,6 +110,12 @@ gem install kettle-family
|
|
|
110
110
|
`kettle-family` reads `.kettle-family.yml` from the family root by default.
|
|
111
111
|
Use `--config PATH` to load a different file.
|
|
112
112
|
|
|
113
|
+
Family `readme.corporate_sponsors` entries are seeded into each member's
|
|
114
|
+
`.structuredmerge/kettle-jem.yml` when running `kettle-family template` with
|
|
115
|
+
kettle-jem. Entries are matched by name: existing member entries take precedence,
|
|
116
|
+
and member-only sponsors are retained. Edit the member file to change an
|
|
117
|
+
existing sponsor; standalone kettle-jem runs use that file too.
|
|
118
|
+
|
|
113
119
|
Member discovery is recursive under the family member search roots. Discovery
|
|
114
120
|
skips gemspecs ignored by git and any configured `members.exclude` glob patterns
|
|
115
121
|
before loading gemspec metadata, so fixture or temporary gemspecs do not create
|
|
@@ -1137,7 +1143,7 @@ If none of the available licenses suit your use case, please [contact us](mailto
|
|
|
1137
1143
|
[📌gitmoji]: https://gitmoji.dev
|
|
1138
1144
|
[📌gitmoji-img]: https://img.shields.io/badge/gitmoji_commits-%20%F0%9F%98%9C%20%F0%9F%98%8D-34495e.svg?style=flat-square
|
|
1139
1145
|
[🧮kloc]: https://www.youtube.com/watch?v=dQw4w9WgXcQ
|
|
1140
|
-
[🧮kloc-img]: https://img.shields.io/badge/KLOC-
|
|
1146
|
+
[🧮kloc-img]: https://img.shields.io/badge/KLOC-9.197-FFDD67.svg?style=for-the-badge&logo=YouTube&logoColor=blue
|
|
1141
1147
|
[🔐security]: https://github.com/kettle-dev/kettle-family/blob/main/SECURITY.md
|
|
1142
1148
|
[🔐security-img]: https://img.shields.io/badge/security-policy-259D6C.svg?style=flat
|
|
1143
1149
|
[📄copyright-notice-explainer]: https://opensource.stackexchange.com/questions/5778/why-do-licenses-such-as-the-mit-license-specify-a-single-year
|
|
@@ -0,0 +1,263 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
require "open3"
|
|
4
|
+
|
|
5
|
+
module Kettle
|
|
6
|
+
module Family
|
|
7
|
+
# Family-level preflight: bundle- and history-mutating commands run from
|
|
8
|
+
# branches the family expects, or stop before any member is touched.
|
|
9
|
+
#
|
|
10
|
+
# Why this gate exists: template_sync rebases whatever branch is checked
|
|
11
|
+
# out onto the default branch, and local sibling wiring resolves sibling
|
|
12
|
+
# gems from their CHECKED-OUT branches — so a member parked on the wrong
|
|
13
|
+
# branch turns into wrong-branch commits, or into an unresolvable bundle
|
|
14
|
+
# when a sibling sits on a maintenance lane (a member requiring
|
|
15
|
+
# `oauth2 ~> 2.0` against an oauth2 checkout on 1-4-stable providing
|
|
16
|
+
# 1.4.12). Both surface here as named preflight failures with the remedy,
|
|
17
|
+
# instead of mid-run Bundler errors or commits on the wrong branch.
|
|
18
|
+
#
|
|
19
|
+
# Expected branches per member: the repo's default branch (origin/HEAD),
|
|
20
|
+
# plus configured release/stack lanes (family `release.member_target_branches`,
|
|
21
|
+
# member-local `release.target_branches`, and `branch_lanes`), plus any
|
|
22
|
+
# `--branch MEMBER:BRANCH` override.
|
|
23
|
+
#
|
|
24
|
+
# Sibling satisfiability is only checked when local sibling wiring is
|
|
25
|
+
# active (the family's local-path env toggle, or K_JEM_TEMPLATING); with
|
|
26
|
+
# released gems the checkout versions are irrelevant.
|
|
27
|
+
class BranchCheckoutCheck
|
|
28
|
+
PHASE = "branch_checkout_check"
|
|
29
|
+
|
|
30
|
+
# Gated commands. Release is deliberately absent: branch-stack release
|
|
31
|
+
# flows check out their target lanes themselves, so the pre-existing
|
|
32
|
+
# checkout is not the thing release mutates from.
|
|
33
|
+
GATED_COMMANDS = %w[bump bup template].freeze
|
|
34
|
+
|
|
35
|
+
FALSEY_ENV = %w[false 0 no off].freeze
|
|
36
|
+
|
|
37
|
+
def self.gated?(command)
|
|
38
|
+
GATED_COMMANDS.include?(command.to_s)
|
|
39
|
+
end
|
|
40
|
+
|
|
41
|
+
def self.call(config:, members:, overrides: {})
|
|
42
|
+
new(config: config, members: members, overrides: overrides).call
|
|
43
|
+
end
|
|
44
|
+
|
|
45
|
+
def initialize(config:, members:, overrides: {})
|
|
46
|
+
@config = config
|
|
47
|
+
@members = members
|
|
48
|
+
@overrides = overrides || {}
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
def call
|
|
52
|
+
found = diagnostics
|
|
53
|
+
CommandResult.new(
|
|
54
|
+
member_name: config.family_name,
|
|
55
|
+
phase: PHASE,
|
|
56
|
+
command: ["internal", PHASE],
|
|
57
|
+
workdir: config.root,
|
|
58
|
+
status: found.empty? ? 0 : 1,
|
|
59
|
+
success: found.empty?,
|
|
60
|
+
stdout: found.map { |diagnostic| diagnostic.fetch("message") }.join("\n"),
|
|
61
|
+
stderr: "",
|
|
62
|
+
elapsed_seconds: 0.0,
|
|
63
|
+
skipped: false,
|
|
64
|
+
reason: found.empty? ? nil : "members checked out on unexpected branches",
|
|
65
|
+
diagnostics: found
|
|
66
|
+
)
|
|
67
|
+
end
|
|
68
|
+
|
|
69
|
+
private
|
|
70
|
+
|
|
71
|
+
attr_reader :config, :members, :overrides
|
|
72
|
+
|
|
73
|
+
def diagnostics
|
|
74
|
+
members.flat_map { |member| member_diagnostics(member) }.compact
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
def member_diagnostics(member)
|
|
78
|
+
[branch_diagnostic(member), *sibling_diagnostics(member)]
|
|
79
|
+
end
|
|
80
|
+
|
|
81
|
+
# nil when the member is not a git repo (nothing to enforce), when the
|
|
82
|
+
# default branch cannot be determined (enforcement would be a guess),
|
|
83
|
+
# or when the checkout is on an expected branch.
|
|
84
|
+
def branch_diagnostic(member)
|
|
85
|
+
current = current_branch(member.root)
|
|
86
|
+
return nil unless current
|
|
87
|
+
return detached_diagnostic(member) if current.empty?
|
|
88
|
+
|
|
89
|
+
default = default_branch(member.root)
|
|
90
|
+
return nil unless default
|
|
91
|
+
|
|
92
|
+
expected = expected_branches(member, default)
|
|
93
|
+
return nil if expected.include?(current)
|
|
94
|
+
|
|
95
|
+
unexpected_branch_diagnostic(member, current, expected)
|
|
96
|
+
end
|
|
97
|
+
|
|
98
|
+
def expected_branches(member, default)
|
|
99
|
+
branches = [default]
|
|
100
|
+
branches.concat(stack_lanes(member))
|
|
101
|
+
override = overrides[member.name]
|
|
102
|
+
branches << override if override
|
|
103
|
+
branches.uniq
|
|
104
|
+
end
|
|
105
|
+
|
|
106
|
+
# Configured lanes the member may legitimately be checked out on, from
|
|
107
|
+
# both config key shapes (family member_target_branches and member-local
|
|
108
|
+
# release.target_branches — see BranchTargetConfig), plus branch_lanes.
|
|
109
|
+
def stack_lanes(member)
|
|
110
|
+
lanes = Array(config.member_release_target_branches[member.name])
|
|
111
|
+
release_config = BranchTargetConfig.member_release_config(member: member, config: config)
|
|
112
|
+
lanes |= release_config.release_target_branches if release_config
|
|
113
|
+
lane_branches = config.branch_lanes.values.select do |lane|
|
|
114
|
+
Array(lane["members"]).include?(member.name)
|
|
115
|
+
end.map { |lane| lane["branch"].to_s }
|
|
116
|
+
lanes | lane_branches
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
def unexpected_branch_diagnostic(member, current, expected)
|
|
120
|
+
{
|
|
121
|
+
"kind" => "unexpected_branch",
|
|
122
|
+
"member" => member.name,
|
|
123
|
+
"root" => member.root,
|
|
124
|
+
"current" => current,
|
|
125
|
+
"expected" => expected,
|
|
126
|
+
"message" => "#{member.name} is on branch #{current.inspect}, expected #{expected.join(" or ")}; " \
|
|
127
|
+
"switch with `git -C #{member.root} switch #{expected.first}` " \
|
|
128
|
+
"or allow the current branch with --branch #{member.name}:#{current}"
|
|
129
|
+
}
|
|
130
|
+
end
|
|
131
|
+
|
|
132
|
+
def detached_diagnostic(member)
|
|
133
|
+
default = default_branch(member.root)
|
|
134
|
+
expected = default ? expected_branches(member, default) : []
|
|
135
|
+
target = expected.empty? ? "the default branch" : expected.join(" or ")
|
|
136
|
+
switch = expected.empty? ? "" : " (`git -C #{member.root} switch #{expected.first}`)"
|
|
137
|
+
{
|
|
138
|
+
"kind" => "detached_head",
|
|
139
|
+
"member" => member.name,
|
|
140
|
+
"root" => member.root,
|
|
141
|
+
"message" => "#{member.name} is on a detached HEAD; switch to #{target}#{switch}"
|
|
142
|
+
}
|
|
143
|
+
end
|
|
144
|
+
|
|
145
|
+
# Cross-member version satisfiability: a member's sibling runtime
|
|
146
|
+
# requirements must be satisfiable from the siblings' checked-out
|
|
147
|
+
# versions whenever local sibling wiring is active. With released gems
|
|
148
|
+
# the registry resolves instead, and checkout versions are irrelevant.
|
|
149
|
+
def sibling_diagnostics(member)
|
|
150
|
+
return [] unless local_wiring_active?
|
|
151
|
+
return [] unless member.gemspec_path && File.file?(member.gemspec_path)
|
|
152
|
+
|
|
153
|
+
spec = load_gemspec(member)
|
|
154
|
+
return [] unless spec
|
|
155
|
+
|
|
156
|
+
siblings = all_members_by_name
|
|
157
|
+
spec.runtime_dependencies.filter_map do |dependency|
|
|
158
|
+
sibling = siblings[dependency.name]
|
|
159
|
+
next unless sibling
|
|
160
|
+
|
|
161
|
+
version = sibling_version(sibling)
|
|
162
|
+
next unless version
|
|
163
|
+
next if dependency.requirement.satisfied_by?(version)
|
|
164
|
+
|
|
165
|
+
sibling_mismatch_diagnostic(member, sibling, dependency, version)
|
|
166
|
+
end
|
|
167
|
+
end
|
|
168
|
+
|
|
169
|
+
def sibling_mismatch_diagnostic(member, sibling, dependency, version)
|
|
170
|
+
sibling_branch = current_branch(sibling.root)
|
|
171
|
+
{
|
|
172
|
+
"kind" => "sibling_version_mismatch",
|
|
173
|
+
"member" => member.name,
|
|
174
|
+
"sibling" => sibling.name,
|
|
175
|
+
"requirement" => dependency.requirement.to_s,
|
|
176
|
+
"actual" => version.to_s,
|
|
177
|
+
"message" => "#{member.name} requires #{dependency.name} #{dependency.requirement}, " \
|
|
178
|
+
"but the #{sibling.name} checkout provides #{version}#{branch_note(sibling_branch)}; " \
|
|
179
|
+
"switch #{sibling.name} to a branch carrying a matching version, or run with released gems"
|
|
180
|
+
}
|
|
181
|
+
end
|
|
182
|
+
|
|
183
|
+
def branch_note(sibling_branch)
|
|
184
|
+
" (branch #{sibling_branch.inspect})" if sibling_branch
|
|
185
|
+
end
|
|
186
|
+
|
|
187
|
+
def local_wiring_active?
|
|
188
|
+
family_env = config.family_local_path_env_name
|
|
189
|
+
truthy_env?(ENV.fetch("K_JEM_TEMPLATING", nil)) ||
|
|
190
|
+
(family_env && truthy_env?(ENV.fetch(family_env, nil)))
|
|
191
|
+
end
|
|
192
|
+
|
|
193
|
+
def truthy_env?(value)
|
|
194
|
+
return false if value.nil?
|
|
195
|
+
|
|
196
|
+
!FALSEY_ENV.include?(value.to_s.strip.downcase)
|
|
197
|
+
end
|
|
198
|
+
|
|
199
|
+
# Every discovered family member by name — the sibling universe — not
|
|
200
|
+
# only the selected members: a --only run still resolves the unselected
|
|
201
|
+
# siblings' checkouts.
|
|
202
|
+
def all_members_by_name
|
|
203
|
+
@all_members_by_name ||= Discovery.new(config: config).members.to_h { |member| [member.name, member] }
|
|
204
|
+
end
|
|
205
|
+
|
|
206
|
+
def sibling_version(sibling)
|
|
207
|
+
return nil if sibling.version.to_s.empty?
|
|
208
|
+
|
|
209
|
+
Gem::Version.new(sibling.version)
|
|
210
|
+
rescue ArgumentError
|
|
211
|
+
nil
|
|
212
|
+
end
|
|
213
|
+
|
|
214
|
+
# Some gemspecs use root-relative loads (see MemberLoader). A gemspec
|
|
215
|
+
# that cannot load returns nil from Gem::Specification.load (with a
|
|
216
|
+
# warning), and the preflight simply skips it.
|
|
217
|
+
def load_gemspec(member)
|
|
218
|
+
# rubocop:disable ThreadSafety/DirChdir
|
|
219
|
+
Dir.chdir(member.root) { Gem::Specification.load(member.gemspec_path) }
|
|
220
|
+
# rubocop:enable ThreadSafety/DirChdir
|
|
221
|
+
end
|
|
222
|
+
|
|
223
|
+
# The repo's default branch: the origin/HEAD symref a clone sets, with
|
|
224
|
+
# `git remote show origin` (the sync command's fallback) when the symref
|
|
225
|
+
# is unset. nil when neither can answer — branch enforcement is skipped
|
|
226
|
+
# rather than guessed.
|
|
227
|
+
def default_branch(root)
|
|
228
|
+
@default_branches ||= {}
|
|
229
|
+
return @default_branches[root] if @default_branches.key?(root)
|
|
230
|
+
|
|
231
|
+
@default_branches[root] = detect_default_branch(root)
|
|
232
|
+
end
|
|
233
|
+
|
|
234
|
+
def detect_default_branch(root)
|
|
235
|
+
stdout, _stderr, status = Open3.capture3("git", "symbolic-ref", "--quiet", "--short", "refs/remotes/origin/HEAD", chdir: root)
|
|
236
|
+
ref = status.success? ? stdout.strip.sub(%r{\Aorigin/}, "") : ""
|
|
237
|
+
return ref unless ref.empty?
|
|
238
|
+
|
|
239
|
+
stdout, _stderr, status = Open3.capture3("git", "remote", "show", "origin", chdir: root)
|
|
240
|
+
return nil unless status.success?
|
|
241
|
+
|
|
242
|
+
branch = stdout[/HEAD branch:\s*(\S+)/, 1]
|
|
243
|
+
# "(unknown)" / ambiguity notices are placeholders, not branch names.
|
|
244
|
+
branch&.start_with?("(") ? nil : branch
|
|
245
|
+
rescue SystemCallError
|
|
246
|
+
nil
|
|
247
|
+
end
|
|
248
|
+
|
|
249
|
+
# Current branch short name; "" on a detached HEAD, nil when the root
|
|
250
|
+
# is not a git repo (or git cannot answer). Memoized per root — monorepo
|
|
251
|
+
# members share one repo.
|
|
252
|
+
def current_branch(root)
|
|
253
|
+
@current_branches ||= {}
|
|
254
|
+
return @current_branches[root] if @current_branches.key?(root)
|
|
255
|
+
|
|
256
|
+
stdout, _stderr, status = Open3.capture3("git", "branch", "--show-current", chdir: root)
|
|
257
|
+
@current_branches[root] = status.success? ? stdout.strip : nil
|
|
258
|
+
rescue SystemCallError
|
|
259
|
+
@current_branches[root] = nil
|
|
260
|
+
end
|
|
261
|
+
end
|
|
262
|
+
end
|
|
263
|
+
end
|
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
# NOTE: `bundler` is deliberately NOT required at load time. family.rb
|
|
4
|
+
# requires this file eagerly for every CLI invocation, and loading Bundler
|
|
5
|
+
# activates the DEFAULT Bundler — whose vendored `uri` clashes with
|
|
6
|
+
# RubyGems' own vendored copy (the Gem::URI double-initialization warning
|
|
7
|
+
# wall on stderr) whenever the default Bundler is 4.x. `bundled_with`
|
|
8
|
+
# requires it at the point of use instead, so plain CLI invocations never
|
|
9
|
+
# load Bundler.
|
|
10
|
+
require "kettle/dev/bundler_pinning"
|
|
11
|
+
|
|
12
|
+
module Kettle
|
|
13
|
+
module Family
|
|
14
|
+
# Family-level preflight: bundle-mutating commands run on the latest
|
|
15
|
+
# stable Bundler, or stop before any member is touched.
|
|
16
|
+
#
|
|
17
|
+
# Why this gate exists: Bundler updates used to happen as a side effect
|
|
18
|
+
# of commands that were not about Bundler (a bare `--bundler` in a
|
|
19
|
+
# configured normalize_lockfiles_command), which drifted BUNDLED WITH
|
|
20
|
+
# pins and could pull a prerelease (the 4.1.0.betaN infection vector).
|
|
21
|
+
# Bundler updates are owned by ONE command — update-bundler (bupb) — and
|
|
22
|
+
# the other bundle-mutating commands verify the family is current before
|
|
23
|
+
# touching a member, so drift surfaces as a named preflight failure with
|
|
24
|
+
# the remedy instead of a mid-run Bundler error.
|
|
25
|
+
#
|
|
26
|
+
# "Latest stable" means the newest non-prerelease version the registry
|
|
27
|
+
# serves, minus Kettle::Dev::BundlerPinning::HELD_VERSIONS (known-bad
|
|
28
|
+
# stables). Fails open when the registry cannot be consulted: an offline
|
|
29
|
+
# run is never blocked by network conditions.
|
|
30
|
+
#
|
|
31
|
+
# The gate also covers the other half of the pair: Bundler and RubyGems
|
|
32
|
+
# release in lockstep, and a machine that updates Bundler without
|
|
33
|
+
# updating RubyGems (gem -v) gets the vendored-uri clash — Bundler's
|
|
34
|
+
# vendored uri vs RubyGems' own — flooding every spawned subprocess's
|
|
35
|
+
# stderr with Gem::URI double-initialization warnings (a release coverage
|
|
36
|
+
# run died on exactly that). Remedy: `gem update --system`.
|
|
37
|
+
class BundlerVersionCheck
|
|
38
|
+
PHASE = "bundler_version_check"
|
|
39
|
+
|
|
40
|
+
# Commands gated by the preflight. bupb / update-bundler are
|
|
41
|
+
# deliberately absent: they are the remedy the diagnostics point at,
|
|
42
|
+
# and gating them would deadlock the fix.
|
|
43
|
+
GATED_COMMANDS = %w[bup template].freeze
|
|
44
|
+
|
|
45
|
+
def self.gated?(command)
|
|
46
|
+
GATED_COMMANDS.include?(command.to_s)
|
|
47
|
+
end
|
|
48
|
+
|
|
49
|
+
def self.call(config:, members:)
|
|
50
|
+
new(config: config, members: members).call
|
|
51
|
+
end
|
|
52
|
+
|
|
53
|
+
def initialize(config:, members:)
|
|
54
|
+
@config = config
|
|
55
|
+
@members = members
|
|
56
|
+
end
|
|
57
|
+
|
|
58
|
+
def call
|
|
59
|
+
found = diagnostics
|
|
60
|
+
CommandResult.new(
|
|
61
|
+
member_name: config.family_name,
|
|
62
|
+
phase: PHASE,
|
|
63
|
+
command: ["internal", PHASE],
|
|
64
|
+
workdir: config.root,
|
|
65
|
+
status: found.empty? ? 0 : 1,
|
|
66
|
+
success: found.empty?,
|
|
67
|
+
stdout: found.map { |diagnostic| diagnostic.fetch("message") }.join("\n"),
|
|
68
|
+
stderr: "",
|
|
69
|
+
elapsed_seconds: 0.0,
|
|
70
|
+
skipped: false,
|
|
71
|
+
reason: found.empty? ? nil : "Bundler drifted from the latest stable",
|
|
72
|
+
diagnostics: found
|
|
73
|
+
)
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
private
|
|
77
|
+
|
|
78
|
+
attr_reader :config, :members
|
|
79
|
+
|
|
80
|
+
def diagnostics
|
|
81
|
+
bundler_diagnostics + rubygems_diagnostics
|
|
82
|
+
end
|
|
83
|
+
|
|
84
|
+
def bundler_diagnostics
|
|
85
|
+
expected = Kettle::Dev::BundlerPinning.published_stable
|
|
86
|
+
return [] unless expected
|
|
87
|
+
|
|
88
|
+
installed_diagnostics(expected) + lockfile_diagnostics(expected)
|
|
89
|
+
end
|
|
90
|
+
|
|
91
|
+
# The RubyGems half of the matched pair: `gem -v` against the newest
|
|
92
|
+
# stable rubygems-update the registry serves. Fails open independently
|
|
93
|
+
# of the Bundler half — each registry lookup has its own outage story.
|
|
94
|
+
# Skipped entirely when the bundled kettle-dev predates the pair
|
|
95
|
+
# lookups (the Bundler half still gates), exactly like the fail-open
|
|
96
|
+
# registry story.
|
|
97
|
+
def rubygems_diagnostics
|
|
98
|
+
return [] unless Kettle::Dev::BundlerPinning.respond_to?(:published_stable_rubygems)
|
|
99
|
+
|
|
100
|
+
expected = Kettle::Dev::BundlerPinning.published_stable_rubygems
|
|
101
|
+
return [] unless expected
|
|
102
|
+
|
|
103
|
+
installed = Kettle::Dev::BundlerPinning.installed_rubygems
|
|
104
|
+
return [] if installed >= expected
|
|
105
|
+
|
|
106
|
+
[{
|
|
107
|
+
"kind" => "rubygems_lags_bundler_pair",
|
|
108
|
+
"member" => config.family_name,
|
|
109
|
+
"expected" => expected.to_s,
|
|
110
|
+
"actual" => installed.to_s,
|
|
111
|
+
"remedy" => "gem update --system",
|
|
112
|
+
"message" => "installed RubyGems #{installed} lags the registry's latest stable #{expected}; " \
|
|
113
|
+
"Bundler and RubyGems release as a matched pair, and a mismatched pair floods subprocess stderr " \
|
|
114
|
+
"with Gem::URI double-initialization warnings (vendored uri clash) — run `gem update --system`"
|
|
115
|
+
}]
|
|
116
|
+
end
|
|
117
|
+
|
|
118
|
+
def installed_diagnostics(expected)
|
|
119
|
+
installed = Kettle::Dev::BundlerPinning.installed_stable
|
|
120
|
+
return [missing_installed_diagnostic(expected)] unless installed
|
|
121
|
+
return [] if installed == expected
|
|
122
|
+
|
|
123
|
+
[installed_drift_diagnostic(installed, expected)]
|
|
124
|
+
end
|
|
125
|
+
|
|
126
|
+
def missing_installed_diagnostic(expected)
|
|
127
|
+
{
|
|
128
|
+
"kind" => "bundler_not_installed",
|
|
129
|
+
"member" => config.family_name,
|
|
130
|
+
"expected" => expected.to_s,
|
|
131
|
+
"actual" => nil,
|
|
132
|
+
"message" => "no stable Bundler is installed; " \
|
|
133
|
+
"run `kettle-family update-bundler --execute` to install #{expected} and re-pin the family"
|
|
134
|
+
}
|
|
135
|
+
end
|
|
136
|
+
|
|
137
|
+
def installed_drift_diagnostic(installed, expected)
|
|
138
|
+
held_reason = Kettle::Dev::BundlerPinning.held_reason(installed)
|
|
139
|
+
{
|
|
140
|
+
"kind" => "bundler_installed_drift",
|
|
141
|
+
"member" => config.family_name,
|
|
142
|
+
"expected" => expected.to_s,
|
|
143
|
+
"actual" => installed.to_s,
|
|
144
|
+
"held" => !held_reason.nil?,
|
|
145
|
+
"message" => installed_drift_message(installed, expected, held_reason)
|
|
146
|
+
}
|
|
147
|
+
end
|
|
148
|
+
|
|
149
|
+
def installed_drift_message(installed, expected, held_reason)
|
|
150
|
+
if held_reason
|
|
151
|
+
"installed stable Bundler #{installed} is a known-bad held version (#{held_reason}); " \
|
|
152
|
+
"run `kettle-family update-bundler --execute` to move the family to #{expected}"
|
|
153
|
+
elsif installed < expected
|
|
154
|
+
"installed stable Bundler #{installed} lags the registry's latest stable #{expected}; " \
|
|
155
|
+
"run `kettle-family update-bundler --execute`"
|
|
156
|
+
else
|
|
157
|
+
"installed stable Bundler #{installed} is newer than the registry's latest stable #{expected}; " \
|
|
158
|
+
"if #{installed} is known-bad, register it in Kettle::Dev::BundlerPinning::HELD_VERSIONS"
|
|
159
|
+
end
|
|
160
|
+
end
|
|
161
|
+
|
|
162
|
+
def lockfile_diagnostics(expected)
|
|
163
|
+
members.map { |member| lockfile_diagnostic(member, expected) }.compact
|
|
164
|
+
end
|
|
165
|
+
|
|
166
|
+
def lockfile_diagnostic(member, expected)
|
|
167
|
+
pinned = bundled_with(member)
|
|
168
|
+
return nil unless pinned
|
|
169
|
+
return nil if pinned == expected
|
|
170
|
+
|
|
171
|
+
{
|
|
172
|
+
"kind" => "bundler_lockfile_drift",
|
|
173
|
+
"member" => member.name,
|
|
174
|
+
"lockfile" => File.join(member.root, "Gemfile.lock"),
|
|
175
|
+
"expected" => expected.to_s,
|
|
176
|
+
"actual" => pinned.to_s,
|
|
177
|
+
"message" => lockfile_drift_message(member, pinned, expected)
|
|
178
|
+
}
|
|
179
|
+
end
|
|
180
|
+
|
|
181
|
+
def lockfile_drift_message(member, pinned, expected)
|
|
182
|
+
prerelease = pinned.prerelease? ? " (a prerelease — the reinfection vector)" : ""
|
|
183
|
+
"#{member.name} pins Bundler #{pinned}#{prerelease} in BUNDLED WITH, " \
|
|
184
|
+
"but the latest stable is #{expected}; run `kettle-family update-bundler --execute`"
|
|
185
|
+
end
|
|
186
|
+
|
|
187
|
+
# Bundler's own lockfile parser owns the BUNDLED WITH trailer. A
|
|
188
|
+
# lockfile without one (ancient), or one Bundler cannot parse, is not
|
|
189
|
+
# gated here — readiness and Bundler itself report those louder.
|
|
190
|
+
def bundled_with(member)
|
|
191
|
+
lockfile = File.join(member.root, "Gemfile.lock")
|
|
192
|
+
return nil unless File.file?(lockfile)
|
|
193
|
+
|
|
194
|
+
require "bundler"
|
|
195
|
+
Bundler::LockfileParser.new(Bundler.read_file(lockfile)).bundler_version
|
|
196
|
+
rescue Bundler::BundlerError, ArgumentError
|
|
197
|
+
nil
|
|
198
|
+
end
|
|
199
|
+
end
|
|
200
|
+
end
|
|
201
|
+
end
|
data/lib/kettle/family/cli.rb
CHANGED
|
@@ -55,6 +55,9 @@ module Kettle
|
|
|
55
55
|
base.option :only, value: {type: String, usage: "MEMBERS"}, desc: "Select comma-separated members or branch targets (MEMBER@BRANCH), or release-state tokens: unreleased/unrel, prepared/prep, pending/pend, bump"
|
|
56
56
|
base.option :exclude, value: {type: String, usage: "MEMBERS"}, desc: "Exclude comma-separated members"
|
|
57
57
|
base.option :start_at, long: "--start-at", value: {type: String, usage: "MEMBER[@BRANCH]"}, desc: "Select from member through the end of order"
|
|
58
|
+
base.option :branch, value: {type: String, usage: "MEMBER:BRANCH"}, desc: "Allow MEMBER to run from BRANCH instead of an expected branch (repeatable)" do |value|
|
|
59
|
+
parse_branch_override(value)
|
|
60
|
+
end
|
|
58
61
|
end
|
|
59
62
|
end
|
|
60
63
|
|
|
@@ -143,11 +146,12 @@ module Kettle
|
|
|
143
146
|
def initialize(**kwargs)
|
|
144
147
|
super
|
|
145
148
|
@workflow_env = {}
|
|
149
|
+
@branch_overrides = {}
|
|
146
150
|
end
|
|
147
151
|
|
|
148
152
|
private
|
|
149
153
|
|
|
150
|
-
attr_reader :workflow_env
|
|
154
|
+
attr_reader :workflow_env, :branch_overrides
|
|
151
155
|
|
|
152
156
|
def family_options(overrides = {})
|
|
153
157
|
{
|
|
@@ -195,7 +199,8 @@ module Kettle
|
|
|
195
199
|
target_version: nil,
|
|
196
200
|
reset_target: nil,
|
|
197
201
|
bup_args: [],
|
|
198
|
-
bex_args: []
|
|
202
|
+
bex_args: [],
|
|
203
|
+
branch_overrides: branch_overrides
|
|
199
204
|
}.merge(overrides)
|
|
200
205
|
end
|
|
201
206
|
|
|
@@ -212,6 +217,13 @@ module Kettle
|
|
|
212
217
|
options.key?(name) && !!options[name]
|
|
213
218
|
end
|
|
214
219
|
|
|
220
|
+
def parse_branch_override(value)
|
|
221
|
+
member, branch = value.split(":", 2)
|
|
222
|
+
raise OptionParser::InvalidArgument, "--branch requires MEMBER:BRANCH" if member.to_s.empty? || branch.to_s.empty?
|
|
223
|
+
|
|
224
|
+
branch_overrides[member] = branch
|
|
225
|
+
end
|
|
226
|
+
|
|
215
227
|
def parse_env_override(value, env)
|
|
216
228
|
key, env_value = value.split("=", 2)
|
|
217
229
|
raise OptionParser::InvalidArgument, "--env requires KEY=VALUE" if key.to_s.empty? || env_value.nil?
|