feat: add lint-gate target and truncation-proof summary to the strict ruff gate#30877
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
Greptile SummaryThis PR improves the developer experience around the strict ruff gate by adding a local
Confidence Score: 5/5Safe to merge — changes are confined to the gate script, Makefile, and its tests, with no impact on production code paths. All three changed files touch developer tooling only (a lint gate script, its Makefile target, and its unit tests). The refactoring is internally consistent: No files require special attention.
|
| Filename | Overview |
|---|---|
| scripts/ruff_strict_gate.py | Refactors violation collection into a parameterized collect_violations(root, config), consolidates worktree lifecycle into _temp_worktree context manager that uses bare subprocess.run in the finally to avoid masking original exceptions, factors out gather() and report(), and adds a trailing BREACHED RULES summary line so the verdict survives log tail truncation in CI. |
| Makefile | Adds lint-gate to the .PHONY list, adds its help text, and adds the target itself — fetches origin/litellm_internal_staging then runs the gate with --base origin/litellm_internal_staging to match the CI invocation exactly. |
| tests/test_litellm/test_ruff_strict_gate.py | Adds test_report_emits_breached_rules_as_final_line which captures stdout and asserts the last line is the compact BREACHED RULES summary, directly covering the new trailing-summary behaviour. |
Reviews (4): Last reviewed commit: "fix: align lint-gate with CI by dropping..." | Re-trigger Greptile
|
bugbot run Generated by Claude Code |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
Autofix Details
Bugbot Autofix prepared a fix for the issue found in the latest run.
- ✅ Fixed: Lint gate mismatches CI
- Dropped the --ci-parity flag from the lint-gate Makefile target (and removed the now-unused gather_ci_parity branch plus the misleading docstring claim about CI), so make lint-gate now invokes ruff_strict_gate.py the same way test-linting.yml does.
You can send follow-ups to the cloud agent here.
The lint-gate Makefile target invoked ruff_strict_gate.py with --ci-parity, which counted violations on a throwaway merge of base into HEAD against base counts at the base tip. CI in test-linting.yml runs the same script without --ci-parity on a PR-head checkout, taking the gather_fast path that counts on the live tree against base counts at the merge-base. A local pass could therefore disagree with CI. Drop --ci-parity from the Makefile and remove the now-unused gather_ci_parity branch and flag so there is one code path that both local and CI exercise. The docstring claim that CI runs against the synthetic merge ref was also wrong; the workflow checks out github.event.pull_request.head.sha.
|
|
yucheng-berri
left a comment
There was a problem hiding this comment.
nit: ci-parity mode was dropped and the body no longer matches the code.
|
Generated by Claude Code |
|
bugbot run Generated by Claude Code |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit 497447a. Configure here.
a7b0b0b
into
litellm_internal_staging
|
Ok |
K |
… ruff gate (BerriAI#30877) * feat: add CI-parity mode and truncation-proof summary to strict ruff gate * refactor: tolerant worktree cleanup and concrete GateInputs types * fix: clean up temp dir when git worktree add fails * fix: align lint-gate with CI by dropping unused --ci-parity path The lint-gate Makefile target invoked ruff_strict_gate.py with --ci-parity, which counted violations on a throwaway merge of base into HEAD against base counts at the base tip. CI in test-linting.yml runs the same script without --ci-parity on a PR-head checkout, taking the gather_fast path that counts on the live tree against base counts at the merge-base. A local pass could therefore disagree with CI. Drop --ci-parity from the Makefile and remove the now-unused gather_ci_parity branch and flag so there is one code path that both local and CI exercise. The docstring claim that CI runs against the synthetic merge ref was also wrong; the workflow checks out github.event.pull_request.head.sha. --------- Co-authored-by: Cursor Agent <[email protected]>
|
K |
Relevant issues
None; this is developer-experience cleanup for the strict ruff gate that came out of fighting it on a recent PR.
Linear ticket
Pre-Submission checklist
make test-unit@greptileaiand received a Confidence Score of at least 4/5 before requesting a maintainer reviewCI (LiteLLM team)
Link:
Link:
Links:
Screenshots / Proof of Fix
Two pain points with the strict ruff gate and how to see the fix locally.
First, the truncation-proof summary. CI only surfaces the tail of the job log, and the gate printed each breached rule's header before its (potentially long) list of offending files, so on a real failure the rule name and counts scrolled off the top of the captured tail and you could not tell which rule blew the budget. The gate now also prints a single
BREACHED RULES: ...line as the very last line, which survives tail truncation. Covered bytest_report_emits_breached_rules_as_final_line.Second, a local entry point that predicts CI.
make lint-gatefetchesorigin/litellm_internal_stagingfresh and then runs the gate the same way the lint check does intest-linting.yml(the CI job checks out the PR head sha and counts against the merge-base with the base branch), so a clean local run predicts the CI verdict before you push.# matches what the lint CI check will conclude, before you push make lint-gateDefault behavior and the existing
make lint-ruff-budgettarget are unchanged.Type
🚄 Infrastructure
Changes
scripts/ruff_strict_gate.pyalways emits a final one-lineBREACHED RULESsummary so the verdict survives log truncation, and the shared violation-collection logic is factored intocollect_violations(root, config)with worktree handling consolidated behind a_temp_worktreecontext manager that cleans up its temp dir even whengit worktree addfails.make lint-gateis a new local entry point that fetches staging fresh and runs the gate exactly as CI does. Tests extendtests/test_litellm/test_ruff_strict_gate.pywith a regression for the trailing summary line.Note
Low Risk
Changes are limited to Makefile targets, the ruff strict gate script, and unit tests—no runtime or proxy behavior.
Overview
Improves strict ruff budget gate developer experience: failures now end with a single
BREACHED RULES:line (rule, total/cap, added) so CI log tails still show which rules failed.Adds
make lint-gate, which fetchesorigin/litellm_internal_stagingand runsruff_strict_gate.py --basethe same way contributors expect before push;make lint-ruff-budgetis unchanged.scripts/ruff_strict_gate.pyis refactored: sharedcollect_violations,gather, and a_temp_worktreecontext manager for base-branch counts; docs note merge-base behavior aligns with CI. A unit test locks in the trailing summary line.Reviewed by Cursor Bugbot for commit 497447a. Bugbot is set up for automated code reviews on this repo. Configure here.