Skip to content

Commit de3a3a9

Browse files
committed
ci: Add GitHub Actions CI workflow
- Add CI workflow with fmt, clippy, test, MSRV (1.92), and docs checks - Add clippy allow attributes for too_many_arguments and result_large_err - Update README badges (CI status, license, docs.rs) - Use idiomatic while let pattern in reconnect example
1 parent 7cb2ec3 commit de3a3a9

File tree

7 files changed

+92
-21
lines changed

7 files changed

+92
-21
lines changed

.github/workflows/ci.yml

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
name: CI
2+
3+
on:
4+
push:
5+
branches: [main]
6+
pull_request:
7+
branches: [main]
8+
9+
env:
10+
CARGO_TERM_COLOR: always
11+
12+
jobs:
13+
fmt:
14+
name: Format
15+
runs-on: ubuntu-latest
16+
steps:
17+
- uses: actions/checkout@v4
18+
- uses: dtolnay/rust-toolchain@stable
19+
with:
20+
components: rustfmt
21+
- run: cargo fmt --all --check
22+
23+
clippy:
24+
name: Clippy
25+
runs-on: ubuntu-latest
26+
steps:
27+
- uses: actions/checkout@v4
28+
- uses: dtolnay/rust-toolchain@stable
29+
with:
30+
components: clippy
31+
- uses: Swatinem/rust-cache@v2
32+
- run: cargo clippy --all-targets -- -D warnings
33+
34+
test:
35+
name: Test
36+
runs-on: ubuntu-latest
37+
steps:
38+
- uses: actions/checkout@v4
39+
- uses: dtolnay/rust-toolchain@stable
40+
- uses: Swatinem/rust-cache@v2
41+
# Run single-threaded to avoid env var race conditions in config tests
42+
- run: cargo test -- --test-threads=1
43+
44+
msrv:
45+
name: MSRV (1.92)
46+
runs-on: ubuntu-latest
47+
steps:
48+
- uses: actions/checkout@v4
49+
- uses: dtolnay/rust-toolchain@master
50+
with:
51+
toolchain: "1.92"
52+
- uses: Swatinem/rust-cache@v2
53+
- run: cargo build --all-targets
54+
55+
docs:
56+
name: Docs
57+
runs-on: ubuntu-latest
58+
steps:
59+
- uses: actions/checkout@v4
60+
- uses: dtolnay/rust-toolchain@stable
61+
- uses: Swatinem/rust-cache@v2
62+
- run: cargo doc --no-deps
63+
env:
64+
RUSTDOCFLAGS: -D warnings

README.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
# Rust Rithmic R | Protocol API client
22

33
[![Crates.io](https://img.shields.io/crates/v/rithmic-rs.svg)](https://crates.io/crates/rithmic-rs)
4-
[![Documentation](https://docs.rs/rithmic-rs/badge.svg)](https://docs.rs/rithmic-rs)
4+
[![docs.rs](https://img.shields.io/docsrs/rithmic-rs)](https://docs.rs/rithmic-rs)
5+
[![CI](https://github.com/pbeets/rithmic-rs/actions/workflows/ci.yml/badge.svg)](https://github.com/pbeets/rithmic-rs/actions)
6+
[![License](https://img.shields.io/crates/l/rithmic-rs)](LICENSE-MIT)
57

68
[Official Rithmic API](https://www.rithmic.com/apis)
79

examples/reconnect.rs

Lines changed: 17 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -48,26 +48,23 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
4848
info!("Subscribed to {} on {}", symbol, exchange);
4949
}
5050

51-
// Inner loop: process until disconnect
52-
loop {
53-
match handle.subscription_receiver.recv().await {
54-
Ok(update) => match &update.message {
55-
RithmicMessage::HeartbeatTimeout
56-
| RithmicMessage::ForcedLogout(_)
57-
| RithmicMessage::ConnectionError => {
58-
warn!("Disconnected, reconnecting...");
59-
break;
60-
}
61-
RithmicMessage::LastTrade(t) => {
62-
info!(
63-
"Trade: {} @ {}",
64-
t.trade_size.unwrap_or(0),
65-
t.trade_price.unwrap_or(0.0)
66-
);
67-
}
68-
_ => {}
69-
},
70-
Err(_) => break,
51+
// Process until disconnect
52+
while let Ok(update) = handle.subscription_receiver.recv().await {
53+
match &update.message {
54+
RithmicMessage::HeartbeatTimeout
55+
| RithmicMessage::ForcedLogout(_)
56+
| RithmicMessage::ConnectionError => {
57+
warn!("Disconnected, reconnecting...");
58+
break;
59+
}
60+
RithmicMessage::LastTrade(t) => {
61+
info!(
62+
"Trade: {} @ {}",
63+
t.trade_size.unwrap_or(0),
64+
t.trade_price.unwrap_or(0.0)
65+
);
66+
}
67+
_ => {}
7168
}
7269
}
7370

src/api/receiver_api.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,10 @@ pub(crate) struct RithmicReceiverApi {
113113
}
114114

115115
impl RithmicReceiverApi {
116+
// TODO: Consider boxing RithmicMessage or using a dedicated error type to reduce
117+
// Result size (~1296 bytes). Current impact is minimal since the Result is
118+
// immediately matched and not passed through deep call stacks.
119+
#[allow(clippy::result_large_err)]
116120
pub(crate) fn buf_to_message(&self, data: Bytes) -> Result<RithmicResponse, RithmicResponse> {
117121
let payload = &data[4..];
118122

src/api/sender_api.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -440,6 +440,7 @@ impl RithmicSenderApi {
440440
///
441441
/// # Returns
442442
/// A tuple of (serialized request buffer, request ID)
443+
#[allow(clippy::too_many_arguments)]
443444
pub fn request_new_order(
444445
&mut self,
445446
exchange: &str,
@@ -855,6 +856,7 @@ impl RithmicSenderApi {
855856
/// a round number of bars (e.g., 10000) or does not cover the entire requested
856857
/// time period, use [`request_resume_bars`](Self::request_resume_bars) with the
857858
/// `request_key` from the response to fetch the remaining data.
859+
#[allow(clippy::too_many_arguments)]
858860
pub fn request_volume_profile_minute_bars(
859861
&mut self,
860862
symbol: &str,

src/plants/history_plant.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -880,6 +880,7 @@ impl RithmicHistoryPlantHandle {
880880
///
881881
/// # Returns
882882
/// The volume profile minute bar responses or an error message
883+
#[allow(clippy::too_many_arguments)]
883884
pub async fn load_volume_profile_minute_bars(
884885
&self,
885886
symbol: String,

src/plants/order_plant.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1726,6 +1726,7 @@ impl RithmicOrderPlantHandle {
17261726
///
17271727
/// # Returns
17281728
/// A vector of order placement responses or an error message
1729+
#[allow(clippy::too_many_arguments)]
17291730
pub async fn place_new_order(
17301731
&self,
17311732
exchange: &str,

0 commit comments

Comments
 (0)