-
-
Notifications
You must be signed in to change notification settings - Fork 301
ci: add cargo tests #89
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
ad539bd
ci: add cargo tests
fffonion 06bb639
Apply suggestion from @mayocream
mayocream c10a7b7
Apply suggestion from @mayocream
mayocream 8efa1dc
Rename test.yml to build.yml
mayocream 85aa6ec
Apply suggestion from @mayocream
mayocream d22abde
Apply suggestion from @mayocream
mayocream a296375
Simplify build workflow by removing test job
mayocream 570b010
Add GitHub Actions workflow for integration tests
mayocream d218f36
Refactor lint workflow configuration
mayocream 3675905
Refactor comic_text_detector test for async usage
mayocream 6b22081
Refactor OCR test to remove unnecessary nesting
mayocream 51a1cf3
Refactor LLM test for async execution
mayocream 2524d9b
Apply suggestion from @Copilot
mayocream 5ddaa81
Refactor inpainting test for clarity and conciseness
mayocream bbdad89
Rename release-packages.yaml to release.yaml
mayocream 0e255e7
Rename publish-crates-io.yml to publish.yml
mayocream File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,32 +1,35 @@ | ||
| name: Lint | ||
|
|
||
| on: | ||
| push: | ||
| branches: ['main'] | ||
| pull_request: | ||
|
|
||
| env: | ||
| REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
|
|
||
| jobs: | ||
| lint: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| # refer: https://v2.tauri.app/start/prerequisites/#linux | ||
| - run: | | ||
| sudo apt update | ||
| sudo apt install libwebkit2gtk-4.1-dev \ | ||
| build-essential \ | ||
| curl \ | ||
| wget \ | ||
| file \ | ||
| libxdo-dev \ | ||
| libssl-dev \ | ||
| libayatana-appindicator3-dev \ | ||
| librsvg2-dev | ||
| - uses: actions/checkout@v6 | ||
| - uses: Swatinem/rust-cache@v2 | ||
| - uses: reviewdog/action-setup@v1 | ||
| - run: cargo check -q --message-format=short | reviewdog -f cargo-check -reporter=github-check | ||
| - run: cargo clippy -q --message-format=short | reviewdog -f clippy -reporter=github-check | ||
| - uses: bnjbvr/cargo-machete@main | ||
| name: Lint | ||
|
|
||
| on: | ||
| push: | ||
| branches: ['main'] | ||
| pull_request: | ||
|
|
||
| env: | ||
| CARGO_TERM_COLOR: always | ||
|
|
||
| jobs: | ||
| lint: | ||
| name: Lint | ||
| env: | ||
| REVIEWDOG_GITHUB_API_TOKEN: ${{ secrets.GITHUB_TOKEN }} | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| # refer: https://v2.tauri.app/start/prerequisites/#linux | ||
| - run: | | ||
| sudo apt update | ||
| sudo apt install libwebkit2gtk-4.1-dev \ | ||
| build-essential \ | ||
| curl \ | ||
| wget \ | ||
| file \ | ||
| libxdo-dev \ | ||
| libssl-dev \ | ||
| libayatana-appindicator3-dev \ | ||
| librsvg2-dev | ||
| - uses: actions/checkout@v6 | ||
| - uses: Swatinem/rust-cache@v2 | ||
| - uses: reviewdog/action-setup@v1 | ||
| - run: cargo check -q --message-format=short | reviewdog -f cargo-check -reporter=github-check | ||
| - run: cargo clippy -q --message-format=short | reviewdog -f clippy -reporter=github-check | ||
| - uses: bnjbvr/cargo-machete@main | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,32 @@ | ||
| name: Test | ||
|
|
||
| on: | ||
| push: | ||
| branches: ['main'] | ||
| pull_request: | ||
|
|
||
| env: | ||
| CARGO_TERM_COLOR: always | ||
|
|
||
| jobs: | ||
| test: | ||
| name: Integration tests | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| # refer: https://v2.tauri.app/start/prerequisites/#linux | ||
| - run: | | ||
| sudo apt update | ||
| sudo apt install libwebkit2gtk-4.1-dev \ | ||
| build-essential \ | ||
| curl \ | ||
| wget \ | ||
| file \ | ||
| libxdo-dev \ | ||
| libssl-dev \ | ||
| libayatana-appindicator3-dev \ | ||
| librsvg2-dev \ | ||
| fonts-noto-cjk | ||
| - uses: actions/checkout@v6 | ||
| - uses: Swatinem/rust-cache@v2 | ||
| - run: cargo test --no-run | ||
| - run: cargo test --workspace --tests |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| use std::path::Path; | ||
|
|
||
| use koharu_ml::lama::Lama; | ||
| use image::GenericImageView; | ||
|
|
||
| #[tokio::test] | ||
| async fn lama_inpainting_updates_masked_region() -> anyhow::Result<()> { | ||
| let fixtures = Path::new(env!("CARGO_MANIFEST_DIR")).join("tests/fixtures"); | ||
|
|
||
| let lama = Lama::load(false).await?; | ||
| let base = image::open(fixtures.join("image.jpg"))?; | ||
| let mask = image::open(fixtures.join("mask.png"))?; | ||
|
|
||
| let output = lama.inference(&base, &mask)?; | ||
|
|
||
| assert_eq!(output.dimensions(), base.dimensions()); | ||
|
|
||
| let mask = mask.to_luma8(); | ||
| let base = base.to_rgb8(); | ||
| let output = output.to_rgb8(); | ||
|
|
||
| let mut changed = false; | ||
| for ((mask_px, base_px), out_px) in mask | ||
| .pixels() | ||
| .zip(base.pixels()) | ||
| .zip(output.pixels()) | ||
| { | ||
| if mask_px.0[0] > 0 && base_px.0 != out_px.0 { | ||
| changed = true; | ||
| break; | ||
| } | ||
| } | ||
|
|
||
| assert!(changed, "inpainting should change at least one masked pixel"); | ||
| Ok(()) | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,29 @@ | ||
| use koharu_ml::llm::{GenerateOptions, Llm, ModelId}; | ||
| use strum::IntoEnumIterator; | ||
|
|
||
| #[tokio::test] | ||
| async fn llm_generates_text_for_all_models() -> anyhow::Result<()> { | ||
| let prompt = "こんにちは、テストです。"; | ||
|
|
||
| for model in ModelId::iter() { | ||
| let mut llm = Llm::load(model, false).await?; | ||
| let opts = GenerateOptions { | ||
| max_tokens: 32, | ||
| temperature: 0.0, | ||
| top_k: None, | ||
| top_p: None, | ||
| seed: 1, | ||
| split_prompt: false, | ||
| repeat_penalty: 1.0, | ||
| repeat_last_n: 64, | ||
| }; | ||
|
|
||
| let generated = llm.generate(prompt, &opts)?; | ||
| assert!( | ||
| !generated.trim().is_empty(), | ||
| "model {model:?} should return some text" | ||
| ); | ||
| } | ||
|
|
||
| Ok(()) | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,20 @@ | ||
| use std::path::Path; | ||
|
|
||
| use koharu_ml::manga_ocr::MangaOcr; | ||
|
|
||
| #[tokio::test] | ||
| async fn manga_ocr_reads_dialog_image() -> anyhow::Result<()> { | ||
| let fixtures = Path::new(env!("CARGO_MANIFEST_DIR")).join("tests/fixtures"); | ||
| let image = image::open(fixtures.join("dialog.jpg"))?; | ||
|
|
||
| let ocr = MangaOcr::load(false).await?; | ||
| let results = ocr.inference(&[image])?; | ||
|
|
||
| assert_eq!(results.len(), 1); | ||
| assert!( | ||
| !results[0].trim().is_empty(), | ||
| "OCR result should contain text" | ||
| ); | ||
|
|
||
| Ok(()) | ||
| } |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.