From 2329d995051d83c5027efc791919000f4329b610 Mon Sep 17 00:00:00 2001 From: Defnull <879658+define-null@users.noreply.github.com> Date: Thu, 24 Sep 2026 12:01:21 +0200 Subject: [PATCH 1/2] Fix the fmt and clippy findings on main Run cargo fmt on collector-utils and router-controller. In pings-collector, drop the signal-handling loop that could only run once (clippy::never_loop, an error) and a redundant closure. Use an array for a router-controller test fixture (clippy::useless_vec). Co-Authored-By: Claude Opus 5.5 (1M context) --- crates/collector-utils/src/storage.rs | 18 ++++++++++-------- crates/pings-collector/src/server.rs | 12 +++++------- crates/router-controller/src/controller.rs | 4 ++-- crates/router-controller/src/messages.rs | 2 +- 4 files changed, 18 insertions(+), 18 deletions(-) diff --git a/crates/collector-utils/src/storage.rs b/crates/collector-utils/src/storage.rs index 929e7c9..6ed60da 100644 --- a/crates/collector-utils/src/storage.rs +++ b/crates/collector-utils/src/storage.rs @@ -7,7 +7,9 @@ use serde::{Deserialize, Serialize}; use serde_repr::{Deserialize_repr, Serialize_repr}; use sqd_messages::signatures::sha3_256; -use sqd_messages::{query_error, query_executed, query_finished, Heartbeat, QueryExecuted, QueryFinished}; +use sqd_messages::{ + query_error, query_executed, query_finished, Heartbeat, QueryExecuted, QueryFinished, +}; use sqd_network_transport::{protocol, PeerId}; use crate::cli::ClickhouseArgs; @@ -378,15 +380,13 @@ pub struct QueryFinishedRow { } impl QueryFinishedRow { - pub fn try_from( - query_finished: QueryFinished, - ) -> Result { + pub fn try_from(query_finished: QueryFinished) -> Result { let QueryFinished { worker_id, query_id, total_time_micros: total_time, worker_signature, - result + result, } = query_finished; let result_hash = match result { Some(query_finished::Result::Ok(ok)) => ok.data_hash, @@ -406,7 +406,6 @@ impl QueryFinishedRow { } } - impl ClickhouseStorage { pub async fn new(args: ClickhouseArgs) -> anyhow::Result { let client = Client::default() @@ -416,7 +415,10 @@ impl ClickhouseStorage { .with_password(args.clickhouse_password); client.query(&LOGS_TABLE_DEFINITION).execute().await?; client.query(&PINGS_TABLE_DEFINITION).execute().await?; - client.query(&PORTAL_LOGS_TABLE_DEFINITION).execute().await?; + client + .query(&PORTAL_LOGS_TABLE_DEFINITION) + .execute() + .await?; Ok(Self(client)) } } @@ -603,7 +605,7 @@ mod tests { let last_stored = storage.get_last_stored().await.unwrap(); assert_eq!(last_stored.get(&worker_id.to_string()), Some(&123456789500)); - let assignment_id = + let assignment_id = "2025-10-12T12:00:45_C1A955A7E13FABEC64DCA7965104FA0CBF98C063A6FCB4473E243348CADFAFAE"; // Check pings storing diff --git a/crates/pings-collector/src/server.rs b/crates/pings-collector/src/server.rs index 714742b..c9f1097 100644 --- a/crates/pings-collector/src/server.rs +++ b/crates/pings-collector/src/server.rs @@ -65,12 +65,10 @@ impl Server { let mut sigint = signal(SignalKind::interrupt())?; let mut sigterm = signal(SignalKind::terminate())?; - loop { - tokio::select! { - _ = sigint.recv() => break, - _ = sigterm.recv() => break, - else => break - } + tokio::select! { + _ = sigint.recv() => {} + _ = sigterm.recv() => {} + else => {} } tracing::info!("Server shutting down"); self.task_manager.await_stop().await; @@ -162,7 +160,7 @@ impl Server { }) .buffered(concurrency_limit) .take_until(cancellation_token.cancelled_owned()) - .filter_map(|x| std::future::ready(x)) + .filter_map(std::future::ready) .collect() .await; diff --git a/crates/router-controller/src/controller.rs b/crates/router-controller/src/controller.rs index 5b26a61..fcf2f48 100644 --- a/crates/router-controller/src/controller.rs +++ b/crates/router-controller/src/controller.rs @@ -10,7 +10,7 @@ use base64::Engine; use rand::prelude::SliceRandom; use serde::{Deserialize, Serialize}; -use super::messages::{Range, RangeSet, WorkerState, DataChunk}; +use super::messages::{DataChunk, Range, RangeSet, WorkerState}; use crate::atom::Atom; @@ -527,7 +527,7 @@ mod tests { .set_datasets((0..2).map(|i| (i.to_string(), i.to_string()))) .build(); - let chunks = vec![ + let chunks = [ vec![ DataChunk::new(0, 0, 10, "".to_string()), DataChunk::new(0, 11, 200, "".to_string()), diff --git a/crates/router-controller/src/messages.rs b/crates/router-controller/src/messages.rs index d625f48..ed15def 100644 --- a/crates/router-controller/src/messages.rs +++ b/crates/router-controller/src/messages.rs @@ -3,7 +3,7 @@ use std::{ ops::{Deref, DerefMut}, }; -pub use sqd_messages::{Range, RangeSet, data_chunk::DataChunk}; +pub use sqd_messages::{data_chunk::DataChunk, Range, RangeSet}; #[derive(serde::Serialize, serde::Deserialize, Default, Debug, Clone, PartialEq, Eq)] pub struct WorkerState { From 4feb3313bdd58c846aff00196f24dde6a65114eb Mon Sep 17 00:00:00 2001 From: Defnull <879658+define-null@users.noreply.github.com> Date: Thu, 24 Sep 2026 12:01:21 +0200 Subject: [PATCH 2/2] Run fmt, clippy and tests in CI Check every pull request and push to main with cargo fmt --check, cargo clippy -D warnings and cargo test on the pinned toolchain. Co-Authored-By: Claude Opus 5.5 (1M context) --- .github/workflows/ci.yml | 42 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 .github/workflows/ci.yml diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..6e5d6a5 --- /dev/null +++ b/.github/workflows/ci.yml @@ -0,0 +1,42 @@ +name: ci +on: + pull_request: + push: + branches: [main] + +permissions: + contents: read + +env: + CARGO_TERM_COLOR: always + +jobs: + fmt: + name: fmt + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + # Installs the toolchain and components pinned in `rust-toolchain`. + - run: rustup toolchain install + - run: cargo fmt --all -- --check + + clippy: + name: clippy + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - run: rustup toolchain install + # sqd-messages compiles its protobuf definitions at build time. + - run: sudo apt-get update && sudo apt-get install -y protobuf-compiler + - uses: Swatinem/rust-cache@v2 + - run: cargo clippy --workspace --all-targets --locked -- -D warnings + + test: + name: test + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - run: rustup toolchain install + - run: sudo apt-get update && sudo apt-get install -y protobuf-compiler + - uses: Swatinem/rust-cache@v2 + - run: cargo test --workspace --locked