ci+test: Python quality baseline for the shared bridge (ruff + pytest), fix ActionEvent parser crash - #94
Open
EslaM-X wants to merge 1 commit into
Open
Conversation
…), fix ActionEvent parser crash The Go side of the tunnel is now tested and linted (see fabricfoundation#91/fabricfoundation#92), but the Python bridge had zero CI: no lint, no formatting, no unit tests. Any change to the shared zenoh_bridge could regress silently. This PR closes that gap with a minimal, green baseline. What lands: - pyproject.toml: ruff (E/F/I/UP/B/RUF, line-length 100, target-version py39) scoped to the pure-logic modules that are testable without a ROS 2 runtime; ROS 2 packages (isaac_sim_bridge, setup.py, launch files) and command_mapper (imports geometry_msgs) are deliberately excluded so the baseline is green today and grows as bridges land. - bridge/common/zenoh_bridge/tests/: 22 unit tests across test_action_event.py and test_utils.py. pytest imports the pure modules directly via pythonpath so the suite never pulls in ROS 2. - .github/workflows/python-quality.yml: ruff check + ruff format --check + pytest on every change touching the bridge, scripts, or pyproject.toml, with concurrency/timeout/least-privilege consistent with fabricfoundation#91/fabricfoundation#93. - Fix: parse_action_event crashed with AttributeError on valid-but-non-object JSON (lists, null, scalars) instead of honoring its documented 'Returns None on parse failure' contract. The parser now rejects any non-dict envelope. Verified locally: 22/22 tests pass, ruff check clean, ruff format --check clean. The new tests cover the parser crash with []/null/42 before and after the fix.
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.
Summary
The Go side of the tunnel is now linted and unit-tested (#91, #92) — but the Python bridge had zero CI: no lint, no formatting, no unit tests. Any change to the shared
zenoh_bridgecould regress silently. This PR closes that gap with a minimal, green baseline — and fixes a real crash the new tests exposed.What lands
pyproject.toml— ruff + pytest, scoped honestlyE/F/I/UP/B/RUF, line-length 100, target-version py39) scoped to the pure-logic modules that are importable without a ROS 2 runtime.isaac_sim_bridge,setup.py,launch/*.launch.py) andcommand_mapper.py(importsgeometry_msgs) are deliberately excluded, so the baseline is green today and grows as new pure modules land.pythonpathpoints at the pure package dir so the suite never imports ROS 2.bridge/common/zenoh_bridge/tests/— 22 unit teststest_action_event.py(15): valid envelopes, empty/missing payloads, params preservation, timestamp handling, malformed JSON, and non-object JSON ([],null,42).test_utils.py(7):clampbounds, inclusivity, negative bounds..github/workflows/python-quality.ymlruff check+ruff format --check+pyteston every change touchingbridge/common/zenoh_bridge/**,scripts/**, orpyproject.toml— withconcurrency,timeout-minutes, least-privilegepermissions, consistent with #91/#93.Bug fix —
parse_action_eventcrashed on non-object JSONValid-but-non-object JSON (
[],null,42) madejson.loadssucceed and then.get("payload")raiseAttributeErrorinside the subscriber's hot path — violating the module's own documented contract "Returns None on parse failure". The parser now rejects any non-dict envelope. (Regression-proven by the new parametrized tests.)Validation
pytest -v: 22/22 pass (0.40s)ruff check .cleanruff format --check .cleanNotes
includegrows as bridges land. This keeps the very first baseline honest instead of force-formatting ROS 2 packages.— EslaM-X 🇪🇬