Skip to content

Commit 49f43c0

Browse files
authored
Add publish to CI (#31)
1 parent c73347a commit 49f43c0

9 files changed

Lines changed: 110 additions & 44 deletions

File tree

.github/workflows/build.yml

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
name: build
2+
3+
on:
4+
push:
5+
branches: ['trunk']
6+
pull_request:
7+
branches: ['trunk']
8+
9+
env:
10+
CARGO_TERM_COLOR: always
11+
12+
jobs:
13+
build_and_test:
14+
runs-on: ubuntu-latest
15+
strategy:
16+
matrix:
17+
toolchain:
18+
- stable
19+
- beta
20+
- nightly
21+
22+
steps:
23+
- uses: actions/checkout@v4
24+
25+
- name: Install Rust toolchain
26+
uses: actions-rs/toolchain@v1
27+
with:
28+
profile: minimal
29+
toolchain: ${{ matrix.toolchain }}
30+
components: clippy
31+
override: true
32+
33+
- name: Install required cargo
34+
run: cargo install clippy-sarif sarif-fmt
35+
36+
- name: Run rust-clippy
37+
run: cargo clippy
38+
--all-features
39+
--message-format=json | clippy-sarif | tee rust-clippy-results.sarif | sarif-fmt
40+
continue-on-error: true
41+
42+
- name: Upload analysis results to GitHub
43+
uses: github/codeql-action/upload-sarif@v1
44+
with:
45+
sarif_file: rust-clippy-results.sarif
46+
wait-for-processing: true
47+
48+
- name: Build
49+
run: cargo build --verbose
50+
51+
- name: Run tests
52+
run: cargo test --verbose
53+
env:
54+
API_KEY: ${{ secrets.TEST_API_KEY }}

.github/workflows/publish.yml

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
name: crates-publish
2+
3+
on:
4+
release:
5+
types: [created]
6+
7+
workflow_dispatch:
8+
9+
jobs:
10+
publish:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v4
14+
15+
- name: Install Rust toolchain
16+
uses: actions-rs/toolchain@v1
17+
with:
18+
profile: minimal
19+
toolchain: stable
20+
override: true
21+
22+
- run: cargo build --verbose
23+
24+
- run: cargo publish --verbose
25+
env:
26+
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }}

.github/workflows/rust.yml

Lines changed: 0 additions & 25 deletions
This file was deleted.

Cargo.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
2-
name = "spice-rs"
3-
version = "0.1.0"
2+
name = "spiceai"
3+
version = "1.0.3"
44
edition = "2021"
55

66
[dependencies]

README.md

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,21 +12,26 @@ spice-rs = { git = "https://github.com/spiceai/spice-rs", tag = "v1.0.2" }
1212
```
1313

1414
## Usage
15+
1516
<!-- NOTE: If you're changing the code examples below, make sure you update `tests/readme_test.rs`. -->
17+
1618
### New client
19+
1720
```rust
18-
use spice_rs::Client;
21+
use spiceai::Client;
1922

2023
#[tokio::main]
2124
async fn main() {
2225
let mut client = Client::new("API_KEY").await.unwrap();
2326
}
2427
```
28+
2529
### Arrow Query
30+
2631
SQL Query
2732

2833
```rust
29-
use spice_rs::Client;
34+
use spiceai::Client;
3035

3136
#[tokio::main]
3237
async fn main() {
@@ -35,11 +40,13 @@ async fn main() {
3540
}
3641

3742
```
43+
3844
### Firecache Query
45+
3946
Firecache SQL Query
4047

4148
```rust
42-
use spice_rs::Client;
49+
use spiceai::Client;
4350

4451
#[tokio::main]
4552
async fn main() {
@@ -48,13 +55,15 @@ async fn main() {
4855
}
4956

5057
```
58+
5159
### HTTP API
60+
5261
#### Prices
5362

5463
Get the supported pairs:
5564

5665
```rust
57-
use spice_rs::Client;
66+
use spiceai::Client;
5867

5968
#[tokio::main]
6069
async fn main() {
@@ -66,7 +75,7 @@ async fn main() {
6675
Get the latest price for a token pair:
6776

6877
```rust
69-
use spice_rs::Client;
78+
use spiceai::Client;
7079

7180
#[tokio::main]
7281
async fn main() {
@@ -78,7 +87,7 @@ async fn main() {
7887
Get historical data:
7988

8089
```rust
81-
use spice_rs::Client;
90+
use spiceai::Client;
8291
use chrono::Utc;
8392
use chrono::Duration;
8493
use std::ops::Sub;
@@ -96,4 +105,5 @@ async fn main() {
96105
```
97106

98107
## Documentation
108+
99109
Check out our [Documentation](https://docs.spice.ai/sdks/rust-sdk) to learn more about how to use the Rust SDK.

src/client.rs

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -40,19 +40,20 @@ impl SpiceClientConfig {
4040
}
4141
}
4242

43-
/// The SpiceClient is the main entry point for interacting with the Spice API.
43+
/// The `SpiceClient` is the main entry point for interacting with the Spice API.
4444
/// It provides methods for querying the Spice Flight and Firecache endpoints,
4545
/// as well as the Spice Prices endpoint.
46+
#[allow(clippy::module_name_repetitions)]
4647
pub struct SpiceClient {
4748
flight: SqlFlightClient,
4849
firecache: SqlFlightClient,
4950
prices: PricesClient,
5051
}
5152

5253
impl SpiceClient {
53-
/// Creates a new SpiceClient with the given API key.
54+
/// Creates a new `SpiceClient` with the given API key.
5455
/// ```
55-
/// use spice_rs::Client;
56+
/// use spiceai::Client;
5657
///
5758
/// #[tokio::main]
5859
/// async fn main() {
@@ -71,7 +72,7 @@ impl SpiceClient {
7172

7273
/// Queries the Spice Flight endpoint with the given SQL query.
7374
/// ```
74-
/// # use spice_rs::Client;
75+
/// # use spiceai::Client;
7576
/// #
7677
/// # #[tokio::main]
7778
/// # async fn main() {
@@ -85,7 +86,7 @@ impl SpiceClient {
8586

8687
/// Queries the Spice Firecache endpoint with the given SQL query.
8788
/// ```
88-
/// # use spice_rs::Client;
89+
/// # use spiceai::Client;
8990
/// #
9091
/// # #[tokio::main]
9192
/// # async fn main() {
@@ -102,7 +103,7 @@ impl SpiceClient {
102103

103104
/// Get the supported pairs:
104105
/// ```rust
105-
/// # use spice_rs::Client;
106+
/// # use spiceai::Client;
106107
/// #
107108
/// # #[tokio::main]
108109
/// # async fn main() {
@@ -116,7 +117,7 @@ impl SpiceClient {
116117

117118
/// Get the latest price for a token pair:
118119
/// ```rust
119-
/// # use spice_rs::Client;
120+
/// # use spiceai::Client;
120121
/// #
121122
/// # #[tokio::main]
122123
/// # async fn main() {
@@ -130,7 +131,7 @@ impl SpiceClient {
130131

131132
/// Get historical data:
132133
/// ```rust
133-
/// # use spice_rs::Client;
134+
/// # use spiceai::Client;
134135
/// # use chrono::Utc;
135136
/// # use chrono::Duration;
136137
/// # use std::ops::Sub;

tests/client_test.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#[cfg(test)]
22
mod tests {
33
use futures::stream::StreamExt;
4-
use spice_rs::Client;
4+
use spiceai::Client;
55
use std::env;
66
use std::path::Path;
77

tests/price_test.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#[cfg(test)]
22
mod tests {
33
use chrono::{TimeZone, Utc};
4-
use spice_rs::Client;
4+
use spiceai::Client;
55
use std::env;
66
use std::path::Path;
77

tests/readme_test.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#[cfg(test)]
22
mod tests {
33
use chrono::{Duration, Utc};
4-
use spice_rs::*;
4+
use spiceai::*;
55
use std::env;
66
use std::ops::Sub;
77
use std::path::Path;

0 commit comments

Comments
 (0)