diff --git a/src/cli/run/mod.rs b/src/cli/run/mod.rs index e4dc2125..7ae9c0f4 100644 --- a/src/cli/run/mod.rs +++ b/src/cli/run/mod.rs @@ -74,6 +74,7 @@ impl RunArgs { simulation_tool: None, profile_folder: None, skip_upload: false, + skip_polling: false, skip_run: false, skip_setup: false, allow_empty: false, diff --git a/src/cli/shared.rs b/src/cli/shared.rs index 4b266edf..f8066401 100644 --- a/src/cli/shared.rs +++ b/src/cli/shared.rs @@ -75,6 +75,16 @@ pub struct ExecAndRunSharedArgs { )] pub skip_upload: bool, + /// Skips polling for the results after upload. + /// This is useful for local runs where the user doesn't want to wait for the results to be available on the server. + #[arg( + long, + default_value = "false", + hide = true, + env = "CODSPEED_SKIP_POLLING" + )] + pub skip_polling: bool, + /// Used internally to upload the results after running the benchmarks in a sandbox environment /// with no internet access #[arg(long, default_value = "false", hide = true)] diff --git a/src/executor/config.rs b/src/executor/config.rs index ad21f2b5..2a64af51 100644 --- a/src/executor/config.rs +++ b/src/executor/config.rs @@ -45,6 +45,7 @@ pub struct Config { pub profile_folder: Option, pub skip_upload: bool, + pub skip_polling: bool, pub skip_run: bool, pub skip_setup: bool, /// If true, allow execution even when no benchmarks are found @@ -100,6 +101,7 @@ impl Config { simulation_tool: SimulationTool::default(), profile_folder: None, skip_upload: false, + skip_polling: false, skip_run: false, skip_setup: false, allow_empty: false, @@ -139,6 +141,7 @@ impl TryFrom for Config { simulation_tool: args.shared.simulation_tool.unwrap_or_default(), profile_folder: args.shared.profile_folder, skip_upload: args.shared.skip_upload, + skip_polling: args.shared.skip_polling, skip_run: args.shared.skip_run, skip_setup: args.shared.skip_setup, allow_empty: args.shared.allow_empty, @@ -178,6 +181,7 @@ impl Config { simulation_tool: args.shared.simulation_tool.unwrap_or_default(), profile_folder: args.shared.profile_folder, skip_upload: args.shared.skip_upload, + skip_polling: args.shared.skip_polling, skip_run: args.shared.skip_run, skip_setup: args.shared.skip_setup, allow_empty: args.shared.allow_empty, @@ -214,6 +218,7 @@ mod tests { simulation_tool: None, profile_folder: None, skip_upload: false, + skip_polling: false, skip_run: false, skip_setup: false, allow_empty: false, @@ -254,6 +259,7 @@ mod tests { simulation_tool: None, profile_folder: Some("./codspeed.out".into()), skip_upload: true, + skip_polling: true, skip_run: true, skip_setup: true, allow_empty: true, @@ -338,6 +344,7 @@ mod tests { simulation_tool: None, profile_folder: None, skip_upload: false, + skip_polling: false, skip_run: false, skip_setup: false, allow_empty: false, diff --git a/src/executor/execution_context.rs b/src/executor/execution_context.rs index 9d945a88..80ec0946 100644 --- a/src/executor/execution_context.rs +++ b/src/executor/execution_context.rs @@ -31,6 +31,10 @@ impl ExecutionContext { self.provider.get_run_environment() == RunEnvironment::Local } + pub fn should_poll_results(&self) -> bool { + self.is_local() && !self.config.skip_polling + } + pub async fn new( mut config: Config, codspeed_config: &CodSpeedConfig, diff --git a/src/executor/mod.rs b/src/executor/mod.rs index 24bd54d2..90c00eec 100644 --- a/src/executor/mod.rs +++ b/src/executor/mod.rs @@ -150,7 +150,7 @@ where start_group!("Uploading results"); let upload_result = crate::upload::upload(execution_context, executor.name()).await?; - if execution_context.is_local() { + if execution_context.should_poll_results() { poll_results(&upload_result).await?; } end_group!(); diff --git a/src/project_config/merger.rs b/src/project_config/merger.rs index 773bc696..73909940 100644 --- a/src/project_config/merger.rs +++ b/src/project_config/merger.rs @@ -156,6 +156,7 @@ mod tests { simulation_tool: None, profile_folder: None, skip_upload: false, + skip_polling: false, skip_run: false, skip_setup: false, allow_empty: false, @@ -189,6 +190,7 @@ mod tests { simulation_tool: None, profile_folder: None, skip_upload: false, + skip_polling: false, skip_run: false, skip_setup: false, allow_empty: false, @@ -224,6 +226,7 @@ mod tests { simulation_tool: None, profile_folder: None, skip_upload: false, + skip_polling: false, skip_run: false, skip_setup: false, allow_empty: false,