Skip to content

Conversation

@AnthonyRonning
Copy link
Contributor

@AnthonyRonning AnthonyRonning commented Jan 23, 2026

Adds Rust unit tests for pdf extraction + TTS text helpers, and adds a GitHub Actions workflow to run on PRs and master.


Open with Devin

Summary by CodeRabbit

  • Tests

    • Extended unit test coverage for document extraction and text-to-speech utilities, adding cases for supported/unsupported formats, invalid input, encoding errors, text preprocessing, chunking, and formatting.
  • Chores

    • Added a CI workflow to run Rust unit tests with caching for faster runs.
    • Updated local pre-commit hooks and setup script to conditionally run Rust tests when relevant files are staged.

✏️ Tip: You can customize this high-level summary in your review settings.

@coderabbitai
Copy link

coderabbitai bot commented Jan 23, 2026

📝 Walkthrough

Walkthrough

Adds a GitHub Actions workflow to run Rust unit tests, introduces unit tests for PDF extraction and TTS in the frontend/src-tauri crate, and updates repository pre-commit hooks and setup scripts to conditionally run those Rust tests before commits.

Changes

Cohort / File(s) Summary
CI: Rust test workflow
.github/workflows/rust-tests.yml
New GitHub Actions workflow triggered on pushes/PRs to master; uses an 8-core Ubuntu runner, installs Rust stable, configures and caches sccache, installs Linux deps, runs cargo test --all-targets in frontend/src-tauri, and prints sccache stats.
Pre-commit hooks
.githooks/pre-commit, setup-hooks.sh
Adds a conditional step to run cargo test --all-targets inside frontend/src-tauri when staged Rust/Tauri files are present; updates setup-hooks messaging to include this step.
PDF extractor tests
frontend/src-tauri/src/pdf_extractor.rs
Adds #[cfg(test)] unit tests for extract_document_content: success for text/plain, unsupported MIME error, invalid base64 error, and invalid UTF‑8 decoding error.
TTS module tests
frontend/src-tauri/src/tts.rs
Adds #[cfg(test)] unit tests for bytes_to_hex, preprocess_text (markdown/emoji stripping and punctuation handling), and chunk_text (word-boundary chunking and empty input).

Sequence Diagram(s)

(Skipped — changes are CI/hooks and unit tests without a multi-component runtime control flow that benefits from a sequence diagram.)

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

Poem

🐰 I nibble lines and run the test,
PDFs and TTS put to quest,
Actions wake on cores of eight,
sccache hums to speed the state,
A little rabbit hops — success!

🚥 Pre-merge checks | ✅ 2
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The pull request title accurately summarizes the main changes: adding Rust unit tests and a CI workflow, which are the primary objectives reflected in all modified files.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link

@devin-ai-integration devin-ai-integration bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 4 additional flags.

Open in Devin Review

@greptile-apps
Copy link
Contributor

greptile-apps bot commented Jan 23, 2026

Greptile Overview

Greptile Summary

This PR adds comprehensive Rust unit tests for PDF extraction and TTS text processing utilities, and establishes CI infrastructure to run these tests automatically.

Changes:

  • Added 4 unit tests for pdf_extractor.rs covering text extraction success, unsupported file types, invalid base64, and invalid UTF-8
  • Added 5 unit tests for tts.rs covering bytes_to_hex, preprocess_text, and chunk_text helper functions
  • Created GitHub Actions workflow (.github/workflows/rust-tests.yml) with sccache caching for faster builds
  • Updated pre-commit hook to conditionally run Rust tests when Rust/Tauri files are staged
  • Updated setup instructions to document the new Rust testing step

Testing:
The tests follow best practices using assertions instead of manual exit calls, properly test edge cases, and provide good error messages.

Confidence Score: 5/5

  • This PR is safe to merge with minimal risk
  • All changes are additive (only tests and CI configuration), follow Rust best practices with proper assertions, include comprehensive error case coverage, and won't affect production code behavior
  • No files require special attention

Important Files Changed

Filename Overview
frontend/src-tauri/src/pdf_extractor.rs Added comprehensive unit tests for document extraction including success cases, error handling for unsupported file types, invalid base64, and invalid UTF-8
frontend/src-tauri/src/tts.rs Added unit tests for text preprocessing utilities (bytes_to_hex, preprocess_text, chunk_text) with proper edge case coverage
.github/workflows/rust-tests.yml Added CI workflow for Rust tests with sccache optimization, runs on PRs and master branch pushes
.githooks/pre-commit Added conditional Rust test execution in pre-commit hook, only runs when Rust/Tauri files are staged
setup-hooks.sh Updated documentation to reflect new Rust testing step in pre-commit workflow

Sequence Diagram

sequenceDiagram
    participant Dev as Developer
    participant Git as Git Hook
    participant CI as GitHub Actions
    participant Tests as Rust Tests
    
    Dev->>Git: git commit (with Rust files)
    Git->>Git: Check staged files
    alt Rust files staged
        Git->>Tests: cargo test --all-targets
        Tests-->>Git: Test results
        alt Tests pass
            Git->>Dev: Commit allowed
        else Tests fail
            Git->>Dev: Commit blocked
        end
    else No Rust files
        Git->>Dev: Skip Rust tests
    end
    
    Dev->>CI: git push / create PR
    CI->>CI: Install Rust & dependencies
    CI->>CI: Configure sccache
    CI->>Tests: cargo test --all-targets
    Tests-->>CI: Test results
    CI->>Dev: CI status (pass/fail)
Loading

@cloudflare-workers-and-pages
Copy link

cloudflare-workers-and-pages bot commented Jan 23, 2026

Deploying maple with  Cloudflare Pages  Cloudflare Pages

Latest commit: 92ecada
Status: ✅  Deploy successful!
Preview URL: https://bcbbcbf6.maple-ca8.pages.dev
Branch Preview URL: https://chore-rust-unit-tests.maple-ca8.pages.dev

View logs

Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In @.githooks/pre-commit:
- Around line 28-41: The current staged-file pattern (used in the STAGED_FILES
check with grep -Eq) only matches src/*.rs, build.rs and Cargo files and misses
Rust files in tests/, benches/, and examples/; update the grep pattern to match
any Rust-related file under frontend/src-tauri (for example change the regex
used in grep -Eq to match ^frontend/src-tauri/.*\.(rs|toml|lock)$ or explicitly
include directories like tests|benches|examples) so that when STAGED_FILES
contains changes in tests/, benches/, examples/, build.rs, Cargo.toml,
Cargo.lock or any .rs file anywhere under frontend/src-tauri the hook runs cargo
test --all-targets. Ensure the updated pattern is applied where grep -Eq is
invoked so SKIPPED cases are avoided for those directories.

Adds Rust unit tests for src-tauri and runs them in CI (and in pre-commit when relevant files are staged).

Co-authored-by: factory-droid[bot] <138933559+factory-droid[bot]@users.noreply.github.com>
Copy link

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In @.github/workflows/rust-tests.yml:
- Around line 48-51: The three environment writes use unquoted $GITHUB_ENV and
separate redirects; change to write all lines in one grouped block redirected to
the quoted variable to avoid SC2086/SC2129. Locate the run step that echoes
RUSTC_WRAPPER, SCCACHE_DIR and SCCACHE_CACHE_SIZE and replace the three
individual echo ... >> $GITHUB_ENV statements with a grouped command (e.g., {
echo "RUSTC_WRAPPER=..."; echo "SCCACHE_DIR=..."; echo "SCCACHE_CACHE_SIZE=...";
} >> "$GITHUB_ENV") so $GITHUB_ENV is quoted and the redirect is only applied
once.

Comment on lines +48 to +51
run: |
echo "RUSTC_WRAPPER=sccache" >> $GITHUB_ENV
echo "SCCACHE_DIR=$HOME/.cache/sccache" >> $GITHUB_ENV
echo "SCCACHE_CACHE_SIZE=2G" >> $GITHUB_ENV
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Quote $GITHUB_ENV and group the redirects.
Avoids shellcheck SC2086/SC2129 and makes the step safer.

🛠 Suggested fix
-        run: |
-          echo "RUSTC_WRAPPER=sccache" >> $GITHUB_ENV
-          echo "SCCACHE_DIR=$HOME/.cache/sccache" >> $GITHUB_ENV
-          echo "SCCACHE_CACHE_SIZE=2G" >> $GITHUB_ENV
+        run: |
+          {
+            echo "RUSTC_WRAPPER=sccache"
+            echo "SCCACHE_DIR=$HOME/.cache/sccache"
+            echo "SCCACHE_CACHE_SIZE=2G"
+          } >> "$GITHUB_ENV"
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
run: |
echo "RUSTC_WRAPPER=sccache" >> $GITHUB_ENV
echo "SCCACHE_DIR=$HOME/.cache/sccache" >> $GITHUB_ENV
echo "SCCACHE_CACHE_SIZE=2G" >> $GITHUB_ENV
run: |
{
echo "RUSTC_WRAPPER=sccache"
echo "SCCACHE_DIR=$HOME/.cache/sccache"
echo "SCCACHE_CACHE_SIZE=2G"
} >> "$GITHUB_ENV"
🧰 Tools
🪛 actionlint (1.7.10)

48-48: shellcheck reported issue in this script: SC2086:info:1:33: Double quote to prevent globbing and word splitting

(shellcheck)


48-48: shellcheck reported issue in this script: SC2086:info:2:44: Double quote to prevent globbing and word splitting

(shellcheck)


48-48: shellcheck reported issue in this script: SC2086:info:3:33: Double quote to prevent globbing and word splitting

(shellcheck)


48-48: shellcheck reported issue in this script: SC2129:style:1:1: Consider using { cmd1; cmd2; } >> file instead of individual redirects

(shellcheck)

🤖 Prompt for AI Agents
In @.github/workflows/rust-tests.yml around lines 48 - 51, The three environment
writes use unquoted $GITHUB_ENV and separate redirects; change to write all
lines in one grouped block redirected to the quoted variable to avoid
SC2086/SC2129. Locate the run step that echoes RUSTC_WRAPPER, SCCACHE_DIR and
SCCACHE_CACHE_SIZE and replace the three individual echo ... >> $GITHUB_ENV
statements with a grouped command (e.g., { echo "RUSTC_WRAPPER=..."; echo
"SCCACHE_DIR=..."; echo "SCCACHE_CACHE_SIZE=..."; } >> "$GITHUB_ENV") so
$GITHUB_ENV is quoted and the redirect is only applied once.

@AnthonyRonning AnthonyRonning merged commit 164a1db into master Jan 23, 2026
11 checks passed
@AnthonyRonning AnthonyRonning deleted the chore/rust-unit-tests branch January 23, 2026 16:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants