-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathexecutor.rs
More file actions
50 lines (45 loc) · 1.46 KB
/
executor.rs
File metadata and controls
50 lines (45 loc) · 1.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
use super::helpers::env::BASE_INJECTED_ENV;
use super::interfaces::{ExecutorName, RunData};
use crate::prelude::*;
use crate::run::instruments::mongo_tracer::MongoTracer;
use crate::run::{check_system::SystemInfo, config::Config};
use async_trait::async_trait;
use std::collections::HashMap;
use std::path::Path;
#[async_trait(?Send)]
pub trait Executor {
fn name(&self) -> ExecutorName;
async fn setup(
&self,
config: &Config,
system_info: &SystemInfo,
run_data: &RunData,
) -> Result<()>;
/// Runs the executor
async fn run(
&self,
config: &Config,
system_info: &SystemInfo,
run_data: &RunData,
// TODO: use Instruments instead of directly passing the mongodb tracer
mongo_tracer: &Option<MongoTracer>,
) -> Result<()>;
async fn teardown(
&self,
config: &Config,
system_info: &SystemInfo,
run_data: &RunData,
) -> Result<()>;
/// Gets the base environment for the command
///
/// Later on, we will want to refactor this and create the cmd directly in a trait function
fn get_cmd_base_envs(&self, profile_folder: &Path) -> HashMap<&str, String> {
let mut hashmap = BASE_INJECTED_ENV.clone();
hashmap.insert("CODSPEED_RUNNER_MODE", self.name().to_string());
hashmap.insert(
"CODSPEED_PROFILE_FOLDER",
profile_folder.to_str().unwrap().to_string(),
);
hashmap
}
}