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
36 changes: 36 additions & 0 deletions Cargo.lock

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

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "codspeed-runner"
version = "3.6.1"
edition = "2021"
edition = "2024"
repository = "https://github.com/CodSpeedHQ/runner"
publish = false

Expand Down Expand Up @@ -61,7 +61,7 @@ procfs = "0.17.0"
[dev-dependencies]
temp-env = { version = "0.3.6", features = ["async_closure"] }
insta = { version = "1.29.0", features = ["json", "redactions"] }

test-with = { version = "0.15", default-features = false, features = [] }

[workspace.metadata.release]
sign-tag = true
Expand Down
2 changes: 1 addition & 1 deletion rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[toolchain]
channel = "1.85.0"
channel = "1.88.0"
components = ["rustfmt", "clippy"]
4 changes: 2 additions & 2 deletions src/app.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@ use crate::{
api_client::CodSpeedAPIClient,
auth,
config::CodSpeedConfig,
local_logger::{init_local_logger, CODSPEED_U8_COLOR_CODE},
local_logger::{CODSPEED_U8_COLOR_CODE, init_local_logger},
prelude::*,
run, setup,
};
use clap::{
builder::{styling, Styles},
Parser, Subcommand,
builder::{Styles, styling},
};

fn create_styles() -> Styles {
Expand Down
2 changes: 1 addition & 1 deletion src/auth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ use std::time::Duration;
use crate::{api_client::CodSpeedAPIClient, config::CodSpeedConfig, prelude::*};
use clap::{Args, Subcommand};
use console::style;
use tokio::time::{sleep, Instant};
use tokio::time::{Instant, sleep};

#[derive(Debug, Args)]
pub struct AuthArgs {
Expand Down
13 changes: 6 additions & 7 deletions src/local_logger.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ use std::{
};

use crate::prelude::*;
use console::{style, Style};
use console::{Style, style};
use indicatif::{ProgressBar, ProgressStyle};
use lazy_static::lazy_static;
use log::Log;
use simplelog::{CombinedLogger, SharedLogger};
use std::io::Write;

use crate::logger::{get_group_event, get_json_event, GroupEvent, JsonEvent};
use crate::logger::{GroupEvent, JsonEvent, get_group_event, get_json_event};

pub const CODSPEED_U8_COLOR_CODE: u8 = 208; // #FF8700

Expand Down Expand Up @@ -68,7 +68,7 @@ impl Log for LocalLogger {
GroupEvent::Start(name) | GroupEvent::StartOpened(name) => {
eprintln!(
"\n{}",
style(format!("►►► {} ", name))
style(format!("►►► {name} "))
.bold()
.color256(CODSPEED_U8_COLOR_CODE)
);
Expand All @@ -78,18 +78,17 @@ impl Log for LocalLogger {
spinner.set_style(
ProgressStyle::with_template(
format!(
" {{spinner:>.{}}} {{wide_msg:.{}.bold}}",
CODSPEED_U8_COLOR_CODE, CODSPEED_U8_COLOR_CODE
" {{spinner:>.{CODSPEED_U8_COLOR_CODE}}} {{wide_msg:.{CODSPEED_U8_COLOR_CODE}.bold}}"
)
.as_str(),
)
.unwrap(),
);
spinner.set_message(format!("{}...", name));
spinner.set_message(format!("{name}..."));
spinner.enable_steady_tick(Duration::from_millis(100));
SPINNER.lock().unwrap().replace(spinner);
} else {
eprintln!("{}...", name);
eprintln!("{name}...");
}
}
GroupEvent::End => {
Expand Down
4 changes: 2 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,12 +35,12 @@ async fn main() {
if log_enabled!(log::Level::Error) {
error!("{} {}", style("Error:").bold().red(), style(cause).red());
} else {
eprintln!("Error: {}", cause);
eprintln!("Error: {cause}");
}
}
if log_enabled!(log::Level::Debug) {
for e in err.chain().skip(1) {
debug!("Caused by: {}", e);
debug!("Caused by: {e}");
}
}
clean_logger();
Expand Down
2 changes: 1 addition & 1 deletion src/prelude.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
pub use crate::{end_group, log_json, start_group, start_opened_group};
#[allow(unused_imports)]
pub use anyhow::{anyhow, bail, ensure, Context, Error, Result};
pub use anyhow::{Context, Error, Result, anyhow, bail, ensure};
pub use itertools::Itertools;
#[allow(unused_imports)]
pub use log::{debug, error, info, trace, warn};
2 changes: 1 addition & 1 deletion src/request_client.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use lazy_static::lazy_static;
use reqwest::ClientBuilder;
use reqwest_middleware::{ClientBuilder as ClientWithMiddlewareBuilder, ClientWithMiddleware};
use reqwest_retry::{policies::ExponentialBackoff, RetryTransientMiddleware};
use reqwest_retry::{RetryTransientMiddleware, policies::ExponentialBackoff};

const UPLOAD_RETRY_COUNT: u32 = 3;

Expand Down
2 changes: 1 addition & 1 deletion src/run/check_system.rs
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ lazy_static! {
/// - Debian 11 x86_64
/// - Debian 12 x86_64
pub fn check_system(system_info: &SystemInfo) -> Result<()> {
debug!("System info: {:#?}", system_info);
debug!("System info: {system_info:#?}");

let system_tuple = (
system_info.os.as_str(),
Expand Down
4 changes: 2 additions & 2 deletions src/run/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ use crate::run::instruments::Instruments;
use std::path::PathBuf;
use url::Url;

use crate::run::run_environment::RepositoryProvider;
use crate::run::RunArgs;
use crate::run::run_environment::RepositoryProvider;

use super::{RunnerMode, UnwindingMode};

Expand Down Expand Up @@ -110,8 +110,8 @@ fn extract_owner_and_repository_from_arg(owner_and_repository: &str) -> Result<(

#[cfg(test)]
mod tests {
use crate::run::instruments::MongoDBConfig;
use crate::run::PerfRunArgs;
use crate::run::instruments::MongoDBConfig;

use super::*;

Expand Down
2 changes: 1 addition & 1 deletion src/run/helpers/download_file.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use std::path::Path;
use url::Url;

pub async fn download_file(url: &Url, path: &Path) -> Result<()> {
debug!("Downloading file: {}", url);
debug!("Downloading file: {url}");
let response = REQUEST_CLIENT
.get(url.clone())
.send()
Expand Down
6 changes: 3 additions & 3 deletions src/run/helpers/format_duration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ fn get_nearest_exponent(val: f64) -> i32 {

fn format_shifted_value(value: f64, fraction_digits: usize) -> String {
if fraction_digits == 0 && value.fract() == 0.0 {
format!("{:.0}", value)
format!("{value:.0}")
} else {
format!("{:.1$}", value, fraction_digits)
format!("{value:.fraction_digits$}")
}
}

Expand All @@ -35,7 +35,7 @@ fn format_duration_to_exponent(val: f64, exponent: i32, fraction_digits: usize)
"{} ns",
format_shifted_value(val * 10f64.powi(9), fraction_digits)
),
_ => format!("{} s", val),
_ => format!("{val} s"),
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/run/helpers/parse_git_remote.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use anyhow::{anyhow, Result};
use anyhow::{Result, anyhow};
use lazy_static::lazy_static;

lazy_static! {
Expand Down
4 changes: 3 additions & 1 deletion src/run/instruments/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,9 @@ impl TryFrom<&RunArgs> for Instruments {
uri_env_name: args.mongo_uri_env_name.clone(),
})
} else if args.mongo_uri_env_name.is_some() {
warn!("The MongoDB instrument is disabled but a MongoDB URI environment variable name was provided, ignoring it");
warn!(
"The MongoDB instrument is disabled but a MongoDB URI environment variable name was provided, ignoring it"
);
None
} else {
None
Expand Down
28 changes: 13 additions & 15 deletions src/run/instruments/mongo_tracer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@ use reqwest::Client;
use tokio::fs;
use url::Url;

use crate::{MONGODB_TRACER_VERSION, run::helpers::get_env_variable};
use crate::{prelude::*, run::helpers::download_file};
use crate::{run::helpers::get_env_variable, MONGODB_TRACER_VERSION};

use super::MongoDBConfig;

Expand Down Expand Up @@ -53,10 +53,7 @@ impl MongoTracer {
pub fn try_from(profile_folder: &Path, mongodb_config: &MongoDBConfig) -> Result<Self> {
let user_input = match &mongodb_config.uri_env_name {
Some(uri_env_name) => {
debug!(
"Retrieving the value of {} to patch the MongoDB URL",
uri_env_name
);
debug!("Retrieving the value of {uri_env_name} to patch the MongoDB URL");
Some(UserInput {
mongo_uri: get_env_variable(uri_env_name.as_str())?,
uri_env_name: uri_env_name.to_string(),
Expand Down Expand Up @@ -98,9 +95,9 @@ impl MongoTracer {
Some(destination_uri) => {
let parsing_error_fn = || {
anyhow!(
"Failed to parse the Mongo URI: {}. Be sure to follow the MongoDB URI format described here: https://www.mongodb.com/docs/manual/reference/connection-string/#connection-string-formats",
destination_uri.as_str()
)
"Failed to parse the Mongo URI: {}. Be sure to follow the MongoDB URI format described here: https://www.mongodb.com/docs/manual/reference/connection-string/#connection-string-formats",
destination_uri.as_str()
)
};

Some(format!(
Expand Down Expand Up @@ -141,14 +138,13 @@ impl MongoTracer {
}
command.envs(envs);

debug!("Start the MongoDB tracer: {:?}", command);
debug!("Start the MongoDB tracer: {command:?}");
if let Some(destination_host_port) = destination_host_port {
debug!(
"Proxy MongoDB from {} to {}",
proxy_host_port, destination_host_port
);
debug!("Proxy MongoDB from {proxy_host_port} to {destination_host_port}");
} else {
info!("No MongoDB URI provided, user will have to provide it dynamically through the CodSpeed integration");
info!(
"No MongoDB URI provided, user will have to provide it dynamically through the CodSpeed integration"
);
}
let mut process = command
.stdout(Stdio::piped())
Expand Down Expand Up @@ -232,7 +228,9 @@ impl MongoTracer {
pub async fn install_mongodb_tracer() -> Result<()> {
debug!("Installing mongodb-tracer");
// TODO: release the tracer and update this url
let installer_url = format!("https://codspeed-public-assets.s3.eu-west-1.amazonaws.com/mongo-tracer/{MONGODB_TRACER_VERSION}/cs-mongo-tracer-installer.sh");
let installer_url = format!(
"https://codspeed-public-assets.s3.eu-west-1.amazonaws.com/mongo-tracer/{MONGODB_TRACER_VERSION}/cs-mongo-tracer-installer.sh"
);
let installer_path = env::temp_dir().join("cs-mongo-tracer-installer.sh");
download_file(
&Url::parse(installer_url.as_str()).unwrap(),
Expand Down
15 changes: 7 additions & 8 deletions src/run/mod.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
use crate::VERSION;
use crate::api_client::CodSpeedAPIClient;
use crate::config::CodSpeedConfig;
use crate::prelude::*;
use crate::run::{config::Config, logger::Logger};
use crate::VERSION;
use check_system::SystemInfo;
use clap::{Args, ValueEnum};
use instruments::mongo_tracer::{install_mongodb_tracer, MongoTracer};
use instruments::mongo_tracer::{MongoTracer, install_mongodb_tracer};
use run_environment::interfaces::{RepositoryProvider, RunEnvironment};
use runner::get_run_data;
use serde::Serialize;
Expand All @@ -30,12 +30,11 @@ fn show_banner() {
/ / / __ \ / __ / \__ \ / __ \ / _ \ / _ \ / __ /
/ /___ / /_/ // /_/ / ___/ // /_/ // __// __// /_/ /
\____/ \____/ \__,_/ /____// .___/ \___/ \___/ \__,_/
https://codspeed.io /_/ runner v{}
"#,
VERSION
https://codspeed.io /_/ runner v{VERSION}
"#
);
println!("{}", banner);
debug!("codspeed v{}", VERSION);
println!("{banner}");
debug!("codspeed v{VERSION}");
}

#[derive(Debug, Copy, Clone, PartialEq, ValueEnum, Default)]
Expand Down Expand Up @@ -187,7 +186,7 @@ pub async fn run(
if provider.get_run_environment() != RunEnvironment::Local {
show_banner();
}
debug!("config: {:#?}", config);
debug!("config: {config:#?}");

if provider.get_run_environment() == RunEnvironment::Local {
if codspeed_config.auth.token.is_none() {
Expand Down
6 changes: 3 additions & 3 deletions src/run/poll_results.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::time::Duration;

use console::style;
use tokio::time::{sleep, Instant};
use tokio::time::{Instant, sleep};

use crate::api_client::{
CodSpeedAPIClient, FetchLocalRunReportResponse, FetchLocalRunReportVars, RunStatus,
Expand Down Expand Up @@ -68,9 +68,9 @@ pub async fn poll_results(
if let Some(impact) = report.impact {
let rounded_impact = (impact * 100.0).round();
let impact_text = if impact > 0.0 {
style(format!("+{}%", rounded_impact)).green().bold()
style(format!("+{rounded_impact}%")).green().bold()
} else {
style(format!("{}%", rounded_impact)).red().bold()
style(format!("{rounded_impact}%")).red().bold()
};

info!(
Expand Down
2 changes: 1 addition & 1 deletion src/run/run_environment/buildkite/logger.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
use crate::{
logger::{get_group_event, get_json_event, GroupEvent},
logger::{GroupEvent, get_group_event, get_json_event},
run::run_environment::logger::should_provider_logger_handle_record,
};
use log::*;
Expand Down
Loading