fix: run Rust tests in CI (#671)
* fix: run Rust tests in CI Fixes #670 Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * 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 <noreply@anthropic.com> * 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 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
parent
9b361f661b
commit
a033a67b13
2 changed files with 79 additions and 0 deletions
24
.github/workflows/test.yml
vendored
Normal file
24
.github/workflows/test.yml
vendored
Normal file
|
|
@ -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
|
||||||
55
src-tauri/src/managers/transcription_mock.rs
Normal file
55
src-tauri/src/managers/transcription_mock.rs
Normal file
|
|
@ -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<String>,
|
||||||
|
pub model_name: Option<String>,
|
||||||
|
pub error: Option<String>,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone)]
|
||||||
|
pub struct TranscriptionManager {
|
||||||
|
#[allow(dead_code)]
|
||||||
|
app_handle: AppHandle,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl TranscriptionManager {
|
||||||
|
pub fn new(app_handle: &AppHandle, _model_manager: Arc<ModelManager>) -> Result<Self> {
|
||||||
|
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<String> {
|
||||||
|
None
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn transcribe(&self, _audio: Vec<f32>) -> Result<String> {
|
||||||
|
Ok(String::new())
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in a new issue