Skip to content

Commit

Permalink
Add publish to CI (#31)
Browse files Browse the repository at this point in the history
  • Loading branch information
lukekim authored Mar 21, 2024
1 parent c73347a commit 49f43c0
Show file tree
Hide file tree
Showing 9 changed files with 110 additions and 44 deletions.
54 changes: 54 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -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 }}
26 changes: 26 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
@@ -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 }}
25 changes: 0 additions & 25 deletions .github/workflows/rust.yml

This file was deleted.

4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "spice-rs"
version = "0.1.0"
name = "spiceai"
version = "1.0.3"
edition = "2021"

[dependencies]
Expand Down
22 changes: 16 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,26 @@ spice-rs = { git = "https://github.com/spiceai/spice-rs", tag = "v1.0.2" }
```

## Usage

<!-- NOTE: If you're changing the code examples below, make sure you update `tests/readme_test.rs`. -->

### 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() {
Expand All @@ -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() {
Expand All @@ -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() {
Expand All @@ -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() {
Expand All @@ -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;
Expand All @@ -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.
17 changes: 9 additions & 8 deletions src/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,19 +40,20 @@ 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,
prices: PricesClient,
}

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() {
Expand All @@ -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() {
Expand All @@ -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() {
Expand All @@ -102,7 +103,7 @@ impl SpiceClient {

/// Get the supported pairs:
/// ```rust
/// # use spice_rs::Client;
/// # use spiceai::Client;
/// #
/// # #[tokio::main]
/// # async fn main() {
Expand All @@ -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() {
Expand All @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion tests/client_test.rs
Original file line number Diff line number Diff line change
@@ -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;

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

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

0 comments on commit 49f43c0

Please sign in to comment.