Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "codspeed-runner"
version = "3.2.2"
version = "3.3.0-beta.5"
edition = "2021"
repository = "https://github.com/CodSpeedHQ/runner"
publish = false
Expand Down
10 changes: 9 additions & 1 deletion src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,22 @@ mod request_client;
mod run;

use console::style;
use lazy_static::lazy_static;
use local_logger::clean_logger;
use prelude::*;

use log::log_enabled;

pub const VERSION: &str = env!("CARGO_PKG_VERSION");
pub const MONGODB_TRACER_VERSION: &str = "cs-mongo-tracer-v0.2.0";
pub const VALGRIND_CODSPEED_VERSION: &str = "3.21.0-0codspeed3";
pub const VALGRIND_CODSPEED_VERSION: &str = "3.24.0-0codspeed";
const VALGRIND_CODSPEED_VERSION_DEB_POST_REV: u32 = 1;
lazy_static! {
pub static ref VALGRIND_CODSPEED_DEB_VERSION: String = format!(
"{}{}",
VALGRIND_CODSPEED_VERSION, VALGRIND_CODSPEED_VERSION_DEB_POST_REV
);
}

#[tokio::main(flavor = "current_thread")]
async fn main() {
Expand Down
4 changes: 2 additions & 2 deletions src/run/check_system.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,12 +98,12 @@ impl SystemInfo {
lazy_static! {
static ref SUPPORTED_SYSTEMS: HashSet<(&'static str, &'static str, &'static str)> = {
HashSet::from([
("ubuntu", "20.04", "x86_64"),
("ubuntu", "22.04", "x86_64"),
("ubuntu", "24.04", "x86_64"),
("ubuntu", "22.04", "aarch64"),
("debian", "11", "x86_64"),
("ubuntu", "24.04", "aarch64"),
("debian", "12", "x86_64"),
("debian", "12", "aarch64"),
])
};
}
Expand Down
40 changes: 24 additions & 16 deletions src/run/runner/valgrind/setup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,11 @@ use std::{
use url::Url;

use super::helpers::download_file::download_file;
use crate::run::{check_system::SystemInfo, config::Config};
use crate::{prelude::*, MONGODB_TRACER_VERSION, VALGRIND_CODSPEED_VERSION};
use crate::{
run::{check_system::SystemInfo, config::Config},
VALGRIND_CODSPEED_DEB_VERSION,
};

/// Run a command with sudo if available
fn run_with_sudo(command_args: &[&str]) -> Result<()> {
Expand Down Expand Up @@ -44,18 +47,18 @@ fn get_codspeed_valgrind_filename(system_info: &SystemInfo) -> Result<String> {
system_info.os_version.as_str(),
system_info.arch.as_str(),
) {
("ubuntu", "20.04", "x86_64") | ("debian", "11", "x86_64") | ("debian", "12", "x86_64") => {
("20.04", "amd64")
}
("ubuntu", "22.04", "x86_64") => ("22.04", "amd64"),
("ubuntu", "22.04", "x86_64") | ("debian", "12", "x86_64") => ("22.04", "amd64"),
("ubuntu", "24.04", "x86_64") => ("24.04", "amd64"),
("ubuntu", "22.04", "aarch64") => ("22.04", "arm64"),
("ubuntu", "22.04", "aarch64") | ("debian", "12", "aarch64") => ("22.04", "arm64"),
("ubuntu", "24.04", "aarch64") => ("24.04", "arm64"),
_ => bail!("Unsupported system"),
};

Ok(format!(
"valgrind_{}_ubuntu-{}_{}.deb",
VALGRIND_CODSPEED_VERSION, version, architecture
VALGRIND_CODSPEED_DEB_VERSION.as_str(),
version,
architecture
))
}

Expand All @@ -74,8 +77,7 @@ fn is_valgrind_installed() -> bool {
}

let version = String::from_utf8_lossy(&version_output.stdout);
// TODO: use only VALGRIND_CODSPEED_VERSION here, the other value is when valgrind has been built locally
version.contains("valgrind-3.21.0.codspeed") || version.contains(VALGRIND_CODSPEED_VERSION)
version.contains(VALGRIND_CODSPEED_VERSION)
} else {
false
}
Expand All @@ -89,14 +91,20 @@ async fn install_valgrind(system_info: &SystemInfo) -> Result<()> {
debug!("Installing valgrind");
let valgrind_deb_url = format!(
"https://github.com/CodSpeedHQ/valgrind-codspeed/releases/download/{}/{}",
VALGRIND_CODSPEED_VERSION,
VALGRIND_CODSPEED_DEB_VERSION.as_str(),
get_codspeed_valgrind_filename(system_info)?
);
let deb_path = env::temp_dir().join("valgrind-codspeed.deb");
download_file(&Url::parse(valgrind_deb_url.as_str()).unwrap(), &deb_path).await?;

run_with_sudo(&["apt-get", "update"])?;
run_with_sudo(&["apt-get", "install", "-y", deb_path.to_str().unwrap()])?;
run_with_sudo(&[
"apt-get",
"install",
"--allow-downgrades",
"-y",
deb_path.to_str().unwrap(),
])?;

Ok(())
}
Expand Down Expand Up @@ -155,7 +163,7 @@ mod tests {
};
assert_snapshot!(
get_codspeed_valgrind_filename(&system_info).unwrap(),
@"valgrind_3.21.0-0codspeed3_ubuntu-22.04_amd64.deb"
@"valgrind_3.24.0-0codspeed1_ubuntu-22.04_amd64.deb"
);
}

Expand All @@ -169,21 +177,21 @@ mod tests {
};
assert_snapshot!(
get_codspeed_valgrind_filename(&system_info).unwrap(),
@"valgrind_3.21.0-0codspeed3_ubuntu-24.04_amd64.deb"
@"valgrind_3.24.0-0codspeed1_ubuntu-24.04_amd64.deb"
);
}

#[test]
fn test_system_info_to_codspeed_valgrind_version_debian() {
let system_info = SystemInfo {
os: "debian".to_string(),
os_version: "11".to_string(),
os_version: "12".to_string(),
arch: "x86_64".to_string(),
..SystemInfo::test()
};
assert_snapshot!(
get_codspeed_valgrind_filename(&system_info).unwrap(),
@"valgrind_3.21.0-0codspeed3_ubuntu-20.04_amd64.deb"
@"valgrind_3.24.0-0codspeed1_ubuntu-22.04_amd64.deb"
);
}

Expand All @@ -197,7 +205,7 @@ mod tests {
};
assert_snapshot!(
get_codspeed_valgrind_filename(&system_info).unwrap(),
@"valgrind_3.21.0-0codspeed3_ubuntu-22.04_arm64.deb"
@"valgrind_3.24.0-0codspeed1_ubuntu-22.04_arm64.deb"
);
}
}
Loading