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

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

8 changes: 6 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ serde = { workspace = true }
serde_json = { workspace = true, features = ["preserve_order"] }
url = "2.4.1"
sha256 = "1.4.0"
tokio = { version = "1", features = ["macros", "rt", "signal"] }
tokio = { version = "1", features = ["macros", "rt"] }
tokio-tar = { package = "astral-tokio-tar", version = "0.6.0" }
tokio-util = "0.7.16"
md5 = "0.7.0"
Expand Down Expand Up @@ -132,7 +132,11 @@ lto = "thin"
strip = true

[package.metadata.dist]
targets = ["aarch64-apple-darwin", "aarch64-unknown-linux-musl", "x86_64-unknown-linux-musl"]
targets = [
"aarch64-apple-darwin",
"aarch64-unknown-linux-musl",
"x86_64-unknown-linux-musl",
]
binaries.aarch64-apple-darwin = ["codspeed"]
binaries.aarch64-unknown-linux-musl = ["codspeed"]
binaries.x86_64-unknown-linux-musl = ["codspeed"]
4 changes: 4 additions & 0 deletions crates/runner-shared/src/fifo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,11 @@ const _: () = assert!(
pub enum MarkerType {
SampleStart(u64),
SampleEnd(u64),
// Old name is kept as an alias for backwards compatibility.
#[serde(alias = "BenchmarkStart")]
RoundStart(u64),
// Old name is kept as an alias for backwards compatibility.
#[serde(alias = "BenchmarkEnd")]
RoundEnd(u64),
}

Expand Down
10 changes: 8 additions & 2 deletions src/api_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -385,7 +385,10 @@ impl CodSpeedAPIClient {
.await;
match response {
Ok(data) => Ok(data.session),
Err(err) if err.contains_error_code("UNAUTHENTICATED") => {
Err(err)
if err.contains_error_code("UNAUTHENTICATED")
|| err.contains_error_code("UNAUTHORIZED") =>
{
Err(SessionError::Unauthenticated)
}
Err(err) => Err(SessionError::Other(anyhow!(
Expand Down Expand Up @@ -423,7 +426,10 @@ impl CodSpeedAPIClient {
session: data.session,
repository_overview: data.repository_overview,
}),
Err(err) if err.contains_error_code("UNAUTHENTICATED") => {
Err(err)
if err.contains_error_code("UNAUTHENTICATED")
|| err.contains_error_code("UNAUTHORIZED") =>
{
Err(SessionAndRepositoryOverviewError::Unauthenticated)
}
Err(err) if err.contains_error_code("REPOSITORY_NOT_FOUND") => {
Expand Down
43 changes: 1 addition & 42 deletions src/cli/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,35 +18,14 @@ use crate::{
api_client::CodSpeedAPIClient,
config::CodSpeedConfig,
executor::helpers::command::CommandBuilder,
local_logger::{CODSPEED_U8_COLOR_CODE, IS_TTY, init_local_logger},
local_logger::{CODSPEED_U8_COLOR_CODE, init_local_logger},
prelude::*,
project_config::DiscoveredProjectConfig,
};
use clap::{
Parser, Subcommand,
builder::{Styles, styling},
};
use console::Term;

/// Guard that hides the terminal cursor on creation and restores it on drop.
struct CursorGuard;

impl CursorGuard {
fn new() -> Self {
if *IS_TTY {
let _ = Term::stderr().hide_cursor();
}
Self
}
}

impl Drop for CursorGuard {
fn drop(&mut self) {
if *IS_TTY {
let _ = Term::stderr().show_cursor();
}
}
}

fn create_styles() -> Styles {
styling::Styles::styled()
Expand Down Expand Up @@ -151,26 +130,6 @@ impl InternalCommands {

pub async fn run() -> Result<()> {
let cli = Cli::parse();
// Important: keep this after the Cli::parse() because the function can exit the process by itself, skipping the drop of the CursorGuard
let _cursor_guard = CursorGuard::new();
if *IS_TTY {
// Ctrl+C terminates the process before `CursorGuard::drop` runs,
// so we restore the cursor explicitly, then re-raise SIGINT with
// the default disposition so the parent shell sees the expected
// signal-terminated status.
tokio::spawn(async {
if tokio::signal::ctrl_c().await.is_ok() {
drop(_cursor_guard); // explicitly drop to restore cursor before re-raising
}
// Safety: resetting SIGINT to SIG_DFL and raising it are
// async-signal-safe and have no Rust-level invariants to break.
unsafe {
libc::signal(libc::SIGINT, libc::SIG_DFL);
libc::raise(libc::SIGINT);
}
});
}

let mut api_client = build_api_client(&cli)?;

// Discover project configuration file
Expand Down