Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ updates:
- "requests"
optional-dependencies:
patterns:
- "pypdfium2"
- "bernard_ledit"
- "Pillow"
test-dependencies:
patterns:
Expand Down
89 changes: 89 additions & 0 deletions .github/workflows/_build-bernard-ledit.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
name: Build bernard-ledit Wheel

on:
workflow_call:
workflow_dispatch:

permissions:
contents: read

jobs:
build-wheel:
name: Build bernard-ledit wheel
timeout-minutes: 30
strategy:
fail-fast: false
matrix:
os:
- "ubuntu-22.04"
- "windows-2022"
- "macos-latest"
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v6
with:
submodules: recursive

- name: Set up Python 3.10
uses: actions/setup-python@v6
with:
python-version: "3.10"

- name: Resolve bernard-ledit submodule commit
id: bernard
shell: bash
run: echo "sha=$(git -C bernard-ledit rev-parse HEAD)" >> "$GITHUB_OUTPUT"

# Skip the whole Rust/maturin build when the submodule pointer is unchanged.
- name: Restore cached bernard-ledit build
id: cache
uses: actions/cache@v5
with:
path: ./.github/artifacts/bernard-ledit
key: bernard-ledit-${{ runner.os }}-${{ steps.bernard.outputs.sha }}

- name: Cache downloaded PDFium binary
if: steps.cache.outputs.cache-hit != 'true'
uses: actions/cache@v5
with:
path: bernard-ledit/core/.pdfium_cache
key: pdfium-${{ runner.os }}-${{ hashFiles('bernard-ledit/core/build.rs') }}
restore-keys: |
pdfium-${{ runner.os }}-

- name: Cache Rust build
if: steps.cache.outputs.cache-hit != 'true'
uses: Swatinem/rust-cache@v2
with:
workspaces: bernard-ledit
key: ${{ steps.bernard.outputs.sha }}

- name: Build bernard-ledit wheel
if: steps.cache.outputs.cache-hit != 'true'
shell: bash
run: |
python -m pip install --upgrade pip
pip wheel --no-deps --wheel-dir ./.github/artifacts/bernard-ledit bernard-ledit/bindings/python/

# The wheel does not embed PDFium; ship the library so consumers can set PDFIUM_PATH.
- name: Collect bundled PDFium library
if: steps.cache.outputs.cache-hit != 'true'
shell: bash
run: |
lib=$(find bernard-ledit/core/.pdfium_cache \( -name 'libpdfium.*' -o -name 'pdfium.dll' \) -print | head -n 1)
if [ -z "$lib" ]; then
echo "::error::PDFium library not found under bernard-ledit/core/.pdfium_cache after build"
exit 1
fi
cp "$lib" ./.github/artifacts/bernard-ledit/
echo "Bundled PDFium library: $(basename "$lib")"

- name: Upload bernard-ledit build
uses: actions/upload-artifact@v4
with:
name: bernard-ledit-wheel-${{ runner.os }}
path: |
./.github/artifacts/bernard-ledit/*.whl
./.github/artifacts/bernard-ledit/libpdfium.*
./.github/artifacts/bernard-ledit/pdfium.dll
if-no-files-found: error
16 changes: 16 additions & 0 deletions .github/workflows/_smoke-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,25 @@ jobs:
restore-keys: |
${{ runner.os }}-samples-

- name: Download prebuilt bernard-ledit wheel
uses: actions/download-artifact@v5
continue-on-error: true
with:
name: bernard-ledit-wheel-${{ runner.os }}
path: ./.github/artifacts/bernard-ledit

- name: Locate bundled PDFium
shell: bash
run: |
lib=$(find .github/artifacts/bernard-ledit \( -name 'libpdfium.*' -o -name 'pdfium.dll' \) -print 2>/dev/null | head -n 1)
if [ -n "$lib" ]; then
echo "PDFIUM_PATH=$(python -c 'import os,sys;print(os.path.abspath(sys.argv[1]))' "$lib")" >> "$GITHUB_ENV"
fi

- name: Install dependencies
run: |
python -m pip install pip
python -c "from pathlib import Path; import subprocess, sys; wheels = sorted(Path('.github/artifacts/bernard-ledit').glob('*.whl')); subprocess.check_call([sys.executable, '-m', 'pip', 'install', str(wheels[0]) if wheels else 'bernard-ledit/bindings/python/'])"
pip install -e '.'

- name: Tests v2 sample code
Expand Down
22 changes: 22 additions & 0 deletions .github/workflows/_static-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ jobs:
python-version: ["3.12"]
steps:
- uses: actions/checkout@v6
with:
submodules: recursive

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v6
Expand All @@ -29,10 +31,26 @@ jobs:
restore-keys: |
${{ runner.os }}-lint-

- name: Download prebuilt bernard-ledit wheel
uses: actions/download-artifact@v5
continue-on-error: true
with:
name: bernard-ledit-wheel-${{ runner.os }}
path: ./.github/artifacts/bernard-ledit

- name: Locate bundled PDFium
shell: bash
run: |
lib=$(find .github/artifacts/bernard-ledit \( -name 'libpdfium.*' -o -name 'pdfium.dll' \) -print 2>/dev/null | head -n 1)
if [ -n "$lib" ]; then
echo "PDFIUM_PATH=$(python -c 'import os,sys;print(os.path.abspath(sys.argv[1]))' "$lib")" >> "$GITHUB_ENV"
fi

- name: Install dependencies
run: |
python -m pip install pip
pip install pylic~=3.6.1
python -c "from pathlib import Path; import subprocess, sys; wheels = sorted(Path('.github/artifacts/bernard-ledit').glob('*.whl')); subprocess.check_call([sys.executable, '-m', 'pip', 'install', str(wheels[0]) if wheels else 'bernard-ledit/bindings/python/'])"
pip install -e '.'

- name: License check
Expand All @@ -43,6 +61,10 @@ jobs:
run: |
pip install -e '.[lint]'

- name: Audit dependencies
run: |
pip-audit --local --skip-editable

- name: Cache pre-commit
uses: actions/cache@v5
with:
Expand Down
16 changes: 16 additions & 0 deletions .github/workflows/_test-cli.yml
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,25 @@ jobs:
restore-keys: |
${{ runner.os }}-cli-

- name: Download prebuilt bernard-ledit wheel
uses: actions/download-artifact@v5
continue-on-error: true
with:
name: bernard-ledit-wheel-${{ runner.os }}
path: ./.github/artifacts/bernard-ledit

- name: Locate bundled PDFium
shell: bash
run: |
lib=$(find .github/artifacts/bernard-ledit \( -name 'libpdfium.*' -o -name 'pdfium.dll' \) -print 2>/dev/null | head -n 1)
if [ -n "$lib" ]; then
echo "PDFIUM_PATH=$(python -c 'import os,sys;print(os.path.abspath(sys.argv[1]))' "$lib")" >> "$GITHUB_ENV"
fi

- name: Install dependencies
run: |
python -m pip install pip
python -c "from pathlib import Path; import subprocess, sys; wheels = sorted(Path('.github/artifacts/bernard-ledit').glob('*.whl')); subprocess.check_call([sys.executable, '-m', 'pip', 'install', str(wheels[0]) if wheels else 'bernard-ledit/bindings/python/'])"
pip install -e '.'

- name: Test V1 CLI
Expand Down
18 changes: 17 additions & 1 deletion .github/workflows/_test-integrations.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,25 @@ jobs:
restore-keys: |
${{ runner.os }}-test-

- name: Download prebuilt bernard-ledit wheel
uses: actions/download-artifact@v5
continue-on-error: true
with:
name: bernard-ledit-wheel-${{ runner.os }}
path: ./.github/artifacts/bernard-ledit

- name: Locate bundled PDFium
shell: bash
run: |
lib=$(find .github/artifacts/bernard-ledit \( -name 'libpdfium.*' -o -name 'pdfium.dll' \) -print 2>/dev/null | head -n 1)
if [ -n "$lib" ]; then
echo "PDFIUM_PATH=$(python -c 'import os,sys;print(os.path.abspath(sys.argv[1]))' "$lib")" >> "$GITHUB_ENV"
fi

- name: Install dependencies
run: |
python -m pip install pip
python -c "from pathlib import Path; import subprocess, sys; wheels = sorted(Path('.github/artifacts/bernard-ledit').glob('*.whl')); subprocess.check_call([sys.executable, '-m', 'pip', 'install', str(wheels[0]) if wheels else 'bernard-ledit/bindings/python/'])"
pip install -e '.[test]'
- name: Run Integration Testing
env:
Expand Down Expand Up @@ -116,4 +132,4 @@ jobs:
MINDEE_V2_SE_TESTS_SPLIT_MODEL_ID: ${{ secrets.MINDEE_V2_SE_TESTS_SPLIT_MODEL_ID }}
MINDEE_V2_SE_TESTS_OCR_MODEL_ID: ${{ secrets.MINDEE_V2_SE_TESTS_OCR_MODEL_ID }}
run: |
pytest -m "integration and not pypdfium2 and not pillow"
pytest -m "integration and not bernard_ledit and not pillow"
16 changes: 16 additions & 0 deletions .github/workflows/_test-regressions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,25 @@ jobs:
restore-keys: |
${{ runner.os }}-test-

- name: Download prebuilt bernard-ledit wheel
uses: actions/download-artifact@v5
continue-on-error: true
with:
name: bernard-ledit-wheel-${{ runner.os }}
path: ./.github/artifacts/bernard-ledit

- name: Locate bundled PDFium
shell: bash
run: |
lib=$(find .github/artifacts/bernard-ledit \( -name 'libpdfium.*' -o -name 'pdfium.dll' \) -print 2>/dev/null | head -n 1)
if [ -n "$lib" ]; then
echo "PDFIUM_PATH=$(python -c 'import os,sys;print(os.path.abspath(sys.argv[1]))' "$lib")" >> "$GITHUB_ENV"
fi

- name: Install dependencies
run: |
python -m pip install pip
python -c "from pathlib import Path; import subprocess, sys; wheels = sorted(Path('.github/artifacts/bernard-ledit').glob('*.whl')); subprocess.check_call([sys.executable, '-m', 'pip', 'install', str(wheels[0]) if wheels else 'bernard-ledit/bindings/python/'])"
pip install -e '.[test]'
- name: Run Regression Testing
env:
Expand Down
19 changes: 18 additions & 1 deletion .github/workflows/_test-units.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ jobs:
os:
- "ubuntu-22.04"
- "windows-2022"
- "macos-latest"
python-version:
- "3.10"
- "3.11"
Expand All @@ -40,9 +41,25 @@ jobs:
restore-keys: |
${{ runner.os }}-test-

- name: Download prebuilt bernard-ledit wheel
uses: actions/download-artifact@v5
continue-on-error: true
with:
name: bernard-ledit-wheel-${{ runner.os }}
path: ./.github/artifacts/bernard-ledit

- name: Locate bundled PDFium
shell: bash
run: |
lib=$(find .github/artifacts/bernard-ledit \( -name 'libpdfium.*' -o -name 'pdfium.dll' \) -print 2>/dev/null | head -n 1)
if [ -n "$lib" ]; then
echo "PDFIUM_PATH=$(python -c 'import os,sys;print(os.path.abspath(sys.argv[1]))' "$lib")" >> "$GITHUB_ENV"
fi

- name: Install dependencies
run: |
python -m pip install pip
python -c "from pathlib import Path; import subprocess, sys; wheels = sorted(Path('.github/artifacts/bernard-ledit').glob('*.whl')); subprocess.check_call([sys.executable, '-m', 'pip', 'install', str(wheels[0]) if wheels else 'bernard-ledit/bindings/python/'])"
pip install -e '.[test]'

- name: Unit testing with pytest
Expand All @@ -57,6 +74,7 @@ jobs:
os:
- "ubuntu-22.04"
- "windows-2022"
- "macos-latest"
python-version:
- "3.10"
- "3.11"
Expand Down Expand Up @@ -92,4 +110,3 @@ jobs:
- name: Unit testing with pytest
run: |
pytest

5 changes: 5 additions & 0 deletions .github/workflows/cron.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,17 @@ permissions:
actions: read

jobs:
build-bernard-ledit:
uses: mindee/mindee-api-python/.github/workflows/_build-bernard-ledit.yml@main
test-regressions:
uses: mindee/mindee-api-python/.github/workflows/_test-regressions.yml@main
needs: build-bernard-ledit
secrets: inherit
test-code-samples:
uses: mindee/mindee-api-python/.github/workflows/_smoke-test.yml@main
needs: build-bernard-ledit
secrets: inherit
test-cli:
uses: mindee/mindee-api-python/.github/workflows/_test-cli.yml@main
needs: build-bernard-ledit
secrets: inherit
8 changes: 6 additions & 2 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,16 @@ permissions:
jobs:
workflow-lint:
uses: ./.github/workflows/_workflow_lint.yml
build-bernard-ledit:
uses: ./.github/workflows/_build-bernard-ledit.yml
static-analysis:
uses: ./.github/workflows/_static-analysis.yml
needs: workflow-lint
needs:
- workflow-lint
- build-bernard-ledit
test-units:
uses: ./.github/workflows/_test-units.yml
needs: static-analysis
needs: build-bernard-ledit
secrets: inherit
test-regressions:
uses: ./.github/workflows/_test-regressions.yml
Expand Down
9 changes: 7 additions & 2 deletions .github/workflows/push-main-branch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,20 @@
- main

jobs:
build-bernard-ledit:
uses: mindee/mindee-api-python/.github/workflows/_build-bernard-ledit.yml@main
static-analysis:

Check warning

Code scanning / CodeQL

Workflow does not contain permissions Medium

Actions job or workflow does not limit the permissions of the GITHUB_TOKEN. Consider setting an explicit permissions block, using the following as a minimal starting point: {}
uses: mindee/mindee-api-python/.github/workflows/_static-analysis.yml@main
needs: build-bernard-ledit
test_units:
uses: mindee/mindee-api-python/.github/workflows/_test-units.yml@main
needs: static-analysis
needs: build-bernard-ledit
secrets: inherit
tag:
uses: mindee/client-lib-actions/.github/workflows/tag-version.yml@main
needs: test_units
needs:
- static-analysis
- test_units
release:
uses: mindee/client-lib-actions/.github/workflows/create-release.yml@main
needs: tag
Expand Down
4 changes: 4 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
[submodule "tests/data"]
path = tests/data
url = git@github.com:mindee/client-lib-test-data.git
[submodule "bernard-ledit"]
path = bernard-ledit
url = https://github.com/mindee/bernard-ledit.git
branch = main
8 changes: 0 additions & 8 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,14 +22,6 @@ repos:
args: [
"-j2"
]
- repo: https://github.com/pypa/pip-audit
rev: v2.10.1
hooks:
- id: pip-audit
args: ["."]
files: ^(requirements.*\.txt|setup\.cfg|setup\.py|pyproject\.toml)$
stages: [pre-push]

- repo: https://github.com/pre-commit/mirrors-mypy
rev: v2.1.0
hooks:
Expand Down
1 change: 1 addition & 0 deletions bernard-ledit
Submodule bernard-ledit added at 769d3e
Loading
Loading