diff --git a/src/run/config.rs b/src/run/config.rs index cc71fd88..79a10e25 100644 --- a/src/run/config.rs +++ b/src/run/config.rs @@ -50,7 +50,7 @@ impl Config { repository_override: None, working_directory: None, command: "".into(), - mode: RunnerMode::Instrumentation, + mode: RunnerMode::Simulation, instruments: Instruments::test(), perf_unwinding_mode: None, enable_perf: false, @@ -123,7 +123,7 @@ mod tests { repository: None, provider: None, working_directory: None, - mode: RunnerMode::Instrumentation, + mode: RunnerMode::Simulation, instruments: vec![], mongo_uri_env_name: None, message_format: None, @@ -157,7 +157,7 @@ mod tests { repository: Some("owner/repo".into()), provider: Some(RepositoryProvider::GitLab), working_directory: Some("/tmp".into()), - mode: RunnerMode::Instrumentation, + mode: RunnerMode::Simulation, instruments: vec!["mongodb".into()], mongo_uri_env_name: Some("MONGODB_URI".into()), message_format: Some(crate::run::MessageFormat::Json), diff --git a/src/run/mod.rs b/src/run/mod.rs index 4c2fa614..5ac4f66f 100644 --- a/src/run/mod.rs +++ b/src/run/mod.rs @@ -137,7 +137,9 @@ pub struct RunArgs { #[derive(ValueEnum, Clone, Debug, Serialize, PartialEq)] #[serde(rename_all = "lowercase")] pub enum RunnerMode { + #[deprecated(note = "Use `RunnerMode::Simulation` instead")] Instrumentation, + Simulation, Walltime, } @@ -156,7 +158,7 @@ impl RunArgs { repository: None, provider: None, working_directory: None, - mode: RunnerMode::Instrumentation, + mode: RunnerMode::Simulation, instruments: vec![], mongo_uri_env_name: None, message_format: None, @@ -184,6 +186,14 @@ pub async fn run( let provider = run_environment::get_provider(&config)?; let logger = Logger::new(&provider)?; + #[allow(deprecated)] + if config.mode == RunnerMode::Instrumentation { + warn!( + "The 'instrumentation' runner mode is deprecated and will be removed in a future version. \ + Please use 'simulation' instead." + ); + } + if provider.get_run_environment() != RunEnvironment::Local { show_banner(); } diff --git a/src/run/runner/helpers/env.rs b/src/run/runner/helpers/env.rs index 31cc04db..509f8a30 100644 --- a/src/run/runner/helpers/env.rs +++ b/src/run/runner/helpers/env.rs @@ -6,6 +6,16 @@ pub fn get_base_injected_env( mode: RunnerMode, profile_folder: &Path, ) -> HashMap<&'static str, String> { + let runner_mode_internal_env_value = match mode { + // While the runner now deprecates the usage of instrumentation with a message, we + // internally still use instrumentation temporarily to give time to users to upgrade their + // integrations to a version that accepts both instrumentation and simulation. + // TODO: Remove Instrumentation mode completely in the next major release, and set this + // value to simulation instead. + #[allow(deprecated)] + RunnerMode::Instrumentation | RunnerMode::Simulation => "instrumentation", + RunnerMode::Walltime => "walltime", + }; HashMap::from([ ("PYTHONHASHSEED", "0".into()), ( @@ -18,7 +28,10 @@ pub fn get_base_injected_env( ), ("ARCH", ARCH.into()), ("CODSPEED_ENV", "runner".into()), - ("CODSPEED_RUNNER_MODE", mode.to_string()), + ( + "CODSPEED_RUNNER_MODE", + runner_mode_internal_env_value.into(), + ), ( "CODSPEED_PROFILE_FOLDER", profile_folder.to_string_lossy().to_string(), diff --git a/src/run/runner/mod.rs b/src/run/runner/mod.rs index 978493b6..77bff9c0 100644 --- a/src/run/runner/mod.rs +++ b/src/run/runner/mod.rs @@ -21,7 +21,9 @@ use wall_time::executor::WallTimeExecutor; impl Display for RunnerMode { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { match self { + #[allow(deprecated)] RunnerMode::Instrumentation => write!(f, "instrumentation"), + RunnerMode::Simulation => write!(f, "simulation"), RunnerMode::Walltime => write!(f, "walltime"), } } @@ -31,7 +33,8 @@ pub const EXECUTOR_TARGET: &str = "executor"; pub fn get_executor_from_mode(mode: &RunnerMode) -> Box { match mode { - RunnerMode::Instrumentation => Box::new(ValgrindExecutor), + #[allow(deprecated)] + RunnerMode::Instrumentation | RunnerMode::Simulation => Box::new(ValgrindExecutor), RunnerMode::Walltime => Box::new(WallTimeExecutor::new()), } } diff --git a/src/run/runner/tests.rs b/src/run/runner/tests.rs index 5dd895bf..738755a1 100644 --- a/src/run/runner/tests.rs +++ b/src/run/runner/tests.rs @@ -145,9 +145,10 @@ mod valgrind { .await } + #[cfg(test)] fn valgrind_config(command: &str) -> Config { Config { - mode: RunnerMode::Instrumentation, + mode: RunnerMode::Simulation, command: command.to_string(), ..Config::test() } diff --git a/src/run/runner/valgrind/measure.rs b/src/run/runner/valgrind/measure.rs index 509abfbe..7c21291c 100644 --- a/src/run/runner/valgrind/measure.rs +++ b/src/run/runner/valgrind/measure.rs @@ -85,7 +85,7 @@ pub async fn measure( cmd.arg(ARCH).arg("-R"); // Configure the environment cmd.envs(get_base_injected_env( - RunnerMode::Instrumentation, + RunnerMode::Simulation, profile_folder, )) .env("PYTHONMALLOC", "malloc")