From 5f06086457d4922099b58b5a5987f76a50153baf Mon Sep 17 00:00:00 2001 From: Ubugeeei Date: Sun, 24 May 2026 02:21:44 +0900 Subject: [PATCH] ci(rust): run cargo clippy --deny warnings and cargo test in CI Closes #49 and #50. The rust matrix job now installs clippy alongside the stable toolchain and runs: - cargo clippy --all-targets -- -D warnings - cargo test --all-targets Also fixes the four collapsible-if lints and the too-many-arguments lint that surface with clippy 1.95 on the render crate so the new gate is green. Co-Authored-By: Claude Opus 4.7 (1M context) --- .github/workflows/ci.yml | 8 ++++++++ render/src/ffmpeg.rs | 1 + render/src/main.rs | 31 ++++++++++++++----------------- 3 files changed, 23 insertions(+), 17 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 09fef91..040e5a2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -64,6 +64,8 @@ jobs: - name: Setup Rust uses: dtolnay/rust-toolchain@stable + with: + components: clippy - name: Cache Cargo uses: actions/cache@v4 @@ -76,3 +78,9 @@ jobs: - name: Check ${{ matrix.crate }} run: cargo check --manifest-path ${{ matrix.crate }}/Cargo.toml + + - name: Clippy ${{ matrix.crate }} + run: cargo clippy --manifest-path ${{ matrix.crate }}/Cargo.toml --all-targets -- -D warnings + + - name: Test ${{ matrix.crate }} + run: cargo test --manifest-path ${{ matrix.crate }}/Cargo.toml --all-targets diff --git a/render/src/ffmpeg.rs b/render/src/ffmpeg.rs index 9249e0f..e6c5dfe 100644 --- a/render/src/ffmpeg.rs +++ b/render/src/ffmpeg.rs @@ -72,6 +72,7 @@ pub struct SegmentWriter { } impl SegmentWriter { + #[allow(clippy::too_many_arguments)] pub async fn new( output_path: &str, width: u32, diff --git a/render/src/main.rs b/render/src/main.rs index aa9870b..10914f2 100644 --- a/render/src/main.rs +++ b/render/src/main.rs @@ -126,10 +126,10 @@ fn resolve_chromium_executable() -> Option { .filter(|value| !value.is_empty()) .map(PathBuf::from); - if let Some(path) = path { - if path.is_file() { - return Some(path); - } + if let Some(path) = path + && path.is_file() + { + return Some(path); } None }) @@ -673,19 +673,16 @@ async fn main() -> Result<(), Box> { let audio_plan_url = std::env::var("RENDER_AUDIO_PLAN_URL") .unwrap_or_else(|_| backend_endpoint("render_audio_plan")); let audio_plan_client = Client::new(); - if let Ok(resp) = backend_get(&audio_plan_client, &audio_plan_url).await { - if resp.status().is_success() { - if let Ok(plan) = resp.json::().await { - if !plan.segments.is_empty() { - let input_video = working_output.clone(); - let temp_video = frame_directory.join("output.audio.mp4"); - mux_audio_plan_into_mp4(&input_video, &temp_video, &plan, total_frames, fps) - .await?; - tokio::fs::remove_file(&input_video).await.ok(); - tokio::fs::rename(&temp_video, &input_video).await?; - } - } - } + if let Ok(resp) = backend_get(&audio_plan_client, &audio_plan_url).await + && resp.status().is_success() + && let Ok(plan) = resp.json::().await + && !plan.segments.is_empty() + { + let input_video = working_output.clone(); + let temp_video = frame_directory.join("output.audio.mp4"); + mux_audio_plan_into_mp4(&input_video, &temp_video, &plan, total_frames, fps).await?; + tokio::fs::remove_file(&input_video).await.ok(); + tokio::fs::rename(&temp_video, &input_video).await?; } if is_canceled.load(Ordering::Relaxed) {