kettle-jem 7.1.45 → 8.0.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.
Files changed (37) hide show
  1. checksums.yaml +4 -4
  2. checksums.yaml.gz.sig +0 -0
  3. data/CHANGELOG.md +100 -1
  4. data/LICENSE.md +4 -6
  5. data/README.md +113 -21
  6. data/lib/kettle/jem/maintenance_changelog.rb +49 -9
  7. data/lib/kettle/jem/member_workflow_wrappers.rb +24 -1
  8. data/lib/kettle/jem/tasks/install_task.rb +64 -4
  9. data/lib/kettle/jem/templates/.github/workflows/perf-comment.yml.example +1 -1
  10. data/lib/kettle/jem/templates/.github/workflows/perf.yml.example +2 -2
  11. data/lib/kettle/jem/templates/.github/workflows/platforms.yml.example +87 -0
  12. data/lib/kettle/jem/templates/.structuredmerge/kettle-jem.yml.example +2 -1
  13. data/lib/kettle/jem/templates/AGENTS.md.example +56 -272
  14. data/lib/kettle/jem/templates/CHANGELOG.transfer.md +42 -9
  15. data/lib/kettle/jem/templates/CODE_OF_CONDUCT.md.example +58 -100
  16. data/lib/kettle/jem/templates/CONTRIBUTING.md.example +35 -1
  17. data/lib/kettle/jem/templates/FUNDING.md.example +7 -0
  18. data/lib/kettle/jem/templates/FUNDING.md.no-osc.example +7 -0
  19. data/lib/kettle/jem/templates/README.md.example +23 -19
  20. data/lib/kettle/jem/templates/SECURITY.md.example +3 -3
  21. data/lib/kettle/jem/templates/gem.gemspec.example +3 -3
  22. data/lib/kettle/jem/templates/gemfiles/modular/coverage.gemfile.example +1 -1
  23. data/lib/kettle/jem/templates/gemfiles/modular/coverage_local.gemfile.example +4 -2
  24. data/lib/kettle/jem/templates/gemfiles/modular/documentation_local.gemfile.example +2 -1
  25. data/lib/kettle/jem/templates/gemfiles/modular/duel.gemfile.example +1 -1
  26. data/lib/kettle/jem/templates/gemfiles/modular/style.gemfile.example +1 -1
  27. data/lib/kettle/jem/templates/gemfiles/modular/style_local.gemfile.example +2 -1
  28. data/lib/kettle/jem/templates/gemfiles/modular/templating.gemfile.example +1 -1
  29. data/lib/kettle/jem/templates/gemfiles/modular/templating_local.gemfile.example +4 -2
  30. data/lib/kettle/jem/templates/readme/partials/configuration.md.example +0 -1
  31. data/lib/kettle/jem/templates/shim/Gemfile.example +1 -1
  32. data/lib/kettle/jem/templates/shim/gem.gemspec.example +2 -2
  33. data/lib/kettle/jem/version.rb +1 -1
  34. data/lib/kettle/jem.rb +306 -127
  35. data.tar.gz.sig +0 -0
  36. metadata +48 -184
  37. metadata.gz.sig +0 -0
data/lib/kettle/jem.rb CHANGED
@@ -70,12 +70,12 @@ module Kettle
70
70
  # declarations in the destination and reconciles their complete requirement
71
71
  # set in place before Bundler is allowed to evaluate that destination.
72
72
  TEMPLATE_MANAGED_DEPENDENCIES = [
73
- {name: PACKAGE_NAME, requirements: ["~> 7.1", ">= 7.1.28"], bootstrap: false},
74
- {name: "nomono", requirements: ["~> 1.1", ">= 1.1.19"], bootstrap: true},
75
- {name: "kettle-dev", requirements: ["~> 3.1", ">= 3.1.36"], bootstrap: true},
73
+ {name: PACKAGE_NAME, requirements: [">= 7.1.28", "< 9"], bootstrap: false},
74
+ {name: "nomono", requirements: ["~> 1.1", ">= 1.1.22"], bootstrap: true},
75
+ {name: "kettle-dev", requirements: ["~> 3.1", ">= 3.1.41"], bootstrap: true},
76
76
  {
77
77
  name: "kettle-changelog",
78
- requirements: ["~> 1.0", ">= 1.0.23"],
78
+ requirements: ["~> 1.0", ">= 1.0.26"],
79
79
  bootstrap: true,
80
80
  ruby_requirement: ">= 4.0.0"
81
81
  }
@@ -153,7 +153,7 @@ module Kettle
153
153
  # (templates/.structuredmerge/kettle-jem.yml.example).
154
154
  PLATFORMS_CONFIG_DOCUMENTATION = [
155
155
  "# List the OS platforms this project's CI exercises. kettle-jem uses this to",
156
- "# generate the current.yml OS matrix and the README platform tier table.",
156
+ "# generate the current.yml and platforms.yml OS matrices and the README platform tier table.",
157
157
  "# Windows applies only when declared: the `if: matrix.os` guards and the",
158
158
  "# Windows-only test step are emitted solely for destinations that opt in.",
159
159
  "#",
@@ -322,6 +322,9 @@ module Kettle
322
322
  "Big-Time-Public-License.md",
323
323
  "mise.toml",
324
324
  "Gemfile",
325
+ ".rubocop",
326
+ ".rubocop.yml",
327
+ ".rubocop_rspec.yml",
325
328
  "certs/pboling.pem",
326
329
  "tmp/.gitignore"
327
330
  ].freeze
@@ -517,6 +520,8 @@ module Kettle
517
520
  "contributing",
518
521
  "versioning",
519
522
  "license",
523
+ # Never gated by license (FLOSS Funding is); carries the sponsor cards slot.
524
+ "corporate sponsorship",
520
525
  # Ends every README, members included; carries the sponsor-ask buttons.
521
526
  "please give the project a star ⭐ ♥."
522
527
  ].freeze
@@ -604,14 +609,21 @@ module Kettle
604
609
  RUBY_TEMPLATE_BASENAMES = Ast::Template::FileTypes::RUBY_BASENAMES
605
610
  RUBY_TEMPLATE_SUFFIXES = Ast::Template::FileTypes::RUBY_SUFFIXES
606
611
  RUBY_TEMPLATE_EXTENSIONS = Ast::Template::FileTypes::RUBY_EXTENSIONS
607
- TEMPLATE_TOKEN_CONFIG = Token::Resolver::Config.new(separators: ["|", ":"]).freeze
612
+ TEMPLATE_TOKEN_CONFIG = if Token::Resolver::Config.const_defined?(:VALID_PARSERS)
613
+ Token::Resolver::Config.new(separators: ["|", ":"], parser: :scanner).freeze
614
+ else
615
+ Token::Resolver::Config.new(separators: ["|", ":"]).freeze
616
+ end
608
617
  EMPTY_TEMPLATE_TOKENS = %w[
609
618
  KJ|CB:USER
610
619
  KJ|COPYRIGHT_PREFIX
620
+ KJ|CI:MACOS_HARDENING_STEP
621
+ KJ|CI:PLATFORMS_MACOS_HARDENING_STEP
611
622
  KJ|AUTHOR:DOMAIN
612
623
  KJ|AUTHOR:NAME
613
624
  KJ|AUTHOR:ORCID
614
625
  KJ|FUNDING:BUYMEACOFFEE
626
+ KJ|FUNDING:CLOUDROOM_REFERRAL
615
627
  KJ|FUNDING:KOFI
616
628
  KJ|FUNDING:LIBERAPAY
617
629
  KJ|FUNDING:PAYPAL
@@ -1643,8 +1655,11 @@ module Kettle
1643
1655
  labels: ["🖇kofi", "🖇kofi-img"]
1644
1656
  },
1645
1657
  "tidelift" => {
1646
- badges: ["[![Get help from me on Tidelift][🏙️entsup-tidelift-img]][🏙️entsup-tidelift]"],
1647
- labels: ["🏙️entsup-tidelift", "🏙️entsup-tidelift-img"]
1658
+ badges: [
1659
+ "[![Get help from me on Tidelift][🏙️entsup-tidelift-img]][🏙️entsup-tidelift]",
1660
+ "[![Lifted through Tidelift](https://tidelift.com/badges/package/rubygems/{KJ|GEM_NAME})][🏙️entsup-tidelift-sonar]"
1661
+ ],
1662
+ labels: ["🏙️entsup-tidelift", "🏙️entsup-tidelift-img", "🏙️entsup-tidelift-sonar"]
1648
1663
  }
1649
1664
  }.freeze
1650
1665
  README_INTEGRATIONS = %w[codecov coveralls qlty codeql skywalking-eyes].freeze
@@ -1704,7 +1719,8 @@ module Kettle
1704
1719
  kofi: "KJ_FUNDING_KOFI",
1705
1720
  paypal: "KJ_FUNDING_PAYPAL",
1706
1721
  buymeacoffee: "KJ_FUNDING_BUYMEACOFFEE",
1707
- liberapay: "KJ_FUNDING_LIBERAPAY"
1722
+ liberapay: "KJ_FUNDING_LIBERAPAY",
1723
+ cloudroom_referral: "KJ_FUNDING_CLOUDROOM_REFERRAL"
1708
1724
  }.freeze
1709
1725
  SOCIAL_TOKEN_ENV_KEYS = {
1710
1726
  mastodon: "KJ_SOCIAL_MASTODON",
@@ -1779,13 +1795,14 @@ module Kettle
1779
1795
  normalized_phase = normalize_phase(phase)
1780
1796
  normalized_timing = normalize_timing(timing)
1781
1797
  hooks_for(normalized_timing, normalized_phase).each do |hook|
1782
- hook.callback.call(
1798
+ arguments = {
1783
1799
  context: context,
1784
1800
  actor: actor,
1785
1801
  phase: normalized_phase,
1786
1802
  phase_stats: phase_stats,
1787
1803
  plugin_name: hook.plugin_name
1788
- )
1804
+ }
1805
+ hook.callback.call(**accepted_keywords(hook.callback, arguments))
1789
1806
  end
1790
1807
  end
1791
1808
 
@@ -1795,6 +1812,17 @@ module Kettle
1795
1812
 
1796
1813
  private
1797
1814
 
1815
+ # Plugins declare only the keywords they use (e.g. `do |context:|`), and
1816
+ # a block with explicit keywords rejects unknown ones. Pass each callback
1817
+ # just what it declares, or everything when it takes `**`.
1818
+ def accepted_keywords(callback, arguments)
1819
+ parameters = callback.parameters
1820
+ return arguments if parameters.any? { |type, _name| type == :keyrest }
1821
+
1822
+ declared = parameters.filter_map { |type, name| name if %i[key keyreq].include?(type) }
1823
+ arguments.slice(*declared)
1824
+ end
1825
+
1798
1826
  def hooks_for(timing, phase)
1799
1827
  @hooks.select { |hook| hook.timing == timing && hook.phase == phase }
1800
1828
  end
@@ -1907,6 +1935,15 @@ module Kettle
1907
1935
  @helpers = PluginHelpers.new(project_root: project_root, changed_files: changed_files, diagnostics: diagnostics)
1908
1936
  @out = PluginOutput.new(diagnostics: diagnostics)
1909
1937
  end
1938
+
1939
+ HASH_KEYS = %i[project_root mode facts recipe_pack recipe_reports phase_reports changed_files diagnostics].freeze
1940
+
1941
+ # Hash-style reads (`context[:project_root]`) for plugins written
1942
+ # against a plain Hash context, e.g. kettle-family <= 1.3.57.
1943
+ def [](key)
1944
+ name = key.to_sym
1945
+ HASH_KEYS.include?(name) ? public_send(name) : nil
1946
+ end
1910
1947
  end
1911
1948
 
1912
1949
  class PluginHelpers
@@ -2312,13 +2349,16 @@ module Kettle
2312
2349
  Array(state.fetch(key.to_s)).map(&:to_s).uniq.sort
2313
2350
  end
2314
2351
 
2315
- def update_maintenance_changelog_paths(project_root:, key:, paths:)
2352
+ def update_maintenance_changelog_paths(project_root:, key:, paths:, remove_keys: [])
2316
2353
  lock = load(project_root: project_root)
2317
2354
  template_state = lock.fetch(TEMPLATE_STATE_KEY, {}).dup
2318
2355
  changelog = maintenance_changelog(lock).dup
2319
2356
  normalized_paths = Array(paths).map(&:to_s).uniq.sort
2320
- return false if changelog[key.to_s] == normalized_paths
2357
+ keys_to_remove = Array(remove_keys).map(&:to_s) - [key.to_s]
2358
+ removed = keys_to_remove.any? { |old_key| changelog.key?(old_key) }
2359
+ return false if changelog[key.to_s] == normalized_paths && !removed
2321
2360
 
2361
+ keys_to_remove.each { |old_key| changelog.delete(old_key) }
2322
2362
  changelog[key.to_s] = normalized_paths
2323
2363
  template_state[MAINTENANCE_CHANGELOG_SUBKEY] = changelog
2324
2364
  lock[TEMPLATE_STATE_KEY] = template_state
@@ -2902,8 +2942,8 @@ module Kettle
2902
2942
  source_url = git_remote_source_url(project_root)
2903
2943
  package_name = repository_name_from_source_url(source_url)
2904
2944
  package_name = File.basename(project_root.to_s) if package_name.empty?
2905
- configured_or_detected_licenses = detected_license_ids(project_root)
2906
- configured_or_detected_licenses = Array(kettle_config["licenses"]) if configured_or_detected_licenses.empty?
2945
+ configured_licenses = Array(kettle_config["licenses"]).map { |id| id.to_s.strip }.reject(&:empty?)
2946
+ configured_or_detected_licenses = configured_licenses.empty? ? detected_license_ids(project_root) : configured_licenses
2907
2947
  copyright = copyright_facts(project_root, kettle_config)
2908
2948
  author = author_facts(kettle_config, env, copyright: copyright)
2909
2949
  license = license_facts(
@@ -2956,6 +2996,8 @@ module Kettle
2956
2996
  forge[:dvcs] = dvcs_states if dvcs_states
2957
2997
  facts[:forge] = forge unless forge.empty?
2958
2998
  facts[:social] = social unless social.empty?
2999
+ rubyforum = rubyforum_facts(kettle_config, env, package_name: package_name)
3000
+ facts[:rubyforum] = rubyforum unless rubyforum.empty?
2959
3001
  facts[:license] = license unless license.empty?
2960
3002
  facts[:project_runtime] = project_runtime unless project_runtime.empty?
2961
3003
  facts[:ruby_style] = ruby_style_facts(project_root)
@@ -5277,14 +5319,14 @@ module Kettle
5277
5319
 
5278
5320
  def monorepo_root_gemfile_dependency_lines
5279
5321
  [
5280
- {name: "appraisal2", source: %(gem "appraisal2", "~> 3.2", ">= 3.2.6"\n)},
5322
+ {name: "appraisal2", source: %(gem "appraisal2", "~> 3.2", ">= 3.2.7"\n)},
5281
5323
  {name: "bundler-audit", source: %(gem "bundler-audit", "~> 0.9.3"\n)},
5282
- {name: "kettle-dev", source: %(gem "kettle-dev", "~> 3.1", ">= 3.1.36"\n)},
5283
- {name: "kettle-drift", source: %(gem "kettle-drift", "~> 1.0", ">= 1.0.21"\n)},
5284
- {name: "kettle-family", source: %(gem "kettle-family", "~> 1.3", ">= 1.3.57"\n)},
5324
+ {name: "kettle-dev", source: %(gem "kettle-dev", "~> 3.1", ">= 3.1.41"\n)},
5325
+ {name: "kettle-drift", source: %(gem "kettle-drift", "~> 1.0", ">= 1.0.22"\n)},
5326
+ {name: "kettle-family", source: %(gem "kettle-family", "~> 1.3", ">= 1.3.64"\n)},
5285
5327
  {name: "kettle-sponsors", source: %(gem "kettle-sponsors", "~> 1.0", ">= 1.0.0"\n)},
5286
5328
  {name: PACKAGE_NAME, source: kettle_jem_dependency_source},
5287
- {name: "kettle-test", source: %(gem "kettle-test", "~> 2.0", ">= 2.0.31"\n)},
5329
+ {name: "kettle-test", source: %(gem "kettle-test", "~> 2.0", ">= 2.0.32"\n)},
5288
5330
  {name: "rake", source: %(gem "rake", "~> 13.0"\n)},
5289
5331
  {name: "rspec", source: %(gem "rspec", "~> 3.0"\n)},
5290
5332
  {name: "stone_checksums", source: %(gem "stone_checksums", "~> 1.0", ">= 1.0.11"\n)},
@@ -5789,6 +5831,7 @@ module Kettle
5789
5831
  "KJ|CB:USER" => "",
5790
5832
  "KJ|DEFAULT_TEST_MINIMUM_RUBY" => DEFAULT_TEST_MINIMUM_RUBY.to_s,
5791
5833
  "KJ|FUNDING:BUYMEACOFFEE" => "",
5834
+ "KJ|FUNDING:CLOUDROOM_REFERRAL" => "",
5792
5835
  "KJ|FUNDING:KOFI" => "",
5793
5836
  "KJ|FUNDING:LIBERAPAY" => "",
5794
5837
  "KJ|FUNDING:PAYPAL" => "",
@@ -7210,7 +7253,16 @@ module Kettle
7210
7253
  return finalize_rubocop_config(content, facts) if recipe.fetch(:target_path).to_s == ".rubocop.yml"
7211
7254
  return finalize_kettle_config_template_source(recipe, content) if recipe.fetch(:target_path).to_s == KETTLE_CONFIG_PATH
7212
7255
  return normalize_simplecov_template_source(content) if recipe.fetch(:target_path).to_s == ".simplecov"
7256
+ # Empty whole-line tokens (e.g. RAKE:TOP_LEVEL_DOCS_TASK at a monorepo
7257
+ # root) leave stacked blank lines; the merge path normalizes them, but
7258
+ # accept_template writes the render verbatim.
7259
+ return collapse_excess_blank_lines(content) if recipe.fetch(:target_path).to_s == "Rakefile"
7213
7260
  return normalize_spec_helper_simplecov_template_source(content) if recipe.fetch(:target_path).to_s == "spec/spec_helper.rb"
7261
+ # Prune here too, not only in the github_funding_yml recipe: monorepo
7262
+ # roots get FUNDING.yml solely from template source application, where
7263
+ # the destination-preferring merge would otherwise keep stale keys.
7264
+ return synchronize_github_funding_yml(content, facts) if facts && recipe.fetch(:target_path).to_s == ".github/FUNDING.yml"
7265
+ return postprocess_contributing_markdown_content(content, facts) if facts && recipe.fetch(:target_path).to_s == "CONTRIBUTING.md"
7214
7266
 
7215
7267
  content
7216
7268
  end
@@ -7668,6 +7720,11 @@ module Kettle
7668
7720
  keep: funding_platform_enabled?(facts.dig(:funding, :platforms), "tidelift")
7669
7721
  )
7670
7722
  processed = processed.gsub(/<!-- KJ:FUNDING_TIDELIFT:(?:START|END) -->\n?/, "")
7723
+ processed = apply_markdown_conditional_block(
7724
+ processed,
7725
+ "FUNDING_CLOUDROOM_REFERRAL",
7726
+ keep: cloudroom_referral_enabled?(facts)
7727
+ )
7671
7728
  star_history_enabled = facts.dig(:repository, :star_history, :enabled) == true
7672
7729
  return processed if star_history_enabled
7673
7730
 
@@ -7680,6 +7737,26 @@ module Kettle
7680
7737
  )
7681
7738
  end
7682
7739
 
7740
+ def postprocess_contributing_markdown_content(content, facts)
7741
+ processed = apply_markdown_conditional_block(
7742
+ content.to_s,
7743
+ "FUNDING_CLOUDROOM_REFERRAL",
7744
+ keep: cloudroom_referral_enabled?(facts)
7745
+ )
7746
+ engines = facts.dig(:rubygems, :engines)
7747
+ engines = DEFAULT_ENGINES if engines.nil?
7748
+ engine_list = Array(engines).map(&:to_s)
7749
+ jruby = engine_list.include?("jruby")
7750
+ truffleruby = engine_list.include?("truffleruby")
7751
+ processed = apply_markdown_conditional_block(processed, "CONTRIBUTING_ALT_ENGINES", keep: jruby || truffleruby)
7752
+ if jruby || truffleruby
7753
+ processed = apply_markdown_conditional_block(processed, "CONTRIBUTING_ALT_ENGINES_BOTH", keep: jruby && truffleruby)
7754
+ processed = apply_markdown_conditional_block(processed, "CONTRIBUTING_ALT_ENGINES_JRUBY_ONLY", keep: jruby && !truffleruby)
7755
+ processed = apply_markdown_conditional_block(processed, "CONTRIBUTING_ALT_ENGINES_TRUFFLERUBY_ONLY", keep: !jruby && truffleruby)
7756
+ end
7757
+ processed
7758
+ end
7759
+
7683
7760
  def postprocess_funding_markdown_content(content, facts)
7684
7761
  open_collective_enabled = !facts.dig(:funding, :open_collective_disabled)
7685
7762
  processed = apply_markdown_conditional_block(content, "OPEN_COLLECTIVE", keep: open_collective_enabled)
@@ -7690,6 +7767,11 @@ module Kettle
7690
7767
  keep: funding_platform_enabled?(facts.dig(:funding, :platforms), "tidelift")
7691
7768
  )
7692
7769
  processed = processed.gsub(/<!-- KJ:FUNDING_TIDELIFT:(?:START|END) -->\n?/, "")
7770
+ processed = apply_markdown_conditional_block(
7771
+ processed,
7772
+ "FUNDING_CLOUDROOM_REFERRAL",
7773
+ keep: cloudroom_referral_enabled?(facts)
7774
+ )
7693
7775
  funding_platforms = facts.dig(:funding, :platforms)
7694
7776
  if facts.dig(:funding, :open_collective_disabled)
7695
7777
  processed = remove_readme_badge_and_refs(
@@ -7772,6 +7854,13 @@ module Kettle
7772
7854
  ReadmePostProcessor.delete_markdown_link_definitions(processed, Array(link_labels))
7773
7855
  end
7774
7856
 
7857
+ # A personal referral link is opt-in per project: only a configured
7858
+ # tokens.funding.cloudroom_referral (or KJ_FUNDING_CLOUDROOM_REFERRAL)
7859
+ # renders the block, so downstream users never inherit someone else's link.
7860
+ def cloudroom_referral_enabled?(facts)
7861
+ present_template_token_value?(facts.dig(:funding, :platform_tokens, :cloudroom_referral))
7862
+ end
7863
+
7775
7864
  def apply_markdown_conditional_block(content, name, keep:)
7776
7865
  ensure_runtime_dependencies!
7777
7866
  start_text = "KJ:#{name}:START"
@@ -13761,19 +13850,9 @@ module Kettle
13761
13850
  end
13762
13851
 
13763
13852
  def prune_legacy_kettle_config_keys(content)
13764
- pruned = KETTLE_CONFIG_LEGACY_KEY_PATHS.reduce(content.to_s) do |updated, legacy_key|
13853
+ KETTLE_CONFIG_LEGACY_KEY_PATHS.reduce(content.to_s) do |updated, legacy_key|
13765
13854
  remove_yaml_scalar_path(updated, legacy_key.fetch(:path))
13766
13855
  end
13767
- remove_obsolete_simplecov_keep_destination_config(pruned)
13768
- end
13769
-
13770
- def remove_obsolete_simplecov_keep_destination_config(content)
13771
- config = YAML.safe_load(content.to_s, permitted_classes: [], aliases: true) || {}
13772
- simplecov_config = config.dig("files", ".simplecov")
13773
- return content unless simplecov_config.is_a?(Hash)
13774
- return content unless simplecov_config.keys == ["strategy"] && simplecov_config["strategy"].to_s == "keep_destination"
13775
-
13776
- remove_yaml_mapping_path(content, %w[files .simplecov])
13777
13856
  end
13778
13857
 
13779
13858
  def migrate_readme_logo_config(content)
@@ -15000,29 +15079,12 @@ module Kettle
15000
15079
  return {} unless File.exist?(path)
15001
15080
 
15002
15081
  config = YAML.safe_load_file(path, permitted_classes: [Date], aliases: false) || {}
15003
- config = normalize_kettle_jem_config(config)
15004
15082
  validate_kettle_jem_config!(config)
15005
15083
  config
15006
15084
  rescue Psych::SyntaxError => error
15007
15085
  raise Error, "Invalid #{kettle_jem_config_relative_path(project_root)}: #{error.message}"
15008
15086
  end
15009
15087
 
15010
- def normalize_kettle_jem_config(config)
15011
- return config unless config.is_a?(Hash)
15012
-
15013
- files = config["files"]
15014
- return config unless files.is_a?(Hash)
15015
-
15016
- simplecov_config = files[".simplecov"]
15017
- return config unless simplecov_config.is_a?(Hash)
15018
- return config unless simplecov_config.keys == ["strategy"] && simplecov_config["strategy"].to_s == "keep_destination"
15019
-
15020
- normalized = config.dup
15021
- normalized["files"] = files.dup
15022
- normalized["files"].delete(".simplecov")
15023
- normalized
15024
- end
15025
-
15026
15088
  def kettle_jem_config_path(project_root)
15027
15089
  canonical = File.join(project_root, KETTLE_CONFIG_PATH)
15028
15090
  legacy = File.join(project_root, LEGACY_KETTLE_CONFIG_PATH)
@@ -15575,18 +15637,36 @@ module Kettle
15575
15637
  end
15576
15638
 
15577
15639
  def funding_platform_enabled?(enabled_platforms, platform)
15640
+ # Tidelift is dead post-Sonar acquisition with no URLs to direct people
15641
+ # to, so the platform is never enabled — configs that still set
15642
+ # funding.tidelift get cleanup treatment (badge + block removal) instead
15643
+ # of emission.
15644
+ return false if platform.to_s == "tidelift"
15645
+
15578
15646
  return true unless enabled_platforms.is_a?(Hash)
15579
15647
 
15580
15648
  enabled_platforms.fetch(platform.to_s, true) == true
15581
15649
  end
15582
15650
 
15651
+ # The config template nests funding under `tokens.funding`; a top-level
15652
+ # `funding:` key is the legacy location and is still honored as a fallback.
15653
+ def opencollective_config_setting(config)
15654
+ [["tokens", "funding"], ["funding"]].each do |path|
15655
+ funding = path.reduce(config) { |node, key| node.is_a?(Hash) ? node[key] : nil }
15656
+ next unless funding.is_a?(Hash) && funding.key?("open_collective")
15657
+
15658
+ return {value: funding["open_collective"], source: "config.#{path.join(".")}.open_collective"}
15659
+ end
15660
+ nil
15661
+ end
15662
+
15583
15663
  def opencollective_policy(config, env)
15584
- funding = config["funding"]
15585
- if funding.is_a?(Hash) && funding.key?("open_collective")
15586
- config_value = funding["open_collective"]
15664
+ setting = opencollective_config_setting(config)
15665
+ if setting
15666
+ config_value = setting.fetch(:value)
15587
15667
  return {
15588
15668
  disabled: falsey_config?(config_value),
15589
- source: "config.funding.open_collective",
15669
+ source: setting.fetch(:source),
15590
15670
  value: config_value.to_s
15591
15671
  }
15592
15672
  end
@@ -15641,16 +15721,16 @@ module Kettle
15641
15721
  end
15642
15722
 
15643
15723
  def opencollective_org_config(config)
15644
- funding = config["funding"]
15645
- return unless funding.is_a?(Hash) && funding.key?("open_collective")
15724
+ setting = opencollective_config_setting(config)
15725
+ return unless setting
15646
15726
 
15647
- value = funding["open_collective"]
15727
+ value = setting.fetch(:value)
15648
15728
  return if value == true || falsey_config?(value)
15649
15729
 
15650
15730
  org = value.to_s.strip
15651
15731
  return if org.empty?
15652
15732
 
15653
- {org: org, source: "config.funding.open_collective"}
15733
+ {org: org, source: setting.fetch(:source)}
15654
15734
  end
15655
15735
 
15656
15736
  def opencollective_org_env(env)
@@ -15723,6 +15803,9 @@ module Kettle
15723
15803
  "KJ|CI:OS_MATRIX_ENTRIES" => github_actions_current_os_matrix_entries(facts),
15724
15804
  "KJ|CI:OS_TEST_STEPS" => github_actions_current_os_test_steps(facts),
15725
15805
  "KJ|CI:MACOS_HARDENING_STEP" => github_actions_macos_hardening_step(facts),
15806
+ "KJ|CI:PLATFORMS_OS_MATRIX_ENTRIES" => github_actions_platforms_os_matrix_entries(facts),
15807
+ "KJ|CI:PLATFORMS_OS_TEST_STEPS" => github_actions_platforms_os_test_steps(facts),
15808
+ "KJ|CI:PLATFORMS_MACOS_HARDENING_STEP" => github_actions_platforms_macos_hardening_step(facts),
15726
15809
  "KJ|README:CURRENT_MRI_PLATFORMS" => readme_current_mri_platforms(facts),
15727
15810
  "KJ|RAKE:TOP_LEVEL_DOCS_TASK" => rake_top_level_docs_task_token(facts).rstrip,
15728
15811
  "KJ|GITHUB_ACTIONS:COVERAGE_UPLOAD_STEPS" => github_actions_coverage_steps(disabled_integrations: facts.dig(:integrations, :disabled))
@@ -15781,7 +15864,8 @@ module Kettle
15781
15864
  " gems: [\"kettle-changelog\"],",
15782
15865
  " prefix: \"KETTLE_DEV\",",
15783
15866
  " path_env: \"KETTLE_DEV_DEV\",",
15784
- " root: [\"src\", \"my\", \"kettle-dev\"]",
15867
+ " root: [\"src\", \"my\", \"kettle-dev\"],",
15868
+ " relative_paths: true",
15785
15869
  " )",
15786
15870
  " elsif Gem::Version.new(RUBY_VERSION) >= Gem::Version.new(\"4.0.0\")",
15787
15871
  %( gem "kettle-changelog", #{template_managed_dependency("kettle-changelog").fetch(:requirements).map(&:inspect).join(", ")}),
@@ -16311,17 +16395,26 @@ module Kettle
16311
16395
  configured.map { |user| user.to_s.downcase.strip }.reject(&:empty?).uniq
16312
16396
  end
16313
16397
 
16398
+ GIT_BLAME_FILE_LIMIT = 64
16399
+
16314
16400
  def git_copyright_lines(project_root, machine_users, author_aliases: {})
16315
16401
  files = git_capture(project_root, "ls-files", "-z")
16316
16402
  return [] if files.to_s.empty?
16317
16403
 
16404
+ tracked = files.split("\0").reject(&:empty?)
16318
16405
  author_map = Hash.new { |hash, email| hash[email] = {name: nil, years: [], email: email} }
16319
- files.split("\0").reject(&:empty?).each do |relative_path|
16320
- next unless File.exist?(File.join(project_root, relative_path))
16406
+ if tracked.length <= GIT_BLAME_FILE_LIMIT
16407
+ tracked.each do |relative_path|
16408
+ next unless File.exist?(File.join(project_root, relative_path))
16321
16409
 
16322
- parse_blame_porcelain(git_capture(project_root, "blame", "--porcelain", "--", relative_path), author_map)
16323
- rescue ArgumentError
16324
- next
16410
+ parse_blame_porcelain(git_capture(project_root, "blame", "--porcelain", "--", relative_path), author_map)
16411
+ rescue ArgumentError
16412
+ next
16413
+ end
16414
+ else
16415
+ parse_git_log_copyright(git_capture(project_root, "log", "--format=%an%x1f%ae%x1f%at", "--", "."), author_map)
16416
+ dirty = git_capture(project_root, "status", "--porcelain", "--", ".")
16417
+ author_map[NOT_COMMITTED_EMAIL][:years] << Time.now.utc.year.to_s unless dirty.strip.empty?
16325
16418
  end
16326
16419
  resolve_uncommitted_author!(project_root, author_map)
16327
16420
  consolidated = author_map.values
@@ -16351,6 +16444,18 @@ module Kettle
16351
16444
  output.to_s
16352
16445
  end
16353
16446
 
16447
+ def parse_git_log_copyright(output, author_map)
16448
+ output.to_s.each_line do |raw_line|
16449
+ name, email, timestamp = raw_line.chomp.split("\x1f", 3)
16450
+ next if email.to_s.strip.empty?
16451
+
16452
+ year = timestamp.to_i.positive? ? Time.at(timestamp.to_i).utc.year.to_s : Time.now.utc.year.to_s
16453
+ entry = author_map[email.strip]
16454
+ entry[:name] ||= name.to_s.strip
16455
+ entry[:years] << year
16456
+ end
16457
+ end
16458
+
16354
16459
  def parse_blame_porcelain(output, author_map)
16355
16460
  commit_meta = {}
16356
16461
  current_sha = nil
@@ -16572,7 +16677,8 @@ module Kettle
16572
16677
  kofi: funding_platform_token_value(funding_config, env, :kofi).to_s,
16573
16678
  paypal: funding_platform_token_value(funding_config, env, :paypal).to_s,
16574
16679
  buymeacoffee: funding_platform_token_value(funding_config, env, :buymeacoffee).to_s,
16575
- liberapay: funding_platform_token_value(funding_config, env, :liberapay).to_s
16680
+ liberapay: funding_platform_token_value(funding_config, env, :liberapay).to_s,
16681
+ cloudroom_referral: funding_platform_token_value(funding_config, env, :cloudroom_referral).to_s
16576
16682
  )
16577
16683
  end
16578
16684
 
@@ -16586,7 +16692,8 @@ module Kettle
16586
16692
  "KJ|FUNDING:KOFI" => platform_tokens[:kofi].to_s,
16587
16693
  "KJ|FUNDING:PAYPAL" => platform_tokens[:paypal].to_s,
16588
16694
  "KJ|FUNDING:BUYMEACOFFEE" => platform_tokens[:buymeacoffee].to_s,
16589
- "KJ|FUNDING:LIBERAPAY" => platform_tokens[:liberapay].to_s
16695
+ "KJ|FUNDING:LIBERAPAY" => platform_tokens[:liberapay].to_s,
16696
+ "KJ|FUNDING:CLOUDROOM_REFERRAL" => platform_tokens[:cloudroom_referral].to_s
16590
16697
  }
16591
16698
  end
16592
16699
 
@@ -16850,7 +16957,8 @@ module Kettle
16850
16957
  requirements: #{requirements.slice(*names).inspect},
16851
16958
  prefix: "#{prefix}",
16852
16959
  path_env: "#{dev_env}",
16853
- root: #{root_literal}
16960
+ root: #{root_literal},
16961
+ relative_paths: true
16854
16962
  )
16855
16963
  ensure
16856
16964
  if direct_sibling_templating && !direct_sibling_local
@@ -17039,7 +17147,7 @@ module Kettle
17039
17147
  def main_gemfile_kettle_family_gem(package_name)
17040
17148
  return "" if package_name.to_s == "kettle-family"
17041
17149
 
17042
- %(gem "kettle-family", "~> 1.3", ">= 1.3.57"\n)
17150
+ %(gem "kettle-family", "~> 1.3", ">= 1.3.64"\n)
17043
17151
  end
17044
17152
 
17045
17153
  def main_gemfile_nomono_bootstrap(package_name)
@@ -17052,7 +17160,7 @@ module Kettle
17052
17160
  end
17053
17161
 
17054
17162
  def nomono_gemfile_declaration
17055
- %(gem "nomono", "~> 1.1", ">= 1.1.19", require: false # ruby >= 3.2.0)
17163
+ %(gem "nomono", "~> 1.1", ">= 1.1.22", require: false # ruby >= 3.2.0)
17056
17164
  end
17057
17165
 
17058
17166
  def local_gemfile_nomono_bootstrap(_package_name)
@@ -20210,7 +20318,7 @@ module Kettle
20210
20318
  source_root: root.fetch(:kind),
20211
20319
  source_root_path: root.fetch(:path),
20212
20320
  migration: "simplecov_bootstrap"
20213
- }
20321
+ }.tap { |preference| apply_configured_template_strategy!(preference, template_strategy_config(config, target_path)) }
20214
20322
  end
20215
20323
  end
20216
20324
 
@@ -20341,6 +20449,16 @@ module Kettle
20341
20449
  return {strategy: :merge, preference: :destination, add_template_only_nodes: true} if target_path.to_s == KETTLE_CONFIG_PATH
20342
20450
  return {strategy: :merge, preference: :destination, add_template_only_nodes: true} if target_path.to_s == ".gitignore"
20343
20451
  return {strategy: :accept_template} if target_path.to_s == "CITATION.cff"
20452
+ # Boilerplate/generated Markdown files (policy docs, LICENSE.md, agent
20453
+ # instructions, spec/RuboCop guides) default to accept_template. Section-
20454
+ # level markdown merge keeps destination sections whole, so updates inside
20455
+ # existing headings (e.g. Cloudroom referral, replacing Tidelift in
20456
+ # SECURITY.md, new RUBOCOP.md/CONTRIBUTING.md guidance) are silently
20457
+ # dropped while the new template checksum still gets recorded. Projects
20458
+ # that hand-edit any of these can opt into `strategy: merge` or
20459
+ # `keep_destination` in kettle-jem.yml. README.md, CHANGELOG.md, and
20460
+ # verbatim SPDX license texts stay on `merge`.
20461
+ return {strategy: :accept_template} if ACCEPT_TEMPLATE_DEFAULT_MARKDOWN_PATHS.include?(target_path.to_s)
20344
20462
  return {strategy: :merge, preference: :destination, add_template_only_nodes: true} if target_path.to_s == "Rakefile"
20345
20463
  return {strategy: :accept_template} if version_gem_template_target_path?(target_path)
20346
20464
  return {strategy: :accept_template} if target_path.to_s.start_with?(".github/workflows/")
@@ -20349,6 +20467,19 @@ module Kettle
20349
20467
  nil
20350
20468
  end
20351
20469
 
20470
+ ACCEPT_TEMPLATE_DEFAULT_MARKDOWN_PATHS = %w[
20471
+ AGENTS.md
20472
+ CODE_OF_CONDUCT.md
20473
+ CONTRIBUTING.md
20474
+ FUNDING.md
20475
+ IRP.md
20476
+ LICENSE.md
20477
+ RUBOCOP.md
20478
+ SECURITY.md
20479
+ .github/copilot_instructions.md
20480
+ spec/README.md
20481
+ ].freeze
20482
+
20352
20483
  def version_gem_template_target_path?(target_path)
20353
20484
  target = target_path.to_s
20354
20485
  target.end_with?("/version.rb", "/version.rbs")
@@ -20543,14 +20674,7 @@ module Kettle
20543
20674
  selection_reason: template_source_selection_reason(source_path, template_source_display_path(template_root, selected_source)),
20544
20675
  apply: template_entry_apply?(entry, apply_templates)
20545
20676
  }
20546
- preference[:strategy] = strategy_config.fetch(:strategy).to_s if strategy_config
20547
- if strategy_config
20548
- %i[file_type preference freeze_token method_move_policy max_recursion_depth comment_merge_policy].each do |key|
20549
- preference[key] = strategy_config.fetch(key).to_s if strategy_config.key?(key)
20550
- end
20551
- preference[:add_template_only_nodes] = strategy_config.fetch(:add_template_only_nodes) if strategy_config.key?(:add_template_only_nodes)
20552
- preference[:skip_unresolved_scan] = strategy_config.fetch(:skip_unresolved_scan) if strategy_config.key?(:skip_unresolved_scan)
20553
- end
20677
+ apply_configured_template_strategy!(preference, strategy_config)
20554
20678
  if copy_only_when_missing_template_path?(target_path) && File.exist?(File.join(project_root, target_path))
20555
20679
  preference[:strategy] = "keep_destination"
20556
20680
  preference[:policy] = "copy_only_when_missing"
@@ -20565,6 +20689,21 @@ module Kettle
20565
20689
  preference
20566
20690
  end
20567
20691
 
20692
+ # Copies a resolved `files:`/default strategy onto a template preference.
20693
+ # Shared by configured entries and implicitly added ones (the SimpleCov
20694
+ # bootstrap migration) so neither can bypass the project's config.
20695
+ def apply_configured_template_strategy!(preference, strategy_config)
20696
+ return preference unless strategy_config
20697
+
20698
+ preference[:strategy] = strategy_config.fetch(:strategy).to_s
20699
+ %i[file_type preference freeze_token method_move_policy max_recursion_depth comment_merge_policy].each do |key|
20700
+ preference[key] = strategy_config.fetch(key).to_s if strategy_config.key?(key)
20701
+ end
20702
+ preference[:add_template_only_nodes] = strategy_config.fetch(:add_template_only_nodes) if strategy_config.key?(:add_template_only_nodes)
20703
+ preference[:skip_unresolved_scan] = strategy_config.fetch(:skip_unresolved_scan) if strategy_config.key?(:skip_unresolved_scan)
20704
+ preference
20705
+ end
20706
+
20568
20707
  def skip_packaged_version_gem_entrypoint_template?(project_root, source_path, target_path, config)
20569
20708
  return false unless source_path == "lib/gem/version_gem.rb"
20570
20709
  return true unless version_gem_runtime_compatible?({rubygems: {min_ruby: config.dig("rubygems", "min_ruby")}})
@@ -20614,18 +20753,22 @@ module Kettle
20614
20753
  template_file_strategy_config(config, target_path) || template_preference_only_file_config(config, target_path) || template_pattern_strategy_config(config, target_path)
20615
20754
  end
20616
20755
 
20756
+ # `files:` entries may be nested by path segment (`spec: {spec_helper.rb: ...}`)
20757
+ # or written as one flat key (`spec/spec_helper.rb: ...`); a flat key wins.
20758
+ def template_file_config_entry(files, target_path)
20759
+ path = target_path.to_s.delete_prefix("./")
20760
+ return files[path] if files.key?(path)
20761
+
20762
+ path.split("/").reduce(files) do |memo, part|
20763
+ memo[part] if memo.is_a?(Hash) && memo.key?(part)
20764
+ end
20765
+ end
20766
+
20617
20767
  def template_file_strategy_config(config, target_path)
20618
20768
  files = config["files"]
20619
20769
  return unless files.is_a?(Hash)
20620
20770
 
20621
- current = files
20622
- parts = target_path.to_s.delete_prefix("./").split("/")
20623
- until parts.empty?
20624
- part = parts.shift
20625
- return unless current.is_a?(Hash) && current.key?(part)
20626
-
20627
- current = current[part]
20628
- end
20771
+ current = template_file_config_entry(files, target_path)
20629
20772
  return unless current.is_a?(Hash) && current.key?("strategy")
20630
20773
 
20631
20774
  template_strategy_entry(config, nil, current)
@@ -20635,11 +20778,7 @@ module Kettle
20635
20778
  files = config["files"]
20636
20779
  return unless files.is_a?(Hash)
20637
20780
 
20638
- current = target_path.to_s.delete_prefix("./").split("/").reduce(files) do |memo, part|
20639
- if memo.is_a?(Hash) && memo.key?(part)
20640
- memo[part]
20641
- end
20642
- end
20781
+ current = template_file_config_entry(files, target_path)
20643
20782
  return unless current.is_a?(Hash) && !current.key?("strategy")
20644
20783
  return unless current.keys.any? { |key| %w[preference add_template_only_nodes file_type].include?(key) }
20645
20784
 
@@ -20762,6 +20901,12 @@ module Kettle
20762
20901
  return matrix.empty? || !matrix.fetch(:workflow, true)
20763
20902
  end
20764
20903
 
20904
+ if basename == "platforms"
20905
+ platforms = os_platforms_config(config)
20906
+ platforms = DEFAULT_PLATFORMS if platforms.nil? || platforms.empty?
20907
+ return !platforms.include?("linux") || (platforms - ["linux"]).empty?
20908
+ end
20909
+
20765
20910
  min_ruby = config_test_min_ruby(config)
20766
20911
  workflow_floor = Kettle::Rb::CompatMatrix.workflow_ruby_floor(basename)
20767
20912
  return true if workflow_floor && min_ruby && Gem::Version.new(workflow_floor) < min_ruby
@@ -22020,17 +22165,35 @@ module Kettle
22020
22165
  update_github_actions_pins(updated)
22021
22166
  end
22022
22167
 
22023
- # The current.yml OS matrix entries, generated from the destination's
22024
- # declared CI OS families (facts[:ci][:platforms]). current.yml is
22025
- # strategy: accept_template, so it is replaced wholesale and the matrix
22026
- # must be generated from facts rather than pruned from a destination file
22027
- # (spec slice 1038). Runner labels come from Kettle::Rb::PlatformSupport,
22028
- # and an unknown family raises rather than silently dropping a lane, since
22029
- # a typo'd family would otherwise produce no CI for that platform at all.
22030
- def github_actions_current_os_matrix_entries(facts)
22168
+ def configured_ci_platforms(facts)
22031
22169
  platforms = facts.dig(:ci, :platforms)
22032
- platforms = DEFAULT_PLATFORMS if platforms.nil? || platforms.empty?
22170
+ (platforms.nil? || platforms.empty?) ? DEFAULT_PLATFORMS : platforms
22171
+ end
22172
+
22173
+ def current_workflow_platforms(facts)
22174
+ platforms = configured_ci_platforms(facts)
22175
+ platforms.include?("linux") ? ["linux"] : platforms
22176
+ end
22177
+
22178
+ def platforms_workflow_platforms(facts)
22179
+ platforms = configured_ci_platforms(facts)
22180
+ platforms.include?("linux") ? (platforms - ["linux"]) : []
22181
+ end
22182
+
22183
+ # The current.yml OS matrix entries, generated from the destination's
22184
+ # declared CI OS families (facts[:ci][:platforms]). When linux is declared,
22185
+ # current.yml stays Linux-only so the flagship Current MRI badge is not
22186
+ # poisoned by macOS/Windows runner starvation; non-Linux lanes move to
22187
+ # platforms.yml. Runner labels come from Kettle::Rb::PlatformSupport, and
22188
+ # an unknown family raises rather than silently dropping a lane.
22189
+ def github_actions_current_os_matrix_entries(facts, platforms: current_workflow_platforms(facts))
22033
22190
  exec_cmd = facts.dig(:ci, :exec_cmd).to_s
22191
+ # Validate all declared platforms up front so typos never vanish silently.
22192
+ configured_ci_platforms(facts).each do |platform|
22193
+ next if Kettle::Rb::PlatformSupport.runner_label(platform)
22194
+
22195
+ raise Error, "Unknown CI OS family in platforms config: #{platform.inspect} (expected one of #{Kettle::Rb::PlatformSupport::OS_FAMILIES.join(", ")})"
22196
+ end
22034
22197
 
22035
22198
  platforms.map do |platform|
22036
22199
  label = Kettle::Rb::PlatformSupport.runner_label(platform)
@@ -22047,23 +22210,18 @@ module Kettle
22047
22210
  end.join("\n")
22048
22211
  end
22049
22212
 
22213
+ def github_actions_platforms_os_matrix_entries(facts)
22214
+ github_actions_current_os_matrix_entries(facts, platforms: platforms_workflow_platforms(facts))
22215
+ end
22216
+
22050
22217
  MACOS_CA_HARDENING_SCRIPT = File.expand_path("jem/ci/harden_macos_ca_bundle.sh", __dir__)
22051
22218
  private_constant :MACOS_CA_HARDENING_SCRIPT
22052
22219
 
22053
- # The first step of current.yml's test job when macos is a declared platform:
22054
- # removes the eMudhra-related roots Apple still ships in /etc/ssl/cert.pem
22055
- # (https://github.com/galadran/we-have-a-problem.com/issues/157). The script is
22056
- # inlined, not fetched or run from the repo, because it has to run before the
22057
- # first download, and actions/checkout runs git. Like the Windows guard, the
22058
- # step exists only when its platform is declared, so no dead `if:` is emitted
22059
- # for linux-only or linux+windows destinations. Returns the step plus a blank
22060
- # line, or "" so the token vanishes without leaving a stray line behind. The
22061
- # script is a copy of structuredmerge/structuredmerge
22062
- # workspace-scripts/harden_macos_ca_bundle.sh (tested there against a bundle
22063
- # containing an eMudhra root).
22064
- def github_actions_macos_hardening_step(facts)
22065
- platforms = facts.dig(:ci, :platforms)
22066
- platforms = DEFAULT_PLATFORMS if platforms.nil? || platforms.empty?
22220
+ # The first step of a workflow's test job when macos is in that workflow's
22221
+ # platforms: removes the eMudhra-related roots Apple still ships in
22222
+ # /etc/ssl/cert.pem (https://github.com/galadran/we-have-a-problem.com/issues/157).
22223
+ # Inlined because it must run before actions/checkout runs git.
22224
+ def github_actions_macos_hardening_step(facts, platforms: current_workflow_platforms(facts))
22067
22225
  return "" unless platforms.include?("macos")
22068
22226
 
22069
22227
  header = [
@@ -22079,32 +22237,53 @@ module Kettle
22079
22237
  "#{(header + script).join("\n")}\n\n"
22080
22238
  end
22081
22239
 
22082
- # The current.yml test steps, generated from the same platforms facts. The
22083
- # Windows-only guard and step exist only when windows is declared, so no
22084
- # tautological `if:` survives in a linux+macos destination (spec slice
22085
- # 1038). The Windows step bypasses Appraisal and invokes the destination's
22086
- # own configured test command, resolved to its binstub from
22087
- # facts[:ci][:exec_cmd] -- never a hardcoded binstub of any one repo.
22088
- def github_actions_current_os_test_steps(facts)
22089
- platforms = facts.dig(:ci, :platforms)
22090
- platforms = DEFAULT_PLATFORMS if platforms.nil? || platforms.empty?
22240
+ def github_actions_platforms_macos_hardening_step(facts)
22241
+ github_actions_macos_hardening_step(facts, platforms: platforms_workflow_platforms(facts))
22242
+ end
22243
+
22244
+ # The workflow test steps, generated from the workflow's OS platforms. The
22245
+ # Windows-only guard and step exist only when windows is in that workflow,
22246
+ # so no tautological `if:` survives in a Linux-only or macOS-only workflow.
22247
+ # When soft_fail is true (used by platforms.yml), wraps test execution in
22248
+ # Jitujoshi71/soft-fail so non-Linux failures publish neutral check runs.
22249
+ def github_actions_current_os_test_steps(facts, platforms: current_workflow_platforms(facts), soft_fail: false)
22091
22250
  windows = platforms.include?("windows")
22092
22251
  windows_label = Kettle::Rb::PlatformSupport.runner_label("windows")
22252
+ soft_fail_pin = soft_fail ? github_actions_step_pins.fetch("Jitujoshi71/soft-fail") : nil
22093
22253
 
22094
22254
  lines = [" - name: Tests for ${{ matrix.os }} ${{ matrix.ruby }} via ${{ matrix.exec_cmd }}"]
22095
22255
  lines << %( if: matrix.os != '#{windows_label}') if windows
22096
- lines << " run: bundle exec appraisal ${{ matrix.appraisal }} ${{ matrix.exec_cmd }}"
22256
+ if soft_fail
22257
+ lines << " uses: #{soft_fail_pin}"
22258
+ lines << " with:"
22259
+ lines << " run: bundle exec appraisal ${{ matrix.appraisal }} ${{ matrix.exec_cmd }}"
22260
+ lines << " check-name: Specs ${{ matrix.os }} ${{ matrix.ruby }}@${{ matrix.appraisal }} (soft-fail)"
22261
+ else
22262
+ lines << " run: bundle exec appraisal ${{ matrix.appraisal }} ${{ matrix.exec_cmd }}"
22263
+ end
22097
22264
  return lines.join("\n") unless windows
22098
22265
 
22099
22266
  binstub = github_actions_windows_exec_binstub(facts.dig(:ci, :exec_cmd))
22100
- (lines + [
22267
+ windows_lines = [
22101
22268
  "",
22102
22269
  " - name: Tests for #{windows_label} ${{ matrix.ruby }} via ruby bin/#{binstub}",
22103
22270
  %( if: matrix.os == '#{windows_label}'),
22104
22271
  " env:",
22105
- " BUNDLE_GEMFILE: ${{ github.workspace }}/gemfiles/current.gemfile",
22106
- " run: ruby -rbundler/setup bin/#{binstub}"
22107
- ]).join("\n")
22272
+ " BUNDLE_GEMFILE: ${{ github.workspace }}/gemfiles/current.gemfile"
22273
+ ]
22274
+ if soft_fail
22275
+ windows_lines << " uses: #{soft_fail_pin}"
22276
+ windows_lines << " with:"
22277
+ windows_lines << " run: ruby -rbundler/setup bin/#{binstub}"
22278
+ windows_lines << " check-name: Specs #{windows_label} ${{ matrix.ruby }}@${{ matrix.appraisal }} (soft-fail)"
22279
+ else
22280
+ windows_lines << " run: ruby -rbundler/setup bin/#{binstub}"
22281
+ end
22282
+ (lines + windows_lines).join("\n")
22283
+ end
22284
+
22285
+ def github_actions_platforms_os_test_steps(facts)
22286
+ github_actions_current_os_test_steps(facts, platforms: platforms_workflow_platforms(facts), soft_fail: true)
22108
22287
  end
22109
22288
 
22110
22289
  def github_actions_push_branches_yaml(content, default_branch:, indent: " ")
@@ -22499,7 +22678,7 @@ module Kettle
22499
22678
  "actions/checkout" => "actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1",
22500
22679
  "actions/cache" => "actions/cache@55cc8345863c7cc4c66a329aec7e433d2d1c52a9 # v6.1.0",
22501
22680
  "appraisal-rb/setup-ruby-flash" => "appraisal-rb/setup-ruby-flash@b04c0c9f2e443c909968abc828a0b53e77567cf9 # v2.15",
22502
- "ruby/setup-ruby" => "ruby/setup-ruby@13841a643d859a0b8166ebb0211afbf488121be4 # v1.346.0",
22681
+ "ruby/setup-ruby" => "ruby/setup-ruby@7eaac3fe3108dfb746bef3a3c1a21344d57923c7 # v1.348.0",
22503
22682
  "coverallsapp/github-action" => "coverallsapp/github-action@8d6379e14d29928660c4ba802d8e85393440b329 # v2.3.8",
22504
22683
  "qltysh/qlty-action/coverage" => "qltysh/qlty-action/coverage@56bee2d751c94b7bd8de22f64c9b5f398048e13f # v2.8.1",
22505
22684
  "codecov/codecov-action" => "codecov/codecov-action@303a32d7a59b442fa8d48b6a1cc6825c09c847a5 # v7.1.1",