Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 15 additions & 2 deletions .github/workflows/build-rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,15 +8,21 @@ on:
required: true
type: string
artifact-name:
description: "Name for the uploaded artifact"
description: "Base name for the uploaded artifact"
required: true
type: string
outputs:
artifact-name:
description: "The actual artifact name with hash suffix"
value: ${{ jobs.build.outputs.artifact-name }}

jobs:
build:
name: Build Rust Artifacts
runs-on: ubuntu-latest
timeout-minutes: 15
outputs:
artifact-name: ${{ inputs.artifact-name }}-${{ steps.source-hash.outputs.hash }}
steps:
- uses: actions/checkout@v4

Expand All @@ -26,13 +32,20 @@ jobs:
with:
shared-key: ${{ inputs.cache-key }}

- name: Calculate source files hash
id: source-hash
run: |
SOURCE_HASH=$(find crates tests Cargo.toml Cargo.lock Makefile makefiles -type f \( -name "*.rs" -o -name "*.toml" -o -name "Makefile" \) -exec sha256sum {} \; | sort | sha256sum | cut -d' ' -f1 | head -c 8)
echo "hash=$SOURCE_HASH" >> $GITHUB_OUTPUT
echo "Source files hash: $SOURCE_HASH"

- name: Build workspace
run: make build

- name: Upload build artifacts
uses: actions/upload-artifact@v4
with:
name: ${{ inputs.artifact-name }}
name: ${{ inputs.artifact-name }}-${{ steps.source-hash.outputs.hash }}
path: |
target/debug/kora
target/debug/test_runner
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ jobs:
- name: Download build artifacts
uses: actions/download-artifact@v4
with:
name: rust-binaries
name: ${{ needs.build.outputs.artifact-name }}
path: target/debug/

- name: Make binaries executable
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/typescript-integration.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ jobs:
- name: Download build artifacts
uses: actions/download-artifact@v4
with:
name: rust-binaries-ts
name: ${{ needs.build.outputs.artifact-name }}
path: target/debug/

- name: Make binaries executable
Expand Down
12 changes: 9 additions & 3 deletions crates/cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,9 @@ async fn main() -> Result<(), KoraError> {
let ServerHandles { rpc_handle, metrics_handle, balance_tracker_handle } =
run_rpc_server(kora_rpc, rpc_args.port).await?;

tokio::signal::ctrl_c().await.unwrap();
if let Err(e) = tokio::signal::ctrl_c().await {
panic!("Error waiting for Ctrl+C signal: {e:?}");
}
println!("Shutting down server...");

// Stop the balance tracker task
Expand All @@ -200,11 +202,15 @@ async fn main() -> Result<(), KoraError> {
}

// Stop the RPC server
rpc_handle.stop().unwrap();
if let Err(e) = rpc_handle.stop() {
panic!("Error stopping RPC server: {e:?}");
}

// Stop the metrics server if running
if let Some(handle) = metrics_handle {
handle.stop().unwrap();
if let Err(e) = handle.stop() {
panic!("Error stopping metrics server: {e:?}");
}
}
}
RpcCommands::InitializeAtas {
Expand Down
2 changes: 1 addition & 1 deletion crates/lib/src/cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ impl CacheUtil {
let config = get_config()?;

let pool = if CacheUtil::is_cache_enabled() {
let redis_url = config.kora.cache.url.as_ref().unwrap();
let redis_url = config.kora.cache.url.as_ref().ok_or(KoraError::ConfigError)?;

let cfg = deadpool_redis::Config::from_url(redis_url);
let pool = cfg.create_pool(Some(Runtime::Tokio1)).map_err(|e| {
Expand Down
3 changes: 3 additions & 0 deletions crates/lib/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ pub enum KoraError {

#[error("Usage limit exceeded: {0}")]
UsageLimitExceeded(String),

#[error("Invalid configuration for Kora")]
ConfigError,
}

impl From<ClientError> for KoraError {
Expand Down
Loading