(
args: RunArgs,
api_client: &mut CodSpeedAPIClient,
discovered_config: Option<&DiscoveredProjectConfig>,
setup_cache_dir: Option<&Path>,
)
| 170 | } |
| 171 | |
| 172 | pub 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 { |
nothing calls this directly
no test coverage detected