Skip to content

Commit

Permalink
Cleanup & Upgrade (#26)
Browse files Browse the repository at this point in the history
Just improving CI and brushing the dust of this old clunky project before expanding it out.
  • Loading branch information
bh2smith authored Apr 7, 2024
1 parent 74e119d commit c3345f4
Show file tree
Hide file tree
Showing 9 changed files with 51 additions and 33 deletions.
22 changes: 22 additions & 0 deletions .github/workflows/main.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Rust Lint & Clippy

on:
push:
branches: [ "main" ]

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: Cache Cargo dependencies
uses: actions/cache@v4
with:
path: |
~/.cargo
target
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}

- name: Lint & Clippy
run: cargo fmt --check && cargo clippy --all-targets --verbose -- -D warnings
32 changes: 15 additions & 17 deletions .github/workflows/pull-request.yaml
Original file line number Diff line number Diff line change
@@ -1,28 +1,26 @@
name: Rust CI
name: Rust Lint, Clippy & Tests

on:
pull_request:
push:
branches: [ main ]

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
- name: Cache Cargo dependencies
uses: actions/cache@v4
with:
path: |
~/.cargo
target
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}
- uses: actions/checkout@v4
- name: Cache Cargo dependencies
uses: actions/cache@v4
with:
path: |
~/.cargo
target
key: ${{ runner.os }}-cargo-${{ hashFiles('**/Cargo.lock') }}

- name: Lint & Clippy
run: cargo fmt --check && cargo clippy --all-targets --verbose -- -D warnings
- name: Lint & Clippy
run: cargo fmt --check && cargo clippy --all-targets --verbose -- -D warnings

- name: Tests
run: cargo test
env:
DUNE_API_KEY: ${{ secrets.DUNE_API_KEY }}
- name: Tests
run: cargo test
env:
DUNE_API_KEY: ${{ secrets.DUNE_API_KEY }}
14 changes: 7 additions & 7 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ license = "MIT OR Apache-2.0"
keywords = ["dune", "ethereum", "api-client", "web3", "dune-analytics"]

[dependencies]
chrono = { version = "0.4.31", features = ["serde"] }
chrono = { version = "0.4.37", features = ["serde"] }
dotenv = "0.15.0"
log = "0.4.20"
reqwest = { version = "0.11.22", features = ["json"] }
serde = { version = "1.0.193", features = ["derive"] }
serde_json = "1.0.108"
serde_with = "3.4.0"
tokio = { version = "1.34.0", features = ["full"] }
log = "0.4.21"
reqwest = { version = "0.12.3", features = ["json"] }
serde = { version = "1.0.197", features = ["derive"] }
serde_json = "1.0.115"
serde_with = "3.7.0"
tokio = { version = "1.37.0", features = ["full"] }
2 changes: 1 addition & 1 deletion src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ impl DuneClient {
}

/// Deserializes Responses into appropriate type.
/// Some "invalid" requests return response JSON, which are parsed an returned as Errors.
/// Some "invalid" requests return response JSON, which are parsed and returned as Errors.
async fn _parse_response<T: DeserializeOwned>(resp: Response) -> Result<T, DuneRequestError> {
if resp.status().is_success() {
resp.json::<T>().await.map_err(DuneRequestError::from)
Expand Down
2 changes: 1 addition & 1 deletion src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ mod tests {
let err = reqwest::get("invalid-url").await.unwrap_err();
assert_eq!(
DuneRequestError::from(err),
DuneRequestError::Request("builder error: relative URL without a base".to_string())
DuneRequestError::Request("builder error".to_string())
);
assert_eq!(
DuneRequestError::from(DuneError {
Expand Down
2 changes: 1 addition & 1 deletion src/parameters.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ enum ParameterType {
Text,
/// Encapsulates all numerical types (integer and float).
Number,
/// A.k.a List or Dropdown of text.
/// A.k.a. List or Dropdown of text.
Enum,
/// Dune Date strings take the form `YYYY-MM-DD hh:mm:ss`
Date,
Expand Down
7 changes: 3 additions & 4 deletions src/parse_utils.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
#![allow(dead_code)]
use chrono::{DateTime, NaiveDateTime, ParseError, Utc};
use serde::{de, Deserialize, Deserializer};
use serde_json::Value;
Expand Down Expand Up @@ -51,13 +50,13 @@ where

pub fn f64_from_str<'de, D>(deserializer: D) -> Result<f64, D::Error>
where
D: serde::Deserializer<'de>,
D: Deserializer<'de>,
{
let value: Value = Deserialize::deserialize(deserializer)?;
if let Value::String(s) = value {
s.parse().map_err(serde::de::Error::custom)
s.parse().map_err(de::Error::custom)
} else {
Err(serde::de::Error::custom("Expected a string"))
Err(de::Error::custom("Expected a string"))
}
}

Expand Down
2 changes: 1 addition & 1 deletion src/response.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ pub struct ExecutionResponse {
}

/// Represents all possible states of query execution.
/// Most states are self explanatory.
/// Most states are self-explanatory.
/// Failure can occur if query takes too long (30 minutes) to execute.
/// Pending state also comes along with a "queue position"
#[derive(DeserializeFromStr, Debug, PartialEq)]
Expand Down
1 change: 0 additions & 1 deletion tests/example.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ async fn test_external_use() {

#[tokio::test]
async fn test_blocks() {
#[allow(dead_code)]
#[derive(Deserialize, Debug, PartialEq)]
struct Block {
pub number: u64,
Expand Down

0 comments on commit c3345f4

Please sign in to comment.