From f9727428647460e32b9945d07717b45b9818c352 Mon Sep 17 00:00:00 2001 From: Defnull <879658+define-null@users.noreply.github.com> Date: Wed, 18 Feb 2026 10:48:26 +0100 Subject: [PATCH 1/6] Add tests/fmt/clippy --- .github/workflows/tests.yaml | 47 +++++++++++++++++++++++++++++++++ Cargo.lock | 8 +++--- Cargo.toml | 9 ++++--- src/cli.rs | 2 +- src/controller/p2p.rs | 5 +--- src/controller/polars_target.rs | 2 +- src/controller/worker.rs | 2 +- src/main.rs | 11 ++++++++ 8 files changed, 71 insertions(+), 15 deletions(-) create mode 100644 .github/workflows/tests.yaml diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml new file mode 100644 index 0000000..fce9aa5 --- /dev/null +++ b/.github/workflows/tests.yaml @@ -0,0 +1,47 @@ +name: Rust Tests + +on: + push: + pull_request: + types: [opened, synchronize, reopened, ready_for_review] + workflow_dispatch: + +env: + CARGO_TERM_COLOR: always + +concurrency: + group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.ref }} + cancel-in-progress: ${{ github.event_name == 'pull_request' }} + +jobs: + test: + name: Test + runs-on: ubuntu-latest + if: github.event_name == 'push' || !github.event.pull_request.draft + steps: + - uses: actions/checkout@v4 + with: + lfs: true + - uses: dsherret/rust-toolchain-file@v1 + - uses: Swatinem/rust-cache@v2 + - name: Run tests + run: cargo test --all-features --verbose + + fmt: + name: Rustfmt + runs-on: ubuntu-latest + if: github.event_name == 'push' || !github.event.pull_request.draft + steps: + - uses: actions/checkout@v4 + - uses: dsherret/rust-toolchain-file@v1 + - run: cargo fmt --all -- --check + + clippy: + name: Clippy + runs-on: ubuntu-latest + if: github.event_name == 'push' || !github.event.pull_request.draft + steps: + - uses: actions/checkout@v4 + - uses: dsherret/rust-toolchain-file@v1 + - uses: Swatinem/rust-cache@v2 + - run: cargo clippy --all-targets --all-features -- -D clippy::correctness -D clippy::suspicious diff --git a/Cargo.lock b/Cargo.lock index 1581383..19577d5 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -7216,7 +7216,7 @@ dependencies = [ [[package]] name = "sqd-assignments" version = "0.1.0" -source = "git+https://github.com/subsquid/sqd-network.git?rev=32b959b#32b959bc85f548840f3d4d93852e633af32c61a6" +source = "git+https://github.com/subsquid/sqd-network.git?rev=020e5e9#020e5e9da5b05101c956cba79a57bcc6760266f1" dependencies = [ "anyhow", "crypto_box", @@ -7240,7 +7240,7 @@ dependencies = [ [[package]] name = "sqd-contract-client" version = "1.2.1" -source = "git+https://github.com/subsquid/sqd-network.git?rev=32b959b#32b959bc85f548840f3d4d93852e633af32c61a6" +source = "git+https://github.com/subsquid/sqd-network.git?rev=020e5e9#020e5e9da5b05101c956cba79a57bcc6760266f1" dependencies = [ "async-trait", "clap", @@ -7260,7 +7260,7 @@ dependencies = [ [[package]] name = "sqd-messages" version = "2.1.0" -source = "git+https://github.com/subsquid/sqd-network.git?rev=32b959b#32b959bc85f548840f3d4d93852e633af32c61a6" +source = "git+https://github.com/subsquid/sqd-network.git?rev=020e5e9#020e5e9da5b05101c956cba79a57bcc6760266f1" dependencies = [ "bytemuck", "flate2", @@ -7276,7 +7276,7 @@ dependencies = [ [[package]] name = "sqd-network-transport" version = "3.0.0" -source = "git+https://github.com/subsquid/sqd-network.git?rev=32b959b#32b959bc85f548840f3d4d93852e633af32c61a6" +source = "git+https://github.com/subsquid/sqd-network.git?rev=020e5e9#020e5e9da5b05101c956cba79a57bcc6760266f1" dependencies = [ "anyhow", "async-trait", diff --git a/Cargo.toml b/Cargo.toml index 0fd8c67..92f8d91 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -57,10 +57,11 @@ url = "2.5.2" walkdir = "2.5.0" zstd = "0.13" -sqd-assignments = { git = "https://github.com/subsquid/sqd-network.git", rev = "32b959b", features = ["reader"] } -sqd-contract-client = { git = "https://github.com/subsquid/sqd-network.git", rev = "32b959b", version = "1.2.1" } -sqd-messages = { git = "https://github.com/subsquid/sqd-network.git", rev = "32b959b", version = "2.0.2", features = ["bitstring"] } -sqd-network-transport = { git = "https://github.com/subsquid/sqd-network.git", rev = "32b959b", version = "3.0.0", features = ["worker", "metrics"] } +sqd-assignments = { git = "https://github.com/subsquid/sqd-network.git", rev = "020e5e9", features = ["reader"] } +sqd-contract-client = { git = "https://github.com/subsquid/sqd-network.git", rev = "020e5e9", version = "1.2.1" } +sqd-messages = { git = "https://github.com/subsquid/sqd-network.git", rev = "020e5e9", version = "2.0.2", features = ["bitstring"] } +sqd-network-transport = { git = "https://github.com/subsquid/sqd-network.git", rev = "020e5e9", version = "3.0.0", features = ["worker", "metrics"] } + sqd-query = { git = "https://github.com/subsquid/data.git", rev = "4c089d8", features = ["parquet"] } sqd-polars = { git = "https://github.com/subsquid/data.git", rev = "4c089d8" } sql_query_plan = {git = "https://github.com/subsquid/qplan.git", rev = "658f88f" } diff --git a/src/cli.rs b/src/cli.rs index f3468a9..2b2c415 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -71,7 +71,7 @@ pub struct Args { pub sentry_traces_sample_rate: f32, #[clap(env, hide(true), default_value_t = true)] - pub sentry_is_enabled: bool + pub sentry_is_enabled: bool, } fn parse_seconds(s: &str) -> Result { diff --git a/src/controller/p2p.rs b/src/controller/p2p.rs index f8f7937..aa213f2 100644 --- a/src/controller/p2p.rs +++ b/src/controller/p2p.rs @@ -595,10 +595,7 @@ impl + Send + 'static> P2PController sqd_messages::WorkerStatus { let status = worker.status().await; - let assignment_id = match status.assignment_id { - Some(assignment_id) => assignment_id, - None => String::new(), - }; + let assignment_id = status.assignment_id.unwrap_or_default(); sqd_messages::WorkerStatus { assignment_id, missing_chunks: Some(BitString::new(&status.unavailability_map)), diff --git a/src/controller/polars_target.rs b/src/controller/polars_target.rs index f1522d4..b9bc6b3 100644 --- a/src/controller/polars_target.rs +++ b/src/controller/polars_target.rs @@ -345,7 +345,7 @@ impl ExprTransformer for PolarsExprTransformer { l: &expression::SingularOrList, ) -> Result { let field = match l.value { - Some(ref x) => self.transform_expr(&*x, source, tctx), + Some(ref x) => self.transform_expr(x, source, tctx), None => polars_err("no field in list expression".to_string()), }?; diff --git a/src/controller/worker.rs b/src/controller/worker.rs index 4b8f20c..47ce278 100644 --- a/src/controller/worker.rs +++ b/src/controller/worker.rs @@ -9,9 +9,9 @@ use polars::{ prelude::{JsonFormat, JsonWriter}, }; use prost::Message; -use sql_query_plan::plan; use sqd_assignments::Assignment; use sqd_query::ParquetChunk; +use sql_query_plan::plan; use substrait::proto::Plan; use tokio_util::sync::CancellationToken; diff --git a/src/main.rs b/src/main.rs index 7c7b51d..55ad964 100644 --- a/src/main.rs +++ b/src/main.rs @@ -14,6 +14,17 @@ // You should have received a copy of the GNU Affero General Public License // along with this program. If not, see . +#![warn(clippy::correctness)] +#![warn(clippy::suspicious)] +#![warn(clippy::perf)] +#![warn(clippy::complexity)] + +#![allow(clippy::style)] +#![allow(clippy::pedantic)] +#![allow(clippy::nursery)] + +#![cfg_attr(test, allow(clippy::all))] + use std::borrow::Cow; use std::sync::Arc; From 9db3c7611d5a82d5cd2ea520bf0cfa2ad57e959d Mon Sep 17 00:00:00 2001 From: Defnull <879658+define-null@users.noreply.github.com> Date: Wed, 18 Feb 2026 10:49:50 +0100 Subject: [PATCH 2/6] Fix formatting --- src/controller/p2p.rs | 2 +- src/main.rs | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/src/controller/p2p.rs b/src/controller/p2p.rs index aa213f2..f3a845b 100644 --- a/src/controller/p2p.rs +++ b/src/controller/p2p.rs @@ -595,7 +595,7 @@ impl + Send + 'static> P2PController sqd_messages::WorkerStatus { let status = worker.status().await; - let assignment_id = status.assignment_id.unwrap_or_default(); + let assignment_id = status.assignment_id.unwrap_or_default(); sqd_messages::WorkerStatus { assignment_id, missing_chunks: Some(BitString::new(&status.unavailability_map)), diff --git a/src/main.rs b/src/main.rs index 55ad964..d526081 100644 --- a/src/main.rs +++ b/src/main.rs @@ -18,11 +18,9 @@ #![warn(clippy::suspicious)] #![warn(clippy::perf)] #![warn(clippy::complexity)] - #![allow(clippy::style)] #![allow(clippy::pedantic)] #![allow(clippy::nursery)] - #![cfg_attr(test, allow(clippy::all))] use std::borrow::Cow; From ac7bbfbc951d841b8f86a810ec384e4797ffa885 Mon Sep 17 00:00:00 2001 From: Defnull <879658+define-null@users.noreply.github.com> Date: Wed, 18 Feb 2026 11:04:14 +0100 Subject: [PATCH 3/6] Fix protoc dep --- .github/workflows/tests.yaml | 42 +++++++++++++++++++++++++++++++++++- 1 file changed, 41 insertions(+), 1 deletion(-) diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index fce9aa5..68b6a9f 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -8,6 +8,8 @@ on: env: CARGO_TERM_COLOR: always + PROTOC_VERSION: 33.3 + ARCH: linux-x86_64 concurrency: group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.ref }} @@ -19,13 +21,32 @@ jobs: runs-on: ubuntu-latest if: github.event_name == 'push' || !github.event.pull_request.draft steps: + - name: Cache protoc + id: cache-protoc + uses: actions/cache@v4 + with: + path: ~/.local/protoc + key: protoc-26.1-linux-x86_64 + + - name: Install protoc (if not cached) + if: steps.cache-protoc.outputs.cache-hit != 'true' + run: | + set -euxo pipefail + mkdir -p ~/.local/protoc + curl -L -o /tmp/protoc.zip \ + "https://github.com/protocolbuffers/protobuf/releases/download/v${PROTOC_VERSION}/protoc-${PROTOC_VERSION}-${ARCH}.zip" + unzip -q /tmp/protoc.zip -d ~/.local/protoc + + - name: Add protoc to PATH + run: echo "$HOME/.local/protoc/bin" >> "$GITHUB_PATH" + - uses: actions/checkout@v4 with: lfs: true - uses: dsherret/rust-toolchain-file@v1 - uses: Swatinem/rust-cache@v2 - name: Run tests - run: cargo test --all-features --verbose + run: cargo test --all-features fmt: name: Rustfmt @@ -41,6 +62,25 @@ jobs: runs-on: ubuntu-latest if: github.event_name == 'push' || !github.event.pull_request.draft steps: + - name: Cache protoc + id: cache-protoc + uses: actions/cache@v4 + with: + path: ~/.local/protoc + key: protoc-26.1-linux-x86_64 + + - name: Install protoc (if not cached) + if: steps.cache-protoc.outputs.cache-hit != 'true' + run: | + set -euxo pipefail + mkdir -p ~/.local/protoc + curl -L -o /tmp/protoc.zip \ + "https://github.com/protocolbuffers/protobuf/releases/download/v${PROTOC_VERSION}/protoc-${PROTOC_VERSION}-${ARCH}.zip" + unzip -q /tmp/protoc.zip -d ~/.local/protoc + + - name: Add protoc to PATH + run: echo "$HOME/.local/protoc/bin" >> "$GITHUB_PATH" + - uses: actions/checkout@v4 - uses: dsherret/rust-toolchain-file@v1 - uses: Swatinem/rust-cache@v2 From 641acc9633f9626e7f628e2940dc1b42d6464d4c Mon Sep 17 00:00:00 2001 From: Defnull <879658+define-null@users.noreply.github.com> Date: Wed, 18 Feb 2026 11:08:26 +0100 Subject: [PATCH 4/6] Fix pull/push CI part --- .github/workflows/tests.yaml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 68b6a9f..66e5e24 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -2,6 +2,8 @@ name: Rust Tests on: push: + branches: + - main pull_request: types: [opened, synchronize, reopened, ready_for_review] workflow_dispatch: From 391b07a479cd113d0333883e5947fbb0da054f32 Mon Sep 17 00:00:00 2001 From: Defnull <879658+define-null@users.noreply.github.com> Date: Wed, 18 Feb 2026 12:59:16 +0100 Subject: [PATCH 5/6] fix cache --- .github/workflows/tests.yaml | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 66e5e24..8ce3cb6 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -28,7 +28,7 @@ jobs: uses: actions/cache@v4 with: path: ~/.local/protoc - key: protoc-26.1-linux-x86_64 + key: protoc-${PROTOC_VERSION}-${ARCH} - name: Install protoc (if not cached) if: steps.cache-protoc.outputs.cache-hit != 'true' @@ -69,7 +69,7 @@ jobs: uses: actions/cache@v4 with: path: ~/.local/protoc - key: protoc-26.1-linux-x86_64 + key: protoc-${PROTOC_VERSION}-${ARCH} - name: Install protoc (if not cached) if: steps.cache-protoc.outputs.cache-hit != 'true' @@ -82,8 +82,10 @@ jobs: - name: Add protoc to PATH run: echo "$HOME/.local/protoc/bin" >> "$GITHUB_PATH" - + - uses: actions/checkout@v4 + - name: Fetch LFS files + run: git lfs fetch --all && git lfs checkout - uses: dsherret/rust-toolchain-file@v1 - uses: Swatinem/rust-cache@v2 - run: cargo clippy --all-targets --all-features -- -D clippy::correctness -D clippy::suspicious From aa4555fb2dd32548c977ecc7dbddd3952f322bdf Mon Sep 17 00:00:00 2001 From: Defnull <879658+define-null@users.noreply.github.com> Date: Wed, 18 Feb 2026 13:04:18 +0100 Subject: [PATCH 6/6] fix cache --- .github/workflows/tests.yaml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 8ce3cb6..7890c34 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -28,7 +28,7 @@ jobs: uses: actions/cache@v4 with: path: ~/.local/protoc - key: protoc-${PROTOC_VERSION}-${ARCH} + key: protoc-${{ env.PROTOC_VERSION }}-${{ runner.arch }} - name: Install protoc (if not cached) if: steps.cache-protoc.outputs.cache-hit != 'true' @@ -69,7 +69,7 @@ jobs: uses: actions/cache@v4 with: path: ~/.local/protoc - key: protoc-${PROTOC_VERSION}-${ARCH} + key: protoc-${{ env.PROTOC_VERSION }}-${{ runner.arch }} - name: Install protoc (if not cached) if: steps.cache-protoc.outputs.cache-hit != 'true'