Repository navigation
Run benchmark tests in CI only when benchmark code changes - #43
Merged
Merged
Conversation
The backend CI job took about 6 minutes, 327s of it in pytest. Most of that was benchmark tests: each one that needs a scored submission spends about 3.3s running the real scorer inline in fixture setup, and the scorer parity test takes 17s. Locally the full suite is 188s; without those tests it is 14s. - conftest.py marks benchmark tests `benchmark`: every test in a test_benchmark* or test_mcp_benchmarks file, and any test using benchmark_case, case_files or run_files. New tests are marked without anyone remembering to. - One end-to-end test (upload, score, waiting for review) is also marked `benchmark_smoke`. CI runs `-m "not benchmark or benchmark_smoke"` and no longer installs tesseract, which only the parity test needs. - A new Benchmarks workflow runs the full set, with tesseract, when a PR or a push to main touches apps/benchmarks/, the scorer submodule, the benchmark tests and fixtures, or conftest.py. It can also be started by hand. It is separate from CI so it never holds up a deploy. - `make backend-test-fast` runs what CI runs. DEVELOPMENT.md and CLAUDE.md describe the split, including the gap: a change elsewhere that breaks a benchmark test is not caught. Coverage in the main CI run drops from 95% to 86%, almost all of it in apps/benchmarks/, which the Benchmarks workflow covers when that code changes.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The backend
testjob took about 6 minutes, much longer than any other job. pytest accounted for 327s of it (707 tests).Where the time went
A local
--durationsprofile of the full suite (188s):finalizeruns the real pdfredeval scorer inline (Q_CLUSTERis synchronous in tests).What changes
Marking (
backend/conftest.py): a collection hook marks testsbenchmarkif they are in atest_benchmark*ortest_mcp_benchmarksfile, or usebenchmark_case,case_filesorrun_files. That catches four tests in other files (API keys, CLI login, badges), and new tests are marked without anyone remembering to. Both markers are registered inpyproject.toml, since--strict-markersis on.Smoke test:
test_an_uploaded_submission_is_scored_and_waits_for_reviewis markedbenchmark_smoke. It covers the whole pipeline: case published, output uploaded, scored by the real scorer, waiting for review.CI runs
pytest -m "not benchmark or benchmark_smoke"(557 of 707 tests). It no longer installstesseract-ocr, which only the parity test needs; the smoke test passes with tesseract unavailable.New
Benchmarksworkflow (.github/workflows/benchmarks.yml) runspytest -m benchmark(151 tests), with tesseract installed. It runs on PRs and pushes tomainthat touch:backend/apps/benchmarks/**backend/conftest.pyIt can also be started by hand from the Actions tab. It is a separate workflow because
pathsfilters a whole workflow, and becausedeploy.ymlwaits on "CI", which this must not hold up.make backend-test-fastruns what CI runs.make backend-teststill runs everything.DEVELOPMENT.mdandCLAUDE.mddescribe the split.Trade-off
Coverage in the main CI run drops from 95% to 86%, almost all of it in
apps/benchmarks/. The Benchmarks workflow covers that code when it changes. What isn't covered: a change outside those paths that breaks a benchmark test, for example a catalog model. The docs say to runmake backend-testor start the workflow by hand in that case.Testing
make backend-test-fast: 557 passed, 150 deselected, in 14s (the full suite was 188s locally).pytest -m benchmark: 151 passed, in 2m57s.make backend-lintpasses, and the workflow YAML parses with one shared path list for both triggers.conftest.pyandbenchmarks.yml, so the Benchmarks workflow should run on it. That run is the check that the new workflow works on GitHub.