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
91 changes: 91 additions & 0 deletions .github/workflows/tests.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
name: Rust Tests

on:
push:
branches:
- main
pull_request:
types: [opened, synchronize, reopened, ready_for_review]
workflow_dispatch:

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 }}
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:
- name: Cache protoc
id: cache-protoc
uses: actions/cache@v4
with:
path: ~/.local/protoc
key: protoc-${{ env.PROTOC_VERSION }}-${{ runner.arch }}

- 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

Comment on lines +33 to +41
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think apt-get install protobuf-compiler should be enough

Copy link
Copy Markdown
Contributor Author

@define-null define-null Feb 18, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The main motivation was:

  • to pin concrete version (reproducability)
  • do not be forced to run apt-get update
    • that saves a bit of a time if update is necessary

- 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

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:
- name: Cache protoc
id: cache-protoc
uses: actions/cache@v4
with:
path: ~/.local/protoc
key: protoc-${{ env.PROTOC_VERSION }}-${{ runner.arch }}

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

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

9 changes: 5 additions & 4 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
Expand Down
2 changes: 1 addition & 1 deletion src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Duration> {
Expand Down
5 changes: 1 addition & 4 deletions src/controller/p2p.rs
Original file line number Diff line number Diff line change
Expand Up @@ -595,10 +595,7 @@ impl<EventStream: Stream<Item = WorkerEvent> + Send + 'static> P2PController<Eve
#[tracing::instrument(skip_all)]
async fn get_worker_status(worker: &Worker) -> 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)),
Expand Down
2 changes: 1 addition & 1 deletion src/controller/polars_target.rs
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ impl ExprTransformer<Expr, PolarsTargetErr> for PolarsExprTransformer {
l: &expression::SingularOrList,
) -> Result<Expr, PolarsTargetErr> {
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()),
}?;

Expand Down
2 changes: 1 addition & 1 deletion src/controller/worker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
9 changes: 9 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,15 @@
// You should have received a copy of the GNU Affero General Public License
// along with this program. If not, see <https://www.gnu.org/licenses/>.

#![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;

Expand Down