Repository navigation
fix(guardian): drop the gh dependency and bump node24 action pins - #773
Conversation
The reusable workflow shelled out to `gh` for the trigger reaction and the base-branch lookup, and github_poster.py posted the inline review with `gh api`; a self-hosted runner without the CLI failed on the second step. Both workflow steps now call the REST API through actions/github-script, and the poster POSTs over HTTPS with urllib and GH_TOKEN (GITHUB_TOKEN locally). An API rejection raises RuntimeError carrying GitHub's response body. Bump the guardian workflows to current, node24 action majors: checkout v7, setup-uv v10.3.3, github-script v9, create-or-update-comment v5, upload-artifact v7, create-github-app-token v3.3.0, download-artifact v8. The workflow notes the v2.327.1+ self-hosted runner requirement. Tests pin the absence of gh in both workflow steps and in guardian code, and hold every remote action pin to the current majors. README says that local --inline needs GH_TOKEN. Co-authored-by: zaebee <305761+zaebee@users.noreply.github.com>
There was a problem hiding this comment.
Code Review
This pull request replaces the dependency on the GitHub CLI (gh) with plain HTTPS requests using Python's built-in urllib library for posting inline review comments, improving compatibility with self-hosted runners. It also introduces comprehensive tests, including AST-based checks, to ensure gh is not spawned. The review comments are highly valuable: one suggests stripping whitespace from retrieved tokens to prevent authentication failures, and the other improves the AST check in tests to robustly detect direct imports of subprocess functions.
Review follow-up on #773: the AST scan now sees direct imports and aliases (from subprocess import run as spawn, import subprocess as sp), with cases pinning each spelling; a token pasted with surrounding whitespace is stripped before it reaches the Authorization header. Co-authored-by: zaebee <305761+zaebee@users.noreply.github.com>
Review follow-up on #773: the AST scan now sees direct imports and aliases (from subprocess import run as spawn, import subprocess as sp), with cases pinning each spelling; a token pasted with surrounding whitespace is stripped before it reaches the Authorization header.
48e8e4d to
926e23c
Compare
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request removes the dependency on the GitHub CLI (gh) by refactoring the inline review poster to use direct HTTPS requests via Python's built-in urllib library. Key changes include implementing a robust token extraction helper, updating the asynchronous runner, and adapting unit tests to mock HTTP requests instead of subprocesses. Additionally, new AST-based tests are introduced to guarantee that no library code or workflow steps shell out to gh, and GitHub Actions are pinned to specific SHAs. There are no review comments to evaluate, and I have no feedback to provide.
|



This is by an automated agent, not a human.
Why
The reusable guardian workflow assumed the GitHub CLI: the trigger reaction and the base-branch lookup shelled out to
gh, andgithub_poster.pyposted the inline review withgh api. A self-hosted runner withoutghfailed on the second step. The action pins were also node20-era majors (#742, items 1–2).What changed
ghin the review path. The reaction and the base-branch lookup areactions/github-scriptREST calls; the poster POSTs to/repos/{repo}/pulls/{pr}/reviewswithurllibandGH_TOKEN(GITHUB_TOKENfallback for local runs). An API rejection raisesRuntimeErrorcarrying GitHub's response body instead ofCalledProcessError, so the runner's existing fallback still fires and logs the reason.# vNcomments name them):actions/checkoutv7,astral-sh/setup-uvv10.3.3,actions/github-scriptv9,peter-evans/create-or-update-commentv5,actions/upload-artifactv7,actions/create-github-app-tokenv3.3.0. This repo's caller (guardian.yml) gets checkout v7,download-artifactv8, github-script v9 and setup-uv v10.3.3.run:block in either guardian workflow callsgh; no guardian module orscripts/guardian_review.pyspawnsgh(AST scan oversubprocess/os/asynciospawn calls); every remoteuses:is SHA-pinned to the current majors. The poster tests mockurlopenand check the URL, method, bearer auth, payload, token fallback, missing-token failure and the response body on rejection.--inlinenow needsGH_TOKEN(orGITHUB_TOKEN); Actions exports it.Verification
make format,make lint,make type-check,make doc-coveragepass.pytest tests/unit/test_guardian_poster.py tests/unit/test_guardian_workflow.py tests/unit/test_guardian_runner.py tests/unit/test_guardian_review_script.py— 177 passed, 2 skipped.pytest: 4477 passed, 2 skipped, 15 xfailed (complete local checkout; a shallow one cannot resolve the historical SHA fixtures).Limitations
/guardian reviewon this repository is the end-to-end check.uses: zaebee/codegraph-brain/...@<sha>) must move their pin to this PR's merge commit in their own PRs; that is outside this repository.Addresses #742.