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

Function run

src/cli/run/mod.rs:148–255  ·  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

146}
147
148pub async fn run(
149 args: RunArgs,
150 api_client: &mut CodSpeedAPIClient,
151 discovered_config: Option<&DiscoveredProjectConfig>,
152 setup_cache_dir: Option<&Path>,
153) -> Result<()> {
154 let output_json = args.message_format == Some(MessageFormat::Json);
155 let project_config = discovered_config.map(|d| &d.config);
156 let base_run_id = args.shared.base.clone();
157
158 let run_target = if args.command.is_empty() {
159 // No command provided - check for targets in project config
160 let targets = project_config
161 .and_then(|c| c.benchmarks.as_ref())
162 .filter(|t| !t.is_empty())
163 .ok_or_else(|| {
164 anyhow!("No command provided and no targets defined in codspeed.yaml")
165 })?;
166
167 let default_walltime = project_config
168 .and_then(|c| c.options.as_ref())
169 .and_then(|o| o.walltime.as_ref());
170
171 RunTarget::ConfigTargets {
172 args,
173 targets,
174 default_walltime,
175 }
176 } else {
177 RunTarget::SingleCommand(args)
178 };
179
180 match run_target {
181 RunTarget::SingleCommand(args) => {
182 // SingleCommand: working_directory comes from --working-directory CLI flag only.
183 // Config file's working-directory is NOT used.
184 let command = args.command.join(" ");
185 let poll_opts = PollResultsOptions::new(output_json, base_run_id);
186 let config = build_orchestrator_config(
187 args,
188 vec![executor::BenchmarkTarget::Entrypoint {
189 command,
190 name: None,
191 }],
192 poll_opts,
193 )?;
194
195 let orchestrator = executor::Orchestrator::new(config, api_client).await?;
196
197 if !orchestrator.is_local() {
198 super::show_banner();
199 }
200 debug!("config: {:?}", orchestrator.config);
201
202 orchestrator.execute(setup_cache_dir, api_client).await?;
203 }
204
205 RunTarget::ConfigTargets {

Callers

nothing calls this directly

Calls 8

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