chore: add minimal ci

This commit is contained in:
Clelia (Astra) Bertelli
2026-05-12 16:58:22 +02:00
parent 7bd40d338e
commit e3c182583a
5 changed files with 150 additions and 7 deletions
+112
View File
@@ -0,0 +1,112 @@
name: Rust CI
on:
pull_request:
paths:
- crates/**/*.rs
- crates/**/Cargo.toml
- Cargo.toml
env:
CARGO_TERM_COLOR: always
jobs:
clippy:
name: Clippy
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
components: clippy
- name: Cache cargo registry
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-clippy-${{ hashFiles('**/Cargo.lock') }}
- name: Run clippy
run: make lint-strict
format:
name: Format
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@stable
with:
components: rustfmt
- name: Check formatting
run: make format-check
test:
name: Test on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
rust: [stable]
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ matrix.rust }}
- name: Cache cargo registry
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-test-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-
- name: Run tests
run: make test
build:
name: Build on ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
rust: [stable]
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install Rust toolchain
uses: dtolnay/rust-toolchain@master
with:
toolchain: ${{ matrix.rust }}
- name: Cache cargo registry
uses: actions/cache@v4
with:
path: |
~/.cargo/registry
~/.cargo/git
target
key: ${{ runner.os }}-cargo-test-${{ hashFiles('**/Cargo.lock') }}
restore-keys: |
${{ runner.os }}-cargo-
- name: Run build
run: make build
+31
View File
@@ -0,0 +1,31 @@
.PHONY: test lint lint-strict format format-check build
all: test lint format
test:
$(info ****************** running tests ******************)
cargo test --all
lint-strict:
$(info ****************** running clippy in strict mode ******************)
cargo clippy --all-targets --all-features -- -D warnings # treat warnings as errors
lint:
$(info ****************** running clippy in strict mode ******************)
cargo clippy --all-targets --all-features
lint-fix:
$(info ****************** running clippy in strict mode ******************)
cargo clippy --fix --allow-dirty --all-targets --all-features
format:
$(info ****************** formatting ******************)
cargo fmt --all
format-check:
$(info ****************** checking formatting ******************)
cargo fmt --all --check
build:
$(info ****************** building ******************)
cargo build
+5 -5
View File
@@ -49,21 +49,21 @@ impl HttpOcrEngine {
let result = self.recognize(i, 0, 0, &options)?;
results.push(result);
}
return Ok(results);
Ok(results)
}
}
impl OcrEngine for HttpOcrEngine {
fn name(&self) -> &str {
return &self.name;
&self.name
}
fn recognize<'a, 'b>(
fn recognize(
&self,
image_data: &'a [u8],
image_data: &[u8],
_width: u32,
_height: u32,
options: &'b OcrOptions,
options: &OcrOptions,
) -> Result<Vec<OcrResult>, Box<dyn std::error::Error>> {
let client = Client::new();
let form = Form::new()
+1 -1
View File
@@ -11,7 +11,7 @@ pub fn ocr_and_merge_pages(
pages: &mut [Page],
pdf_path: &str,
dpi: f32,
ocr_engine: &Box<dyn OcrEngine>,
ocr_engine: &dyn OcrEngine,
ocr_language: &str,
) -> Result<(), Box<dyn std::error::Error>> {
let lib = Library::init();
+1 -1
View File
@@ -82,7 +82,7 @@ impl LiteParse {
&mut pages,
&pdf_path,
self.config.dpi,
&engine,
engine.as_ref(),
&self.config.ocr_language,
)?;
}