diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000..64319c3 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,54 @@ +name: build + +on: + push: + branches: ['trunk'] + pull_request: + branches: ['trunk'] + +env: + CARGO_TERM_COLOR: always + +jobs: + build_and_test: + runs-on: ubuntu-latest + strategy: + matrix: + toolchain: + - stable + - beta + - nightly + + steps: + - uses: actions/checkout@v4 + + - name: Install Rust toolchain + uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: ${{ matrix.toolchain }} + components: clippy + override: true + + - name: Install required cargo + run: cargo install clippy-sarif sarif-fmt + + - name: Run rust-clippy + run: cargo clippy + --all-features + --message-format=json | clippy-sarif | tee rust-clippy-results.sarif | sarif-fmt + continue-on-error: true + + - name: Upload analysis results to GitHub + uses: github/codeql-action/upload-sarif@v1 + with: + sarif_file: rust-clippy-results.sarif + wait-for-processing: true + + - name: Build + run: cargo build --verbose + + - name: Run tests + run: cargo test --verbose + env: + API_KEY: ${{ secrets.TEST_API_KEY }} diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml new file mode 100644 index 0000000..661a46d --- /dev/null +++ b/.github/workflows/publish.yml @@ -0,0 +1,26 @@ +name: crates-publish + +on: + release: + types: [created] + + workflow_dispatch: + +jobs: + publish: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + + - name: Install Rust toolchain + uses: actions-rs/toolchain@v1 + with: + profile: minimal + toolchain: stable + override: true + + - run: cargo build --verbose + + - run: cargo publish --verbose + env: + CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml deleted file mode 100644 index 7ea78d0..0000000 --- a/.github/workflows/rust.yml +++ /dev/null @@ -1,25 +0,0 @@ -name: Rust - -on: - push: - branches: ["trunk"] - pull_request: - branches: ["trunk"] - -env: - CARGO_TERM_COLOR: always - -jobs: - build: - runs-on: ubuntu-latest - - steps: - - uses: actions/checkout@v3 - - name: Build - run: cargo build --verbose - - name: Run tests - run: cargo test --verbose - env: - API_KEY: ${{ secrets.TEST_API_KEY }} - - name: Run clippy - run: cargo clippy --verbose --all-targets --all-features -- -D warnings diff --git a/Cargo.toml b/Cargo.toml index b6bb4c5..2746905 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] -name = "spice-rs" -version = "0.1.0" +name = "spiceai" +version = "1.0.3" edition = "2021" [dependencies] diff --git a/README.md b/README.md index 16766ef..466bf03 100644 --- a/README.md +++ b/README.md @@ -12,21 +12,26 @@ spice-rs = { git = "https://github.com/spiceai/spice-rs", tag = "v1.0.2" } ``` ## Usage + + ### New client + ```rust -use spice_rs::Client; +use spiceai::Client; #[tokio::main] async fn main() { let mut client = Client::new("API_KEY").await.unwrap(); } ``` + ### Arrow Query + SQL Query ```rust -use spice_rs::Client; +use spiceai::Client; #[tokio::main] async fn main() { @@ -35,11 +40,13 @@ async fn main() { } ``` + ### Firecache Query + Firecache SQL Query ```rust -use spice_rs::Client; +use spiceai::Client; #[tokio::main] async fn main() { @@ -48,13 +55,15 @@ async fn main() { } ``` + ### HTTP API + #### Prices Get the supported pairs: ```rust -use spice_rs::Client; +use spiceai::Client; #[tokio::main] async fn main() { @@ -66,7 +75,7 @@ async fn main() { Get the latest price for a token pair: ```rust -use spice_rs::Client; +use spiceai::Client; #[tokio::main] async fn main() { @@ -78,7 +87,7 @@ async fn main() { Get historical data: ```rust -use spice_rs::Client; +use spiceai::Client; use chrono::Utc; use chrono::Duration; use std::ops::Sub; @@ -96,4 +105,5 @@ async fn main() { ``` ## Documentation + Check out our [Documentation](https://docs.spice.ai/sdks/rust-sdk) to learn more about how to use the Rust SDK. diff --git a/src/client.rs b/src/client.rs index 8f982bb..3f94a0d 100644 --- a/src/client.rs +++ b/src/client.rs @@ -40,9 +40,10 @@ impl SpiceClientConfig { } } -/// The SpiceClient is the main entry point for interacting with the Spice API. +/// The `SpiceClient` is the main entry point for interacting with the Spice API. /// It provides methods for querying the Spice Flight and Firecache endpoints, /// as well as the Spice Prices endpoint. +#[allow(clippy::module_name_repetitions)] pub struct SpiceClient { flight: SqlFlightClient, firecache: SqlFlightClient, @@ -50,9 +51,9 @@ pub struct SpiceClient { } impl SpiceClient { - /// Creates a new SpiceClient with the given API key. + /// Creates a new `SpiceClient` with the given API key. /// ``` - /// use spice_rs::Client; + /// use spiceai::Client; /// /// #[tokio::main] /// async fn main() { @@ -71,7 +72,7 @@ impl SpiceClient { /// Queries the Spice Flight endpoint with the given SQL query. /// ``` - /// # use spice_rs::Client; + /// # use spiceai::Client; /// # /// # #[tokio::main] /// # async fn main() { @@ -85,7 +86,7 @@ impl SpiceClient { /// Queries the Spice Firecache endpoint with the given SQL query. /// ``` - /// # use spice_rs::Client; + /// # use spiceai::Client; /// # /// # #[tokio::main] /// # async fn main() { @@ -102,7 +103,7 @@ impl SpiceClient { /// Get the supported pairs: /// ```rust - /// # use spice_rs::Client; + /// # use spiceai::Client; /// # /// # #[tokio::main] /// # async fn main() { @@ -116,7 +117,7 @@ impl SpiceClient { /// Get the latest price for a token pair: /// ```rust - /// # use spice_rs::Client; + /// # use spiceai::Client; /// # /// # #[tokio::main] /// # async fn main() { @@ -130,7 +131,7 @@ impl SpiceClient { /// Get historical data: /// ```rust - /// # use spice_rs::Client; + /// # use spiceai::Client; /// # use chrono::Utc; /// # use chrono::Duration; /// # use std::ops::Sub; diff --git a/tests/client_test.rs b/tests/client_test.rs index 1a86dec..f5e399c 100644 --- a/tests/client_test.rs +++ b/tests/client_test.rs @@ -1,7 +1,7 @@ #[cfg(test)] mod tests { use futures::stream::StreamExt; - use spice_rs::Client; + use spiceai::Client; use std::env; use std::path::Path; diff --git a/tests/price_test.rs b/tests/price_test.rs index e1494d9..ff7a4e4 100644 --- a/tests/price_test.rs +++ b/tests/price_test.rs @@ -1,7 +1,7 @@ #[cfg(test)] mod tests { use chrono::{TimeZone, Utc}; - use spice_rs::Client; + use spiceai::Client; use std::env; use std::path::Path; diff --git a/tests/readme_test.rs b/tests/readme_test.rs index d49553e..04523db 100644 --- a/tests/readme_test.rs +++ b/tests/readme_test.rs @@ -1,7 +1,7 @@ #[cfg(test)] mod tests { use chrono::{Duration, Utc}; - use spice_rs::*; + use spiceai::*; use std::env; use std::ops::Sub; use std::path::Path;