Skip to content

Commit

Permalink
fix perf CI build (#1095)
Browse files Browse the repository at this point in the history
- fix versioning issue caused by
dependabot/dependabot-core#10542
- add `--dry-run` for local testing
  • Loading branch information
OmarTawfik authored Sep 3, 2024
1 parent 872ef97 commit 74387a6
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 11 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ console = { version = "0.15.8" }
derive-new = { version = "0.6.0" }
env_logger = { version = "0.11.5" }
iai-callgrind = { version = "0.12.3" }
iai-callgrind-runner = { version = "0.12.1" }
iai-callgrind-runner = { version = "0.12.3" }
ignore = { version = "0.4.22" }
indexmap = { version = "2.5.0", features = ["serde"] }
indicatif = { version = "0.17.8", features = ["in_memory"] }
Expand Down
19 changes: 13 additions & 6 deletions crates/infra/cli/src/commands/perf/benchmark/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,9 @@ impl BenchmarkController {
}

fn run_iai_bench(&self, package_name: &str, bench_name: &str) {
let token = if self.dry_run.get() {
let dry_run = self.dry_run.get();

let token = if dry_run {
// Use a dummy test token for dry runs:
// https://github.com/bencherdev/bencher/issues/468
BENCHER_TEST_TOKEN.to_string()
Expand All @@ -62,22 +64,27 @@ impl BenchmarkController {
)
};

let cargo_command = format!("cargo bench --package {package_name} --bench {bench_name}");
let test_runner = format!("cargo bench --package {package_name} --bench {bench_name}");

let testbed = if GitHub::is_running_in_ci() {
"ci"
} else {
"dev"
};

Command::new("bencher")
let mut command = Command::new("bencher")
.arg("run")
.property("--project", "slang")
.property("--adapter", "rust_iai_callgrind")
.property("--testbed", testbed)
.property("--token", token)
.arg(cargo_command)
.run();
.env("BENCHER_API_TOKEN", token);

if dry_run {
command = command.flag("--dry-run");
}

// Has to be the last argument:
command.arg(test_runner).run();

let reports_dir = Path::repo_path("target/iai")
.join(package_name)
Expand Down
9 changes: 5 additions & 4 deletions crates/infra/utils/src/commands/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -216,16 +216,17 @@ impl Display for Command {
fn fmt(&self, formatter: &mut Formatter<'_>) -> std::fmt::Result {
let mut parts = vec![];

for (key, value) in &self.environment {
parts.push(format!("{key}='{value}'"));
}

if let Some(dir) = &self.current_dir {
parts.push("cd".to_owned());
parts.push(dir.strip_repo_root().unwrap().unwrap_str().to_owned());
parts.push("&&".to_owned());
}

for key in self.environment.keys() {
// Note: GitHub CI might not be able to obfuscate all secrets. Let's err on the side of caution:
parts.push(format!("{key}='XXX'"));
}

parts.push(self.name.clone());

for arg in &self.args {
Expand Down

0 comments on commit 74387a6

Please sign in to comment.