From ee18381912fa790eed9d0a906eb26c7d7828a84e Mon Sep 17 00:00:00 2001 From: Adrien Cacciaguerra Date: Wed, 24 Jul 2024 16:08:42 +0000 Subject: [PATCH 1/3] feat: bump rust toolchain --- rust-toolchain.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/rust-toolchain.toml b/rust-toolchain.toml index b44c3df..8749391 100644 --- a/rust-toolchain.toml +++ b/rust-toolchain.toml @@ -1,3 +1,3 @@ [toolchain] -channel = "1.73.0" +channel = "1.79.0" components = ["rustfmt", "clippy"] From 7c19915131df2ac556f2da770b8c04c65fc3384f Mon Sep 17 00:00:00 2001 From: Adrien Cacciaguerra Date: Wed, 24 Jul 2024 16:22:41 +0000 Subject: [PATCH 2/3] chore(clippy): allow some prelude unused imports --- src/prelude.rs | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/prelude.rs b/src/prelude.rs index 9ba08e1..aa0cf4d 100644 --- a/src/prelude.rs +++ b/src/prelude.rs @@ -1,4 +1,6 @@ pub use crate::{end_group, start_group, start_opened_group}; +#[allow(unused_imports)] pub use anyhow::{anyhow, bail, ensure, Context, Error, Result}; pub use itertools::Itertools; +#[allow(unused_imports)] pub use log::{debug, error, info, trace, warn}; From 9d674c850b8bd480a98c8a6fabacb659c57d50dc Mon Sep 17 00:00:00 2001 From: Adrien Cacciaguerra Date: Thu, 25 Jul 2024 14:12:24 +0000 Subject: [PATCH 3/3] refactor(runner): do not create system info inside check_system --- src/run/check_system.rs | 9 ++++----- src/run/mod.rs | 5 ++++- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/run/check_system.rs b/src/run/check_system.rs index ffd182b..416c00d 100644 --- a/src/run/check_system.rs +++ b/src/run/check_system.rs @@ -41,7 +41,7 @@ impl SystemInfo { } impl SystemInfo { - fn new() -> Result { + pub fn new() -> Result { let os = System::name().ok_or(anyhow!("Failed to get OS name"))?; let os_version = System::os_version().ok_or(anyhow!("Failed to get OS version"))?; let arch = System::cpu_arch().ok_or(anyhow!("Failed to get CPU architecture"))?; @@ -58,15 +58,14 @@ impl SystemInfo { } } -/// Checks if the system is supported and returns the system info +/// Checks if the provided system info is supported /// /// Supported systems: /// - Ubuntu 20.04 on x86_64 /// - Ubuntu 22.04 on x86_64 /// - Debian 11 on x86_64 /// - Debian 12 on x86_64 -pub fn check_system() -> Result { - let system_info = SystemInfo::new()?; +pub fn check_system(system_info: &SystemInfo) -> Result<()> { debug!("System info: {:#?}", system_info); match (system_info.os.as_str(), system_info.os_version.as_str()) { @@ -79,5 +78,5 @@ pub fn check_system() -> Result { bail!("Only x86_64 is supported at the moment"); } - Ok(system_info) + Ok(()) } diff --git a/src/run/mod.rs b/src/run/mod.rs index b1b03aa..7324667 100644 --- a/src/run/mod.rs +++ b/src/run/mod.rs @@ -3,6 +3,7 @@ use crate::config::CodSpeedConfig; use crate::prelude::*; use crate::run::{config::Config, logger::Logger}; use crate::VERSION; +use check_system::SystemInfo; use clap::Args; mod check_system; @@ -110,7 +111,9 @@ pub async fn run(args: RunArgs, api_client: &CodSpeedAPIClient) -> Result<()> { config.set_token(codspeed_config.auth.token.clone()); } - let system_info = check_system::check_system()?; + let system_info = SystemInfo::new()?; + check_system::check_system(&system_info)?; + let run_data = runner::run(&config, &system_info).await?; if !config.skip_upload {