Skip to content

Commit 7cacc30

Browse files
feat: automatically install exec-harness for exec subcommand
1 parent b997fb7 commit 7cacc30

4 files changed

Lines changed: 15 additions & 8 deletions

File tree

crates/exec-harness/src/main.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,10 @@ mod walltime;
1212

1313
#[derive(Parser, Debug)]
1414
#[command(name = "exec-harness")]
15-
#[command(about = "CodSpeed exec harness - wraps commands with performance instrumentation")]
15+
#[command(
16+
version,
17+
about = "CodSpeed exec harness - wraps commands with performance instrumentation"
18+
)]
1619
struct Args {
1720
/// Optional benchmark name (defaults to command filename)
1821
#[arg(long)]

src/exec/mod.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
use crate::api_client::CodSpeedAPIClient;
2+
use crate::binary_installer::ensure_binary_installed;
23
use crate::config::CodSpeedConfig;
34
use crate::executor;
45
use crate::prelude::*;
@@ -10,6 +11,9 @@ mod poll_results;
1011
/// We temporarily force this name for all exec runs
1112
pub const DEFAULT_REPOSITORY_NAME: &str = "local-runs";
1213

14+
pub const EXEC_HARNESS_COMMAND: &str = "exec-harness";
15+
const EXEC_HARNESS_VERSION: &str = "1.0.0";
16+
1317
#[derive(Args, Debug)]
1418
pub struct ExecArgs {
1519
#[command(flatten)]
@@ -31,11 +35,15 @@ pub async fn run(
3135
) -> Result<()> {
3236
let config = crate::executor::Config::try_from(args)?;
3337
let mut execution_context = executor::ExecutionContext::try_from((config, codspeed_config))?;
38+
debug!("config: {:#?}", execution_context.config);
3439
let executor = executor::get_executor_from_mode(
3540
&execution_context.config.mode,
3641
executor::ExecutorCommand::Exec,
3742
);
3843

44+
// Ensure the exec-harness is installed
45+
ensure_binary_installed(EXEC_HARNESS_COMMAND, EXEC_HARNESS_VERSION, None).await?;
46+
3947
let poll_results_fn = |run_id: String| poll_results::poll_results(api_client, run_id);
4048

4149
executor::execute_benchmarks(

src/executor/config.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use crate::exec::DEFAULT_REPOSITORY_NAME;
1+
use crate::exec::{DEFAULT_REPOSITORY_NAME, EXEC_HARNESS_COMMAND};
22
use crate::instruments::Instruments;
33
use crate::prelude::*;
44
use crate::run::{RunArgs, UnwindingMode};
@@ -141,7 +141,7 @@ impl TryFrom<crate::exec::ExecArgs> for Config {
141141
.map_err(|_| anyhow!("Cannot append to upload URL"))?
142142
.push("project");
143143

144-
let wrapped_command = std::iter::once("exec-harness".to_string())
144+
let wrapped_command = std::iter::once(EXEC_HARNESS_COMMAND.to_owned())
145145
.chain(args.command)
146146
.collect::<Vec<String>>()
147147
.join(" ");

src/executor/memory/executor.rs

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,7 @@ impl MemoryExecutor {
3030
) -> Result<(MemtrackIpcServer, CommandBuilder)> {
3131
// FIXME: We only support native languages for now
3232

33-
// Find memtrack binary - check env variable or use default command name
34-
let memtrack_path = std::env::var("CODSPEED_MEMTRACK_BINARY")
35-
.unwrap_or_else(|_| "codspeed-memtrack".to_string());
36-
37-
let mut cmd_builder = CommandBuilder::new(memtrack_path);
33+
let mut cmd_builder = CommandBuilder::new(MEMTRACK_COMMAND);
3834
cmd_builder.arg("track");
3935
cmd_builder.arg(get_bench_command(&execution_context.config)?);
4036
cmd_builder.arg("--output");

0 commit comments

Comments
 (0)