Class: Kettle::Family::Workflow

Inherits:
Object
  • Object
show all
Defined in:
lib/kettle/family/workflow.rb

Constant Summary collapse

DEFAULT_COMMANDS =
{
  "template" => "bundle exec kettle-jem install",
  "test" => "bundle exec kettle-test",
  "lint" => "bundle exec rake rubocop_gradual",
  "docs" => "bundle exec rake yard",
  "gha-sha-pins" => "bundle exec kettle-gha-sha-pins",
  "sync" => [
    "sh",
    "-lc",
    <<~SH
      set -e
      current_branch=$(git branch --show-current)
      if [ -z "$current_branch" ]; then
        echo "kettle-family sync requires a named branch checkout" >&2
        exit 1
      fi
      default_ref=$(git symbolic-ref --quiet --short refs/remotes/origin/HEAD 2>/dev/null || true)
      default_branch=${default_ref#origin/}
      if [ -z "$default_branch" ] || [ "$default_branch" = "$default_ref" ]; then
        default_branch=$(git remote show origin | awk '/HEAD branch:/ { print $NF; exit }')
      fi
      if [ -z "$default_branch" ]; then
        echo "could not determine origin default branch" >&2
        exit 1
      fi
      git fetch origin "$default_branch"
      if [ "$current_branch" != "$default_branch" ]; then
        git switch "$default_branch"
      fi
      git rebase "origin/$default_branch"
      if [ "$current_branch" != "$default_branch" ]; then
        git switch "$current_branch"
        git rebase "$default_branch"
      fi
    SH
  ],
  "bupb" => %w[bundle update --bundler]
}.freeze
PRE_TEMPLATE_BOOTSTRAP_GEMS =
%w[nomono kettle-dev].freeze
GIT_SYNC_COMMANDS =
{
  "push" => [["push", %w[git push]]],
  "pull" => [["pull", %w[git pull --rebase]]],
  "up" => [["pull", %w[git pull --rebase]], ["push", %w[git push]]]
}.freeze
TEMPLATE_QUIET_ENV =
{
  "KETTLE_JEM_QUIET" => "true",
  "KETTLE_JEM_DEBUG" => "false",
  "KETTLE_DEV_DEBUG" => "false",
  "STRUCTUREDMERGE_DEBUG" => "false",
  "DEBUG" => nil,
  "BUNDLE_QUIET" => "true",
  "BUNDLE_DEBUG" => "false",
  "BUNDLER_DEBUG" => "false",
  "BUNDLE_VERBOSE" => "false",
  "DEBUG_RESOLVER" => nil,
  "DEBUG_RESOLVER_TREE" => nil,
  "BUNDLER_DEBUG_RESOLVER" => nil,
  "BUNDLER_DEBUG_RESOLVER_TREE" => nil,
  "DEBUG_COMPACT_INDEX" => nil,
  "MOLINILLO_DEBUG" => nil,
  "BUNDLE_SILENCE_DEPRECATIONS" => "true",
  "BUNDLE_SILENCE_ROOT_WARNING" => "true",
  "BUNDLE_SUPPRESS_INSTALL_USING_MESSAGES" => "true"
}.freeze
RESET_LOCKFILE_HELPER =
<<~RUBY
  require "bundler/inline"

  source_url = ENV.fetch("KETTLE_FAMILY_RESET_GEM_SOURCE", "https://gem.coop")
  kettle_dev_version = ENV["KETTLE_FAMILY_RESET_KETTLE_DEV_VERSION"].to_s

  gemfile(true) do
    source source_url
    if kettle_dev_version.empty?
      gem "kettle-dev"
    else
      gem "kettle-dev", kettle_dev_version
    end
  end

  load Gem.bin_path("kettle-dev", "kettle-reset")
RUBY
REGISTRY_WAIT_ATTEMPTS =
15
REGISTRY_WAIT_INTERVAL_SECONDS =
15

Instance Method Summary collapse

Constructor Details

#initialize(command:, config:, members:, execute: false, accept: true, commit: true, allow_dirty: false, publish: false, push: false, tag: false, start_step: nil, skip_steps: nil, local_ci: false, continue_ci_failures: false, ci_workflows: nil, skip_bundle_audit: false, skip_remotes: nil, auto_dependency_floors: nil, gha_sha_pins_upgrade: "patch", gha_sha_pins_check: false, env_overrides: {}, debug: false, verbose: false, gem_signing_password: nil, secrets_provider: nil, jobs: nil, progress_io: nil, reset_target: nil, bup_args: [], bex_args: [], start_member: nil, start_branch: nil, **options) ⇒ Workflow

Returns a new instance of Workflow.



103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
# File 'lib/kettle/family/workflow.rb', line 103

def initialize(command:, config:, members:, execute: false, accept: true, commit: true, allow_dirty: false, publish: false, push: false, tag: false, start_step: nil, skip_steps: nil, local_ci: false, continue_ci_failures: false, ci_workflows: nil, skip_bundle_audit: false, skip_remotes: nil, auto_dependency_floors: nil, gha_sha_pins_upgrade: "patch", gha_sha_pins_check: false, env_overrides: {}, debug: false, verbose: false, gem_signing_password: nil, secrets_provider: nil, jobs: nil, progress_io: nil, reset_target: nil, bup_args: [], bex_args: [], start_member: nil, start_branch: nil, **options)
  @command = command
  @config = config
  @members = members
  @execute = execute
  @accept = accept
  @commit = commit
  @allow_dirty = allow_dirty
  @publish = publish
  @push = push
  @tag = tag
  @start_step = start_step
  @skip_steps = skip_steps
  @local_ci = local_ci
  @continue_ci_failures = continue_ci_failures
  @ci_workflows = validate_ci_workflows(ci_workflows)
  @skip_bundle_audit = skip_bundle_audit
  @skip_remotes = validate_skip_remotes(skip_remotes)
  @auto_dependency_floors = auto_dependency_floors.nil? ? config.release_auto_dependency_floors? : auto_dependency_floors
  @gha_sha_pins_upgrade = gha_sha_pins_upgrade
  @gha_sha_pins_check = gha_sha_pins_check
  @env_overrides = env_overrides
  @debug = debug
  @verbose = verbose
  @gem_signing_password = gem_signing_password
  @secrets_provider = secrets_provider || Secrets::Provider.new
  @jobs = jobs
  @progress_io = progress_io
  @reset_target = reset_target
  @bup_args = bup_args
  @bex_args = bex_args
  @start_member = start_member
  @start_branch = start_branch
  @template_commit_mutex = Mutex.new
end

Instance Method Details

#resultsObject



139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
# File 'lib/kettle/family/workflow.rb', line 139

def results
  if command == "release" && execute
    release_preflight = release_preflight_results
    return release_preflight unless release_preflight.empty?

    return branch_target_results unless config.release_target_branches.empty?
    return member_local_branch_target_results if member_local_branch_targets?

    return current_branch_results(members)
  end

  preflight = branch_checkout_dirty_preflight_results
  return preflight unless preflight.empty?

  prompt_for_gem_signing_password if command == "release" && execute && release_signing_prompt_required?
  return branch_target_results unless config.release_target_branches.empty?
  return member_local_branch_target_results if member_local_branch_targets?

  current_branch_results(members)
end