-
Notifications
You must be signed in to change notification settings - Fork 64
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
Add lint.sh to run golanci-lint in 2 stages #2051
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#!/bin/bash | ||
set -euo pipefail | ||
# With golangci-lint, if there are any compliation issues, then formatters' autofix won't be applied. | ||
# https://github.com/golangci/golangci-lint/issues/5257 | ||
# However, running goimports first alone will actually fix some of the compilation issues. | ||
# Fixing formatting is also reasonable thing to do. | ||
# For this reason, this script runs golangci-lint in two stages: | ||
golangci-lint run --fix --no-config --disable-all --enable gofumpt,goimports $@ | ||
exec golangci-lint run --fix $@ | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. How does this work on CI? We don't actually commit anything back, right? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Neither lint.sh not "make lint" are called on CI. It uses golangci's github action instead: https://github.com/databricks/cli/blob/main/.github/workflows/push.yml#L75 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. So we're not even going to modify anything in the worktree, because we don't pass --fix there. If there are any mismatches, they won't be corrected, the check will fail. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@denik I would recommend this:
Because this will read the configuration of the formatters but ignore the rest.
Those 3 linters just read the syntax, not the types.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! Yes, that makes sense. #2056