From a033a67b1390ea03b060bfe5932ffc885c3f5135 Mon Sep 17 00:00:00 2001 From: Josh Ribakoff Date: Sat, 31 Jan 2026 19:18:50 -0800 Subject: [PATCH] fix: run Rust tests in CI (#671) * fix: run Rust tests in CI Fixes #670 Co-Authored-By: Claude Opus 4.5 * fix: run Rust tests in CI Adds a separate test.yml workflow to run existing Rust unit tests. Fixes #670 Co-Authored-By: Claude Opus 4.5 * refactor: use mock TranscriptionManager in CI tests Swap to a mock adapter during CI to avoid compiling whisper/Vulkan. The mock has the same interface but no heavy dependencies. Existing tests don't exercise transcription code, so this is safe. Co-Authored-By: Claude Opus 4.5 --------- Co-authored-by: Claude Opus 4.5 --- .github/workflows/test.yml | 24 +++++++++ src-tauri/src/managers/transcription_mock.rs | 55 ++++++++++++++++++++ 2 files changed, 79 insertions(+) create mode 100644 .github/workflows/test.yml create mode 100644 src-tauri/src/managers/transcription_mock.rs diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml new file mode 100644 index 0000000..818ab3c --- /dev/null +++ b/.github/workflows/test.yml @@ -0,0 +1,24 @@ +name: "test" +on: [pull_request] + +jobs: + rust-tests: + runs-on: ubuntu-24.04 + steps: + - uses: actions/checkout@v4 + + - name: Install system dependencies + run: | + sudo apt-get update + sudo apt-get install -y libwebkit2gtk-4.1-dev libappindicator3-dev librsvg2-dev libasound2-dev libssl-dev + + - name: Use mock TranscriptionManager (CI only) + working-directory: src-tauri + run: | + # Swap to mock adapter - avoids compiling whisper/Vulkan + cp src/managers/transcription_mock.rs src/managers/transcription.rs + sed -i '/^transcribe-rs/d' Cargo.toml + + - name: Run Rust tests + working-directory: src-tauri + run: cargo test diff --git a/src-tauri/src/managers/transcription_mock.rs b/src-tauri/src/managers/transcription_mock.rs new file mode 100644 index 0000000..63c92ca --- /dev/null +++ b/src-tauri/src/managers/transcription_mock.rs @@ -0,0 +1,55 @@ +// CI-only mock TranscriptionManager - avoids whisper/Vulkan dependencies. +// This file is copied over transcription.rs during CI tests. +// Existing tests don't exercise transcription, so this is safe. + +use crate::managers::model::ModelManager; +use anyhow::Result; +use serde::Serialize; +use std::sync::Arc; +use tauri::AppHandle; + +#[derive(Clone, Debug, Serialize)] +pub struct ModelStateEvent { + pub event_type: String, + pub model_id: Option, + pub model_name: Option, + pub error: Option, +} + +#[derive(Clone)] +pub struct TranscriptionManager { + #[allow(dead_code)] + app_handle: AppHandle, +} + +impl TranscriptionManager { + pub fn new(app_handle: &AppHandle, _model_manager: Arc) -> Result { + Ok(Self { + app_handle: app_handle.clone(), + }) + } + + pub fn is_model_loaded(&self) -> bool { + false + } + + pub fn unload_model(&self) -> Result<()> { + Ok(()) + } + + pub fn maybe_unload_immediately(&self, _context: &str) {} + + pub fn load_model(&self, _model_id: &str) -> Result<()> { + Ok(()) + } + + pub fn initiate_model_load(&self) {} + + pub fn get_current_model(&self) -> Option { + None + } + + pub fn transcribe(&self, _audio: Vec) -> Result { + Ok(String::new()) + } +}