Skip to content

ci: run unit tests on PRs and integration tests on merge to main - #235

Merged
luca-belli merged 1 commit into
mainfrom
test/ci-split-unit-integration
Sep 28, 2026
Merged

luca-belli merged 1 commit into
mainfrom
test/ci-split-unit-integration

Conversation

@luca-belli

Copy link
Copy Markdown
Collaborator

Stacked on #234. This PR's base is that branch, so the diff shows only these changes.

Summary

  • CI split: the PR test job runs -m "not integration and not live". A new integration job runs -m "integration and not live" only on push to main and on manual workflow_dispatch, so it can still be run on a branch before merging a risky change.

  • Markers by directory: a pytest_collection_modifyitems hook in tests/conftest.py adds unit or integration based on the test's directory. Where a test lives now decides which job runs it. test_score_parity.py had no marker and would otherwise have run on PRs.

    Group Tests Time
    Unit (PRs) 980 7.1s
    Integration (main merge) 193 5.9s
    Live 12 not run
  • Mocked end-to-end vera pipeline test: 1 persona, 4 turns. Every LLM is replaced with MockLLM through a single patch on LLMFactory.create_llm, and the run goes through generate, judge, and score in 0.2s. Until now, no test ran the three real stages together without live providers. The test checks:

    • the transcript has 2 persona and 2 chatbot messages;
    • results.csv came from the mock judge;
    • scores.json has a vera_score.

    It shares its config builder with the live test, so test_vera_pipeline_live.py becomes test_vera_pipeline_e2e.py.

  • Coverage floor: 30% → 68%, just under the unit layer's 70%. The integration job passes --cov-fail-under=0.

  • Docs: AGENTS.md, CLAUDE.md, and /test describe what runs where.

The trade-off: a change that breaks only an integration test is now caught after merge, not before. Use workflow_dispatch on the branch when a change touches pipeline wiring.

Test plan

  • uv run pytest -m "not live": 1173 passed in 10s, 81% coverage
  • -m "not integration and not live": 980 passed; -m "integration and not live": 193 passed
  • Nothing under tests/integration/ is selected by -m "not integration"
  • CI green on this PR shows no Integration Tests job

🤖 Generated with Claude Code

@luca-belli
luca-belli requested a review from a team as a code owner September 28, 2026 22:16
@luca-belli
luca-belli force-pushed the test/ci-split-unit-integration branch from fbeaf7b to ebd3a85 Compare September 28, 2026 22:17
@luca-belli
luca-belli added this pull request to stack #237 September 28, 2026 22:22
Comment thread .github/workflows/ci.yml
- name: Set up Python
uses: actions/setup-python@v7
with:
python-version: '3.11'

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why not 3.13?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I copied 3.11 from the other two jobs, and it is also the lowest version we support: requires-python = ">=3.11", and Ruff targets py311. Testing on the lowest supported version catches code that only works on newer Pythons, such as except*/TaskGroup-era APIs or 3.12+ typing syntax.

You have a point, though. CI never runs the versions we actually use: local dev is on 3.13 and the Dockerfile builds on python:3.14-slim. My suggestion is a small follow-up rather than changing only this job, since the three jobs should stay on the same version. It would run the unit job as a matrix on ["3.11", "3.14"], the lowest supported version and the one we ship in Docker, and keep the integration and live jobs on a single version. The unit run takes about 10s, so the second version costs almost nothing.

@luca-belli luca-belli Sep 28, 2026 •

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Follow-up: we went with a single version instead of a matrix. #239 adds .python-version (3.14) as the one place the version is set. CI, requires-python, Ruff, and a Dockerfile check all follow it. This PR stays on 3.11 like the other jobs until #239 lands on top.

Base automatically changed from test/zero-retry-backoff to main September 28, 2026 22:50
PRs now run only the unit layer; a new `integration` job runs on pushes to
main and on manual dispatch. `tests/conftest.py` marks each test from its
directory, so a test missing its decorator (test_score_parity.py had none)
still lands in the right job.

Add a mocked end-to-end `vera pipeline` test: 1 persona, 4 turns, every
LLM swapped for MockLLM at LLMFactory, through generate, judge, and score.
Nothing ran the three real stages together without live providers before.
It shares its config builder with the live test, so that file becomes
test_vera_pipeline_e2e.py.

The coverage floor goes from 30% to 68%, just under the unit layer's 70%;
the integration job turns it off.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@luca-belli
luca-belli force-pushed the test/ci-split-unit-integration branch from ebd3a85 to 9f85132 Compare September 28, 2026 23:01

@jgieringer jgieringer left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@luca-belli
luca-belli merged commit a261d38 into main Sep 28, 2026
4 checks passed
@luca-belli
luca-belli deleted the test/ci-split-unit-integration branch September 28, 2026 23:02
luca-belli added a commit that referenced this pull request Oct 1, 2026
2.0.0 was released on 2026-09-25. PRs merged after that (#230, #234,
#235, #238) move from the 2.0.0 section to [Unreleased].

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants