feat: Add Tesseract.from_source to serve a Tesseract a separate subprocess without a container
#694
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
| name: Benchmarks | |
| on: | |
| pull_request: | |
| paths: | |
| - "tesseract_core/**" | |
| - "benchmarks/**" | |
| - ".github/workflows/benchmarks.yml" | |
| push: | |
| branches: | |
| - main | |
| concurrency: | |
| group: benchmarks-${{ github.event.pull_request.number || github.ref }} | |
| cancel-in-progress: true | |
| permissions: | |
| contents: read | |
| jobs: | |
| benchmark: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Set up Git repository | |
| uses: actions/checkout@v7 | |
| - name: Set up Python | |
| uses: actions/setup-python@v7 | |
| with: | |
| python-version: "3.13" | |
| - name: Set up uv | |
| uses: astral-sh/setup-uv@v7 | |
| with: | |
| enable-cache: true | |
| - name: Restore UV environment | |
| run: cp production.uv.lock uv.lock | |
| - name: Install package | |
| run: uv sync --extra dev --frozen | |
| - name: Run benchmarks on current commit | |
| run: | | |
| uv run --no-sync pytest benchmarks/ \ | |
| --benchmark-json current_benchmarks.json | |
| - name: Check out baseline branch | |
| if: github.event_name == 'pull_request' | |
| uses: actions/checkout@v7 | |
| with: | |
| ref: ${{ github.event.pull_request.base.ref }} | |
| path: baseline | |
| - name: Install package (baseline) | |
| if: github.event_name == 'pull_request' | |
| working-directory: baseline | |
| run: | | |
| cp production.uv.lock uv.lock 2>/dev/null || true | |
| uv sync --extra dev --frozen | |
| - name: Use PR benchmark scripts for baseline | |
| if: github.event_name == 'pull_request' | |
| working-directory: baseline | |
| run: | | |
| cp -r ../benchmarks/* benchmarks/ | |
| - name: Run benchmarks on baseline | |
| if: github.event_name == 'pull_request' | |
| id: baseline | |
| working-directory: baseline | |
| run: | | |
| rc=0 | |
| uv run --no-sync pytest benchmarks/ \ | |
| --benchmark-json baseline_benchmarks.json \ | |
| || rc=$? | |
| if [ "$rc" != "0" ]; then | |
| echo "::warning::Baseline benchmark run failed, skipping comparison" | |
| echo "has_baseline=false" >> $GITHUB_OUTPUT | |
| exit 0 | |
| fi | |
| echo "has_baseline=true" >> $GITHUB_OUTPUT | |
| # Secrets are withheld from `pull_request` runs on fork PRs, so the comment | |
| # is posted by the privileged `Benchmark Report` workflow instead. | |
| - name: Generate comparison report | |
| if: github.event_name == 'pull_request' | |
| env: | |
| PR_NUMBER: ${{ github.event.pull_request.number }} | |
| run: | | |
| baseline_flag="" | |
| if [ "${{ steps.baseline.outputs.has_baseline }}" = "true" ]; then | |
| baseline_flag="--baseline baseline/baseline_benchmarks.json" | |
| fi | |
| python benchmarks/compare_benchmarks.py \ | |
| $baseline_flag \ | |
| --current current_benchmarks.json \ | |
| --pr-number "$PR_NUMBER" \ | |
| --output benchmark_report.md | |
| - name: Upload benchmark results | |
| if: always() | |
| uses: actions/upload-artifact@v7 | |
| with: | |
| name: benchmark-results | |
| path: | | |
| current_benchmarks.json | |
| baseline/baseline_benchmarks.json | |
| benchmark_report.md | |
| if-no-files-found: ignore | |
| retention-days: 30 |