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