Files
PaddleOCR/.github/workflows/tests.yml
Bvicii 5cf9233040 vl 1.8 (#18444)
* Support PaddleOCR-VL 1.8
2026-12-03 13:53:21 +08:00

97 lines
3.3 KiB
YAML

name: PaddleOCR PR Tests
on:
push:
branches: ["main", "release/*"]
pull_request:
branches: ["main", "release/*"]
permissions:
contents: read
jobs:
detect-changes:
runs-on: ubuntu-latest
outputs:
docs_only: ${{ steps.detect.outputs.docs_only }}
steps:
- uses: actions/checkout@v6
with:
fetch-depth: 0
- id: detect
uses: ./.github/actions/detect-docs-only
test-pr-python:
# setup-python provides Python 3.9 on Ubuntu 24.04.
runs-on: ubuntu-24.04
needs: detect-changes
if: needs.detect-changes.outputs.docs_only != 'true'
strategy:
matrix:
python-version: ["3.9", "3.13"]
steps:
- uses: actions/checkout@v6
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v6
with:
python-version: ${{ matrix.python-version }}
- name: Cache dependencies
uses: actions/cache@v5
with:
path: |
~/.cache/pip
~/.local/lib/python${{ matrix.python-version }}/site-packages
~/.paddleocr/
key: ${{ runner.os }}-dependencies-${{ matrix.python-version }}-${{ hashFiles('**/requirements.txt', 'pyproject.toml') }}
restore-keys: |
${{ runner.os }}-dependencies-
- name: Install dependencies
env:
PADDLEX_TEST_WHEEL: ${{ vars.PADDLEX_TEST_WHEEL }}
run: |
python -m pip install --upgrade pip
pip install pytest
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
python -m pip install paddlepaddle==3.1.0 -i https://www.paddlepaddle.org.cn/packages/stable/cpu/
PADDLEX_SOURCE="${PADDLEX_TEST_WHEEL}"
if [ -z "$PADDLEX_SOURCE" ]; then
PADDLEX_SERIES=$(grep -oE 'paddlex\[[^]]+\]>=[0-9]+\.[0-9]+' pyproject.toml | head -1 | grep -oE '[0-9]+\.[0-9]+')
if [ -z "$PADDLEX_SERIES" ]; then
echo "Failed to determine PaddleX version requirement from pyproject.toml" >&2
exit 1
fi
PADDLEX_SOURCE="paddlex@git+https://github.com/PaddlePaddle/PaddleX.git@release/${PADDLEX_SERIES}"
fi
python -m pip install -e ".[all]" "$PADDLEX_SOURCE"
python -c "import paddlex; print(f'Installed paddlex version: {paddlex.__version__}')"
- name: Test with pytest
run: pytest --verbose tests/
# Aggregator: produces a single check named `test-pr` so branch protection
# (which requires the literal context `test-pr`) is satisfied. Without this,
# the matrix above only emits `test-pr (3.x)` checks and the required
# `test-pr` context never reports.
test-pr:
runs-on: ubuntu-latest
needs: [detect-changes, test-pr-python]
if: always()
steps:
- name: Verify required jobs
run: |
if [ "${{ needs.detect-changes.result }}" != "success" ]; then
echo "detect-changes did not succeed: ${{ needs.detect-changes.result }}"
exit 1
fi
if [ "${{ needs.detect-changes.outputs.docs_only }}" = "true" ]; then
echo "Docs-only change; skipping python tests."
exit 0
fi
if [ "${{ needs.test-pr-python.result }}" != "success" ]; then
echo "test-pr-python concluded with: ${{ needs.test-pr-python.result }}"
exit 1
fi
echo "All python matrix variants passed."