Skip to content

ci: run Python tests on every PR (closes #22)#45

Open
iliassjabali wants to merge 5 commits intomainfrom
ci/add-python-tests
Open

ci: run Python tests on every PR (closes #22)#45
iliassjabali wants to merge 5 commits intomainfrom
ci/add-python-tests

Conversation

@iliassjabali
Copy link
Copy Markdown
Collaborator

@iliassjabali iliassjabali commented Apr 11, 2026

Closes #22

Re-opens #42 from a properly named branch (ci/add-python-tests instead of the auto-generated tender-ritchie).

Summary

  • Adds a python-changes detector job using dorny/paths-filter@v3 that emits a JSON array of Python packages touched in the PR. On push: main it always emits all four as a safety net.
  • Adds a python-tests matrix job that runs pytest for each changed package. Uses actions/setup-python@v5 with cache: pip keyed per package, picks per-package install commands via a small case statement, and runs with fail-fast: false so each package reports independently.
  • Updates ci-success to depend on both new jobs via a fail_if_not_ok helper that treats skipped as acceptable, so TS-only PRs still pass the gate.
  • Includes a small bug fix in packages/control-plane/api/heartbeat.py: the rate limiter used 0.0 as the never-seen sentinel, which causes false 429s on hosts where time.monotonic() is small (freshly-booted CI runners, or when tests monkeypatch RATE_LIMIT_SECONDS=1000). Switched to a None sentinel. This was a latent bug exposed by enabling the previously-unrun heartbeat tests in CI.

This wires the existing 282 Python tests (control-plane 109, operator 178, sdk-langgraph 123, sdk-python 7) into CI without adding weight to PRs that don't touch Python.

CI weight

  • TS-only PR: only the tiny python-changes job runs (~7s), python-tests is skipped.
  • Python PR: only the affected package legs run, in parallel, with pip cache hits on unchanged deps.
  • push: main: all 4 legs run unconditionally.

Test plan

  • PR triggers python-changes and the matching python-tests legs (this PR touches .github/workflows/ci.yml, so all 4 run).
  • All 4 Python matrix legs are green.
  • CI gate is green and lists python-tests as a required dependency.
  • After merge, push: main runs all 4 legs and stays green.

Adds python-changes detector + python-tests matrix job to ci.yml so the
282 Python tests across control-plane, operator, sdk-langgraph, and
sdk-python run on every PR that touches them and on every push to main.

- dorny/paths-filter scopes runs to changed packages on PRs
- push: main always runs all 4 packages as a safety net
- actions/setup-python pip cache keyed per package
- ci-success gate depends on both jobs and treats skipped as ok

Closes #22
…ting bug

The previous version inlined ${{ steps.filter.outputs.changes }} directly
inside a double-quoted echo, so the JSON array's double quotes broke shell
parsing and the python-tests matrix failed to materialize. Pass the value
through an env var instead.
test_sidecar_client.py imports the real httpx (not mocked), which lives
in the 'opa' extra. Switch to a per-package case so each package gets
exactly the deps its tests need.
The rate-limit window used 0.0 as the 'never seen' sentinel, so on a host
where time.monotonic() is small (freshly-booted CI runner, or under a
monkeypatched RATE_LIMIT_SECONDS=1000 in tests), the first heartbeat for
a brand-new agent could be incorrectly rate-limited. Switch to a None
sentinel so the absence of a prior timestamp always allows the request.

Discovered when wiring tests/test_heartbeat.py::test_heartbeat_rate_limit_returns_429
into CI (issue #22).
Sets FORCE_JAVASCRIPT_ACTIONS_TO_NODE24=true at the workflow level so the
13 'Node.js 20 actions are deprecated' warnings disappear ahead of the
June 2026 default switch, without bumping any action versions.

https://github.blog/changelog/2025-09-19-deprecation-of-node-20-on-github-actions-runners/
@iliassjabali iliassjabali self-assigned this Apr 12, 2026
@iliassjabali iliassjabali requested a review from skokaina April 12, 2026 00:29
@iliassjabali iliassjabali removed their assignment Apr 12, 2026
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.

Add Python tests to CI pipeline

1 participant