MCPcopy Create free account
hub / github.com/CodSpeedHQ/codspeed / run

Function run

src/cli/run/mod.rs:172–279  ·  view source on GitHub ↗
(
    args: RunArgs,
    api_client: &mut CodSpeedAPIClient,
    discovered_config: Option<&DiscoveredProjectConfig>,
    setup_cache_dir: Option<&Path>,
)

Source from the content-addressed store, hash-verified

170}
171
172pub async fn run(
173 args: RunArgs,
174 api_client: &mut CodSpeedAPIClient,
175 discovered_config: Option<&DiscoveredProjectConfig>,
176 setup_cache_dir: Option<&Path>,
177) -> Result<()> {
178 let output_json = args.message_format == Some(MessageFormat::Json);
179 let project_config = discovered_config.map(|d| &d.config);
180 let base_run_id = args.shared.base.clone();
181
182 let run_target = if args.command.is_empty() {
183 // No command provided - check for targets in project config
184 let targets = project_config
185 .and_then(|c| c.benchmarks.as_ref())
186 .filter(|t| !t.is_empty())
187 .ok_or_else(|| {
188 anyhow!("No command provided and no targets defined in codspeed.yaml")
189 })?;
190
191 let default_walltime = project_config
192 .and_then(|c| c.options.as_ref())
193 .and_then(|o| o.walltime.as_ref());
194
195 RunTarget::ConfigTargets {
196 args,
197 targets,
198 default_walltime,
199 }
200 } else {
201 RunTarget::SingleCommand(args)
202 };
203
204 match run_target {
205 RunTarget::SingleCommand(args) => {
206 // SingleCommand: working_directory comes from --working-directory CLI flag only.
207 // Config file's working-directory is NOT used.
208 let command = shell_command_from_args(&args.command);
209 let poll_opts = PollResultsOptions::new(output_json, base_run_id);
210 let config = build_orchestrator_config(
211 args,
212 vec![executor::BenchmarkTarget::Entrypoint {
213 command,
214 name: None,
215 }],
216 poll_opts,
217 )?;
218
219 let orchestrator = executor::Orchestrator::new(config, api_client).await?;
220
221 if !orchestrator.is_local() {
222 super::show_banner();
223 }
224 debug!("config: {:?}", orchestrator.config);
225
226 orchestrator.execute(setup_cache_dir, api_client).await?;
227 }
228
229 RunTarget::ConfigTargets {

Callers

nothing calls this directly

Calls 9

shell_command_from_argsFunction · 0.85
show_bannerFunction · 0.85
build_benchmark_targetsFunction · 0.85
execute_configFunction · 0.85
is_localMethod · 0.80
executeMethod · 0.80
config_dirMethod · 0.80
is_emptyMethod · 0.45

Tested by

no test coverage detected