Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(lint): plumb exit codes as outputs rather than dropping them #225

Merged
merged 7 commits into from
May 9, 2024

Conversation

alexeagle
Copy link
Member

@alexeagle alexeagle commented May 8, 2024

This allows downstream tools to return a correct exit code based on 'errors were reported by at least one linter'

Also fixes our bug where "empty output" is assumed to mean success, which was forcing us to stay on an older version of ruff.

Note that lint.sh doesn't try to read these files and exit with the right code. I don't really care about that right now, but will file an issue to come back to it.

Work towards #86


Changes are visible to end-users: yes

It's only slightly visible, in that lint.sh now prints exit codes as well:

rules_lint/example$ ./lint.sh src:unused_import
INFO: Analyzed target //src:unused_import (5 packages loaded, 492 targets configured).
INFO: Found 1 target...
INFO: Elapsed time: 0.309s, Critical Path: 0.00s
INFO: 1 process: 1 internal.
INFO: Build completed successfully, 1 total action
INFO: Build Event Protocol files produced successfully.
From bazel-out/k8-fastbuild/bin/src/ruff.unused_import.aspect_rules_lint.report:
src/unused_import.py:13:8: F401 [*] `os` imported but unused
Found 1 error.
[*] 1 fixable with the `--fix` option.

From bazel-out/k8-fastbuild/bin/src/ruff.unused_import.aspect_rules_lint.exit_code:
1

From bazel-out/k8-fastbuild/bin/src/flake8.unused_import.aspect_rules_lint.report:
src/unused_import.py:13:1: F401 'os' imported but unused

From bazel-out/k8-fastbuild/bin/src/flake8.unused_import.aspect_rules_lint.exit_code:
1
  • Searched for relevant documentation and updated as needed: yes
  • Breaking change (forces users to change their own code or config): no
  • Suggested release notes appear below: no

Test plan

  • Covered by existing test cases

…loor

This allows downstream tools to return a correct exit code based on 'errors were reported by at least one linter'
@alexeagle alexeagle force-pushed the exit_codes branch 4 times, most recently from f3d5a84 to 94b547b Compare May 8, 2024 21:03
When running it to produce patches we need to ignore its exit code.
@alexeagle alexeagle marked this pull request as ready for review May 8, 2024 21:21
lint/lint_test.sh Outdated Show resolved Hide resolved
@alexeagle alexeagle enabled auto-merge (squash) May 8, 2024 22:38
lint/lint_test.bzl Outdated Show resolved Hide resolved
Copy link
Member

@gregmagolan gregmagolan left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧙

@alexeagle alexeagle merged commit 65b2e4d into main May 9, 2024
8 checks passed
@alexeagle alexeagle deleted the exit_codes branch May 9, 2024 15:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants