Class: Serialbench::Cli::EnvironmentCli
- Defined in:
- lib/serialbench/cli/environment_cli.rb
Overview
Environment management CLI
Instance Method Summary collapse
- #execute(environment_path, benchmark_config_path, result_dir) ⇒ Object
- #new(name, kind, ruby_build_tag) ⇒ Object
- #prepare(environment_config_path) ⇒ Object
Methods inherited from BaseCli
Instance Method Details
#execute(environment_path, benchmark_config_path, result_dir) ⇒ Object
93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 |
# File 'lib/serialbench/cli/environment_cli.rb', line 93 def execute(environment_path, benchmark_config_path, result_dir) benchmark_config = load_benchmark_config(benchmark_config_path) environment_config = load_environment_config(environment_path) say "🚀 Running benchmark '#{benchmark_config_path}' in environment '#{environment_config.name}'...", :green FileUtils.mkdir_p(result_dir) say "Results will be saved to: #{result_dir}", :cyan runner = create_environment_runner(environment_config, environment_path) runner.run_benchmark(benchmark_config, benchmark_config_path, result_dir) say '✅ Benchmark completed successfully!', :green say "Results saved to: #{result_dir}", :cyan rescue StandardError => e say "❌ Benchmark failed: #{e.}", :red exit 1 end |
#new(name, kind, ruby_build_tag) ⇒ Object
32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 |
# File 'lib/serialbench/cli/environment_cli.rb', line 32 def new(name, kind, ruby_build_tag) validate_environment_name!(name) config_path = File.join([:dir], "#{name}.yml") if File.exist?(config_path) say "Environment '#{name}' already exists at #{config_path}", :yellow return unless yes?('Overwrite existing environment? (y/n)') end FileUtils.mkdir_p('config/environments') kind_config = case kind when 'docker' raise unless [:docker_image] && [:dockerfile] Models::EnvironmentConfig.new( name: name, type: kind, ruby_build_tag: ruby_build_tag, docker: Models::DockerEnvConfig.new( image: [:docker_image], dockerfile: [:dockerfile] ), description: "Docker environment for Ruby #{ruby_build_tag} benchmarks" ) when 'asdf' Models::EnvironmentConfig.new( name: name, type: kind, ruby_build_tag: ruby_build_tag, asdf: Models::AsdfEnvConfig.new(auto_install: true), description: "ASDF environment for Ruby #{ruby_build_tag} benchmarks" ) end File.write(config_path, kind_config.to_yaml) say "✅ Created environment template: #{config_path}", :green # Show ruby-build tag suggestion for local environments show_ruby_build_suggestion if kind == 'local' say '' say 'Next steps:', :white say "1. Edit #{config_path} to confirm/change configuration", :cyan say "2. Validate: serialbench environment validate #{config_path}", :cyan say "3. Run benchmark: serialbench benchmark execute #{config_path} config/short.yml", :cyan end |
#prepare(environment_config_path) ⇒ Object
123 124 125 126 127 128 129 130 131 132 133 134 135 136 |
# File 'lib/serialbench/cli/environment_cli.rb', line 123 def prepare(environment_config_path) environment_config = load_environment_config(environment_config_path) say "🔧 Preparing environment '#{environment_config.name}'...", :green runner = create_environment_runner(environment_config, environment_config_path) runner.prepare say '✅ Environment prepared successfully!', :green rescue StandardError => e say "❌ Environment preparation failed: #{e.}", :red say e.backtrace.join("\n"), :red exit 1 end |