Class: Polyrun::CLI

Inherits:
Object
  • Object
show all
Includes:
CiShardRunCommand, CiShardRunParse, ConfigCommand, CoverageCommands, DatabaseCommands, DefaultRun, EnvCommands, Help, Helpers, HooksCommand, InitCommand, PartitionDiagnostics, PlanCommand, PrepareCommand, QueueCommand, QuickCommand, ReportCommands, RunQueueCommand, RunShardsCommand, SpecQualityCommands, TimingCommand
Defined in:
lib/polyrun/cli.rb,
lib/polyrun/cli/help.rb,
lib/polyrun/cli/helpers.rb,
lib/polyrun/cli/default_run.rb,
lib/polyrun/cli/env_commands.rb,
lib/polyrun/cli/init_command.rb,
lib/polyrun/cli/plan_command.rb,
lib/polyrun/cli/hooks_command.rb,
lib/polyrun/cli/queue_command.rb,
lib/polyrun/cli/quick_command.rb,
lib/polyrun/cli/ci_shard_hooks.rb,
lib/polyrun/cli/config_command.rb,
lib/polyrun/cli/prepare_recipe.rb,
lib/polyrun/cli/run_shards_run.rb,
lib/polyrun/cli/timing_command.rb,
lib/polyrun/cli/prepare_command.rb,
lib/polyrun/cli/report_commands.rb,
lib/polyrun/cli/start_bootstrap.rb,
lib/polyrun/cli/failure_commands.rb,
lib/polyrun/cli/coverage_commands.rb,
lib/polyrun/cli/coverage_merge_io.rb,
lib/polyrun/cli/database_commands.rb,
lib/polyrun/cli/run_queue_command.rb,
lib/polyrun/cli/ci_shard_run_parse.rb,
lib/polyrun/cli/run_shards_command.rb,
lib/polyrun/cli/run_shards_planning.rb,
lib/polyrun/cli/ci_shard_run_command.rb,
lib/polyrun/cli/partition_diagnostics.rb,
lib/polyrun/cli/spec_quality_commands.rb,
lib/polyrun/cli/run_shards_plan_options.rb,
lib/polyrun/cli/run_shards_parallel_wait.rb,
lib/polyrun/cli/run_shards_plan_boot_phases.rb,
lib/polyrun/cli/run_shards_worker_interrupt.rb,
lib/polyrun/cli/run_shards_parallel_children.rb,
sig/polyrun/cli.rbs

Defined Under Namespace

Modules: CiShardHooks, CiShardRunCommand, CiShardRunParse, ConfigCommand, CoverageCommands, CoverageMergeIo, DatabaseCommands, DefaultRun, EnvCommands, FailureCommands, Help, Helpers, HooksCommand, InitCommand, PartitionDiagnostics, PlanCommand, PrepareCommand, PrepareRecipe, QueueCommand, QuickCommand, ReportCommands, RunQueueCommand, RunShardsCommand, RunShardsParallelChildren, RunShardsParallelWait, RunShardsPlanBootPhases, RunShardsPlanOptions, RunShardsPlanning, RunShardsRun, RunShardsWorkerInterrupt, SpecQualityCommands, StartBootstrap, TimingCommand

Constant Summary collapse

CI_SHARD_COMMANDS =
{
  "ci-shard-run" => :cmd_ci_shard_run,
  "ci-shard-rspec" => :cmd_ci_shard_rspec
}.freeze
DISPATCH_SUBCOMMAND_NAMES =

Keep in sync with dispatch_cli_command_subcommands (+when+ branches). Used for implicit path routing.

%w[
  plan prepare merge-coverage merge-failures merge-spec-quality report-coverage report-junit report-timing report-spec-quality
  env config merge-timing db:setup-template db:setup-shard db:clone-shards
  run-shards parallel-rspec start build-paths init queue run-queue quick hook
].freeze
IMPLICIT_PATH_EXCLUSION_TOKENS =

First argv token that is a normal subcommand (not a path); if argv is not here but looks like paths, run implicit parallel.

(
  DISPATCH_SUBCOMMAND_NAMES + CI_SHARD_COMMANDS.keys + %w[help version]
).freeze

Constants included from InitCommand

InitCommand::INIT_PROFILES

Constants included from RunShardsParallelWait

RunShardsParallelWait::WORKER_IDLE_TIMEOUT_EXIT_STATUS, RunShardsParallelWait::WORKER_TIMEOUT_EXIT_STATUS

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Help

#print_help

Class Method Details

.run(argv = ARGV) ⇒ Integer

Parameters:

  • argv (::Array[String]) (defaults to: ARGV)

Returns:

  • (Integer)


67
68
69
# File 'lib/polyrun/cli.rb', line 67

def self.run(argv = ARGV)
  new.run(argv)
end

Instance Method Details

#run(argv) ⇒ Integer

Parameters:

  • argv (::Array[String])

Returns:

  • (Integer)


71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
# File 'lib/polyrun/cli.rb', line 71

def run(argv)
  argv = argv.dup
  config_path = parse_global_cli!(argv)
  return config_path if config_path.is_a?(Integer)

  if argv.empty?
    Polyrun::Debug.log_kv(
      command: "(default)",
      cwd: Dir.pwd,
      polyrun_config: config_path,
      argv_rest: [],
      verbose: @verbose
    )
    return dispatch_default_parallel!(config_path)
  end

  if implicit_parallel_run?(argv)
    Polyrun::Debug.log_kv(
      command: "(paths)",
      cwd: Dir.pwd,
      polyrun_config: config_path,
      argv_rest: argv.dup,
      verbose: @verbose
    )
    return dispatch_implicit_parallel_targets!(argv, config_path)
  end

  command = argv.shift

  Polyrun::Debug.log_kv(
    command: command,
    cwd: Dir.pwd,
    polyrun_config: config_path,
    argv_rest: argv.dup,
    verbose: @verbose
  )

  dispatch_cli_command(command, argv, config_path)
end