MCPcopy Create free account
hub / github.com/CodSpeedHQ/codspeed / run_executor

Function run_executor

src/executor/mod.rs:161–231  ·  view source on GitHub ↗

Run a single executor: setup → run → teardown → persist logs. Does NOT upload.

(
    executor: &mut dyn Executor,
    orchestrator: &Orchestrator,
    execution_context: &ExecutionContext,
    setup_cache_dir: Option<&Path>,
    display_label: Option<&str>,
)

Source from the content-addressed store, hash-verified

159/// Run a single executor: setup → run → teardown → persist logs.
160/// Does NOT upload.
161pub async fn run_executor(
162 executor: &mut dyn Executor,
163 orchestrator: &Orchestrator,
164 execution_context: &ExecutionContext,
165 setup_cache_dir: Option<&Path>,
166 display_label: Option<&str>,
167) -> Result<()> {
168 let run_environment = orchestrator.provider.get_run_environment();
169 match executor.support_level(&orchestrator.system_info) {
170 ExecutorSupport::Unsupported => {
171 bail!(
172 "The {} executor is not supported on {}",
173 executor.name(),
174 orchestrator.system_info.os
175 );
176 }
177 ExecutorSupport::RequiresManualInstallation | ExecutorSupport::FullySupported => {
178 if !execution_context.config.skip_setup {
179 executor
180 .setup(&orchestrator.system_info, setup_cache_dir, &run_environment)
181 .await?;
182 executor.grant_privileges()?;
183 }
184 }
185 }
186
187 if !execution_context.config.skip_setup {
188 // TODO: refactor and move directly in the Instruments struct as a `setup` method
189 if execution_context.config.instruments.is_mongodb_enabled() {
190 install_mongodb_tracer().await?;
191 }
192
193 debug!("Environment ready");
194 }
195
196 if !execution_context.config.skip_run {
197 // TODO: refactor and move directly in the Instruments struct as a `start` method
198 let mongo_tracer =
199 if let Some(mongodb_config) = &execution_context.config.instruments.mongodb {
200 let mut mongo_tracer =
201 MongoTracer::try_from(&execution_context.profile_folder, mongodb_config)?;
202 mongo_tracer.start().await?;
203 Some(mongo_tracer)
204 } else {
205 None
206 };
207
208 let display_guard =
209 display_label.and_then(|label| run_environment.start_command_display(label));
210 let run_result = executor.run(execution_context, &mongo_tracer).await;
211 if let Some(guard) = display_guard {
212 guard.finish_with(run_result.is_ok());
213 }
214 run_result?;
215
216 // TODO: refactor and move directly in the Instruments struct as a `stop` method
217 if let Some(mut mongo_tracer) = mongo_tracer {
218 mongo_tracer.stop().await?;

Callers 1

executeMethod · 0.85

Calls 13

install_mongodb_tracerFunction · 0.85
is_mongodb_enabledMethod · 0.80
start_command_displayMethod · 0.80
finish_withMethod · 0.80
get_run_environmentMethod · 0.45
support_levelMethod · 0.45
setupMethod · 0.45
grant_privilegesMethod · 0.45
startMethod · 0.45
runMethod · 0.45
stopMethod · 0.45

Tested by

no test coverage detected