Make make lint able to fail, and match the lint workflow - #104
Open
mrubash1 wants to merge 1 commit into
Open
Conversation
`make lint` ran `ruff check --exit-zero .`, which forces an exit status of 0 regardless of what it finds, so the target always passed. It also never ran `ruff format --check`, which `.github/workflows/lint.yml` does run, so a misformatted file produced no output and a zero exit locally while failing CI. Drop `--exit-zero` and add the formatter check, so the target runs the same three checks as the workflow, in the same order. Also swap the order of `ruff check --fix` and `ruff format` in `make format`. The fixer's edits are not themselves formatted, so with the formatter first, a fix such as removing an unused import can leave a stray blank line and so leave the tree failing the newly-strict `make lint`. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WLpJZQ4W4XsL9NUUjjsry9
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.
make lintcould not fail.Makefileline 3 wasruff check --exit-zero ., and--exit-zeroforces an exit status of 0 regardless of findings, so a greenmake lintpredicted nothing about CI. It also never ranruff format --check, though.github/workflows/lint.ymldoes.This makes the target run the same three checks as the workflow, in the same order.
The two failure modes, demonstrated
Both were checked against the current tree with a deliberately broken file, using CI's pinned versions (ruff 0.1.6, snakefmt 0.8.5) under Python 3.9:
F401)Found 1 error., exits 0The second row is the worse of the two.
--exit-zeroat least still printed the finding, so someone watching the scrollback could notice it. But with noruff format --checkat all, a file that CI rejects produced completely clean local output and a zero exit — there was nothing to notice.Also: the order of the two commands in
make formatmake formatranruff formatand thenruff check --fix. The fixer runs last, so its edits are never formatted afterwards. That is invisible whilemake lintignores formatting, but this PR makesmake lintenforce it, so it would become a fixed-point violation introduced by this change: runmake format, thenmake lintfails.It is reachable with an ordinary edit. Given this format-clean file:
ruff check --fixremoves the unusedosand leaves the blank line that followed it, so the file starts with a blank line andruff format --checkthen rejects it. Reversing the two commands produces a clean tree from the same input. This also matches ruff's own guidance to run the fixer before the formatter.Verification
make lintexits 0 on the current tree.make lintexits non-zero for a lint error and for a formatting error (the table above); a fix that cannot be shown to fail is not verified.make formatrewrites nothing on the current tree — the only modified file afterwards is theMakefileitself — and still fixes both broken files above.What was not verified
make testdoes not pass on this branch, and does not pass on unmodifiedmaineither. Two rules fail:That is the
envs/analysis.ymldependency drift fixed in #101, reproduced here independently on a clean checkout of currentmainwith a fresh conda solve. It is unrelated to this PR, which touches only thelintandformattargets in theMakefile. Worth noting as a second data point for #101: the drift is not specific to one machine or one day's package index.make smoke-testwas not run because that target does not exist on this base; it arrives with #101.Stacking: #101 also edits the
Makefile, adding asmoke-testtarget further down. The hunks are far apart and were checked to apply cleanly in either order.