()
| 185 | } |
| 186 | |
| 187 | pub async fn run() -> Result<()> { |
| 188 | let cli = Cli::parse(); |
| 189 | |
| 190 | if let Commands::Internal(command) = cli.command { |
| 191 | return run_internal(command); |
| 192 | } |
| 193 | |
| 194 | let codspeed_config = load_config(&cli)?; |
| 195 | let mut api_client = build_api_client(&cli, &codspeed_config); |
| 196 | |
| 197 | // Discover project configuration file |
| 198 | let discovered_config = DiscoveredProjectConfig::discover_and_load( |
| 199 | cli.config.as_deref(), |
| 200 | &std::env::current_dir()?, |
| 201 | )?; |
| 202 | |
| 203 | // In the context of the CI, it is likely that a ~ made its way here without being expanded by the shell |
| 204 | let setup_cache_dir = cli |
| 205 | .setup_cache_dir |
| 206 | .as_ref() |
| 207 | .map(|d| PathBuf::from(shellexpand::tilde(d).as_ref())); |
| 208 | let setup_cache_dir = setup_cache_dir.as_deref(); |
| 209 | |
| 210 | match cli.command { |
| 211 | // These initialize their own logging. |
| 212 | Commands::Run(_) | Commands::Exec(_) => {} |
| 213 | _ => { |
| 214 | init_local_logger()?; |
| 215 | } |
| 216 | } |
| 217 | |
| 218 | match cli.command { |
| 219 | Commands::Run(args) => { |
| 220 | let mut args = *args; |
| 221 | args.shared |
| 222 | .upload_url |
| 223 | .get_or_insert_with(|| codspeed_config.upload_url.clone()); |
| 224 | args.shared.experimental.warn_if_active(); |
| 225 | args.shared.experimental.warn_if_deprecated(); |
| 226 | run::run( |
| 227 | args, |
| 228 | &mut api_client, |
| 229 | discovered_config.as_ref(), |
| 230 | setup_cache_dir, |
| 231 | ) |
| 232 | .await? |
| 233 | } |
| 234 | Commands::Exec(args) => { |
| 235 | let mut args = *args; |
| 236 | args.shared |
| 237 | .upload_url |
| 238 | .get_or_insert_with(|| codspeed_config.upload_url.clone()); |
| 239 | args.shared.experimental.warn_if_active(); |
| 240 | args.shared.experimental.warn_if_deprecated(); |
| 241 | exec::run( |
| 242 | args, |
| 243 | &mut api_client, |
| 244 | discovered_config.as_ref().map(|d| &d.config), |
no test coverage detected