feat(benchmark): add database query benchmark infrastructure #2
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: "Benchmark" | |
| on: | |
| push: | |
| branches: [main] | |
| pull_request: | |
| branches: [main] | |
| jobs: | |
| benchmark: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v6 | |
| with: | |
| ref: ${{ github.event.workflow_run.head_branch }} | |
| token: ${{ github.actor == 'dependabot[bot]' && secrets.REPO_AND_READ_PACKAGES_PAT || secrets.XML_SUBMODULE_PAT }} | |
| submodules: "recursive" | |
| - name: Set up Python 3.14 | |
| uses: actions/setup-python@v6 | |
| with: | |
| python-version: "3.14" | |
| - name: Install dependencies | |
| run: | | |
| python -m pip install --upgrade pip | |
| pip install -e ".[sqlmodels,ahbicht,benchmark]" | |
| - name: Download baseline (if PR) | |
| id: download-baseline | |
| if: github.event_name == 'pull_request' | |
| uses: dawidd6/action-download-artifact@v6 | |
| with: | |
| name: benchmark-baseline | |
| branch: main | |
| path: .benchmarks/baseline | |
| if_no_artifact_found: warn | |
| - name: Run benchmarks | |
| run: | | |
| pytest benchmarks/ --benchmark-only --benchmark-json=benchmark-results.json | |
| - name: Compare against baseline (if PR and baseline exists) | |
| if: github.event_name == 'pull_request' | |
| run: | | |
| if [ -f ".benchmarks/baseline/benchmark-results.json" ]; then | |
| python scripts/compare_benchmarks.py .benchmarks/baseline/benchmark-results.json benchmark-results.json | |
| else | |
| echo "No baseline found. Skipping comparison (first run or expired artifact)." | |
| fi | |
| - name: Save baseline (if main) | |
| if: github.ref == 'refs/heads/main' | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: benchmark-baseline | |
| path: benchmark-results.json | |
| retention-days: 90 |