Repository navigation
fix(ci-formats): name annotation files from the checkout root for a subdirectory --path - #358
Conversation
…ubdirectory --path GitHub resolves annotation and SARIF paths against the checkout root. With --path backend, nplusone wrote shop/views.py, and an absolute --path did the same for migration-risk and blast-radius. Write files under the working directory relative to it. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
No actionable comments were generated in the recent review. Walkthrough
Merge Risk:
|
# Conflicts: # CHANGELOG.md
py-1.18.4: migration-risk --only and the staged-files pre-commit hook (#355), positional operation arguments (#359), abstract-base fields in scan and ER (#354), ER fixes for SQLAlchemy keys and same-named models (#356, #357), checkout-relative annotation paths (#358). 0.22.4: the ER view and hover cards show fields from abstract bases (#354). Co-authored-by: FROWNINGdev <[email protected]>
Summary
GitHub resolves the file of an annotation (and a SARIF
artifactLocation.uri) against the checkout root, and the Action runs the CLI from there. When--pathis a subdirectory, as with the Action'spath: backend, the paths did not say so:--path backend--path /abs/checkout/backendnplusoneshop/views.py(wrong)shop/views.py(wrong)migration-riskbackend/shop/migrations/0002_drop.pyshop/migrations/0002_drop.py(wrong)blast-radiusbackend/shop/migrations/0002_drop.pyshop/migrations/0002_drop.py(wrong)So the N+1 annotations of a monorepo never reached the PR diff, and the other two depended on how the path was spelled. All of them should be
backend/shop/....ci_formats._rel_posix()now writes an absolute path under the working directory relative to that directory, and falls back to the root as before for a path outside it.NPlusOneFinding.fileis relative to the scanned root, sonplusone_github()andnplusone_sarif()take an optionalroot(whichcli.pypasses) and join it to the file first. With the defaultpath: .nothing changes.Type of change
Test plan
test_paths_under_a_subdirectory_root_stay_checkout_relativeintests/test_ci_formats.pychanges into a temporary checkout and checks the GitHub and SARIF paths of both commands forbackendand for the absolute path. It fails onmain. Onmain,_rel_posix()turns the absolute case intoorders/0002.pyinstead ofbackend/orders/0002.py.test_github_annotations_point_at_the_migration_lineintests/test_blast_radius.pynow runs from its fixture folder, which stands in for the checkout root, so it keeps its assertionfile=blog/migrations/0002_drop_author.py. Run fromcli/it would now givetests/fixtures/blast_radius/blog/..., which is the right checkout-relative path from there.backend/shop:nplusone,migration-riskandblast-radius --format github, with--path backendand with the absolute path, all printfile=backend/shop/....cd cli && python -m pytest -q: 1359 passed, 6 skipped.ruff check orm_lens testsandmypy orm_lensare clean.Checklist
cd cli && pytest -qfor Python,npm testfor TypeScript) and it is green## [Unreleased]mcp_server.pyand the relevant tests intest_mcp_server.py(not touched)## Summaryabove and suggested a migration path (not breaking)Related issues / discussions
This touches the same
CHANGELOG.mdsection as #356 and #357, so whichever lands later may need a one-line rebase.This change was written with the help of an AI assistant (Claude); I reviewed and tested it.
🤖 Generated with Claude Code
Summary by CodeRabbit