Mirror of https://github.com/roostorg/osprey github.com/roostorg/osprey
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

feat: add rust build workflow (#50)

authored by

Caidan and committed by
GitHub
704347d5 b3b38662

+66 -14
+49 -1
.github/workflows/code-quality.yml
··· 4 4 pull_request: 5 5 branches: [main] 6 6 types: [opened, synchronize, reopened, ready_for_review] 7 + push: 8 + branches: [main] 7 9 8 10 concurrency: 9 11 group: ${{ github.workflow }}-${{ github.ref }} ··· 40 42 run: uv run mypy . 41 43 42 44 ui-quality: 43 - runs-on: ubuntu-latest 45 + runs-on: ubuntu-24.04 44 46 steps: 45 47 - name: Checkout code 46 48 uses: actions/checkout@v4 ··· 59 61 - name: Run prettier check 60 62 run: npm run format:check 61 63 working-directory: osprey_ui 64 + 65 + rust-quality: 66 + runs-on: ubuntu-24.04 67 + steps: 68 + - name: Checkout code 69 + uses: actions/checkout@v4 70 + 71 + - name: Set up Rust 72 + uses: actions-rs/toolchain@v1 73 + with: 74 + toolchain: stable 75 + components: rustfmt, clippy 76 + override: true 77 + 78 + - name: Cache Rust dependencies 79 + uses: actions/cache@v4 80 + with: 81 + path: | 82 + ~/.cargo/bin/ 83 + ~/.cargo/registry/index/ 84 + ~/.cargo/registry/cache/ 85 + ~/.cargo/git/db/ 86 + osprey_coordinator/target/ 87 + key: ${{ runner.os }}-cargo-${{ hashFiles('osprey_coordinator/Cargo.lock', 'osprey_coordinator/Cargo.toml') }} 88 + restore-keys: | 89 + ${{ runner.os }}-cargo- 90 + 91 + - name: Check Rust formatting 92 + run: cargo fmt --check 93 + working-directory: osprey_coordinator 94 + 95 + - name: Run Clippy linting 96 + run: cargo clippy -- -D warnings 97 + working-directory: osprey_coordinator 98 + continue-on-error: true 99 + 100 + - name: Build Rust project 101 + run: | 102 + sudo apt-get install protobuf-compiler 103 + cargo build --verbose 104 + working-directory: osprey_coordinator 105 + 106 + - name: Run Rust tests 107 + run: cargo test --verbose 108 + working-directory: osprey_coordinator 109 + continue-on-error: true
+1 -2
osprey_coordinator/build.rs
··· 5 5 let proto_paths = [ 6 6 proto_root.join("osprey/rpc/actions/v1/action.proto"), 7 7 proto_root.join("osprey/rpc/osprey_coordinator/sync_action/v1/service.proto"), 8 - proto_root 9 - .join("osprey/rpc/osprey_coordinator/bidirectional_stream/v1/service.proto"), 8 + proto_root.join("osprey/rpc/osprey_coordinator/bidirectional_stream/v1/service.proto"), 10 9 proto_root.join("osprey/rpc/common/v1/*.proto"), 11 10 ] 12 11 .into_iter()
+2 -2
osprey_coordinator/src/main.rs
··· 10 10 mod hashring; 11 11 mod label_service_client; 12 12 mod metrics; 13 + mod osprey_bidirectional_stream; 13 14 mod pigeon; 14 15 mod priority_queue; 15 16 mod proto; ··· 17 18 mod pubsub; 18 19 mod shutdown_handler; 19 20 mod signals; 20 - mod osprey_bidirectional_stream; 21 21 mod snowflake_client; 22 22 mod sync_action_rpc; 23 23 mod tokio_utils; ··· 41 41 use pubsub::start_pubsub_subscriber; 42 42 use tokio::join; 43 43 44 - use crate::proto::osprey_coordinator_service_server::OspreyCoordinatorServiceServer; 45 44 use crate::osprey_bidirectional_stream::OspreyCoordinatorServer; 45 + use crate::proto::osprey_coordinator_service_server::OspreyCoordinatorServiceServer; 46 46 47 47 #[derive(Debug, Parser)] 48 48 struct CliOptions {
+3 -1
osprey_coordinator/src/osprey_bidirectional_stream.rs
··· 168 168 } 169 169 170 170 #[tonic::async_trait] 171 - impl proto::osprey_coordinator_service_server::OspreyCoordinatorService for OspreyCoordinatorServer { 171 + impl proto::osprey_coordinator_service_server::OspreyCoordinatorService 172 + for OspreyCoordinatorServer 173 + { 172 174 type OspreyBidirectionalStreamStream = 173 175 ReceiverStream<Result<proto::OspreyCoordinatorAction, tonic::Status>>; 174 176
-1
osprey_coordinator/src/proto/mod.rs
··· 41 41 } 42 42 } 43 43 44 - 45 44 pub use osprey::rpc::actions::v1::*; 46 45 pub use osprey::rpc::common::v1::*; 47 46 pub use osprey::rpc::labels::v1::*;
+11 -7
osprey_coordinator/src/sync_action_rpc.rs
··· 12 12 use std::sync::Arc; 13 13 use tokio::time::Instant; 14 14 15 - use rand::Rng; 16 15 use osprey_coordinator_sync_action::osprey_coordinator_sync_action_service_server::OspreyCoordinatorSyncActionService; 17 16 use osprey_coordinator_sync_action::ProcessActionRequest; 17 + use rand::Rng; 18 18 19 19 pub(crate) struct SyncActionServer { 20 20 snowflake_client: Arc<SnowflakeClient>, ··· 60 60 ack_id, 61 61 action_id, 62 62 action_name: action_request.action_name.clone(), 63 - action_data: Some(proto::osprey_coordinator_action::ActionData::JsonActionData( 64 - action_request.action_data_json.clone().into(), 65 - )), 63 + action_data: Some( 64 + proto::osprey_coordinator_action::ActionData::JsonActionData( 65 + action_request.action_data_json.clone().into(), 66 + ), 67 + ), 66 68 secret_data: None, 67 69 timestamp: Some( 68 70 action_request ··· 88 90 { 89 91 let unvalidated_action_id = action_request.action_id; 90 92 91 - let (smite_coordinator_action, requested_entities) = match create_smite_coordinator_action( 93 + let (smite_coordinator_action, requested_entities) = match create_smite_coordinator_action( 92 94 ack_id, 93 95 action_request, 94 96 self.snowflake_client.as_ref(), ··· 145 147 } 146 148 }; 147 149 148 - let response = 149 - osprey_coordinator_sync_action::ProcessActionResponse { entities, verdicts }; 150 + let response = osprey_coordinator_sync_action::ProcessActionResponse { 151 + entities, 152 + verdicts, 153 + }; 150 154 151 155 self.metrics.sync_classification_result_ack.incr(); 152 156 self.metrics