-
Notifications
You must be signed in to change notification settings - Fork 60
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
Conversation
First stage is to run goimports and formatter, second is full suite. This ensures that imports and formatting are fixed even in presence of other issues. Otherwise golanci-lint refuses to fix anything. This helpful when running aider with config like this - aider will use that to autofix what it can after every update: % cat .aider.conf.yml lint-cmd: - "go: ./lint.sh"
If integration tests don't run automatically, an authorized user can run them manually by following the instructions below: Trigger: Inputs:
Checks will be approved automatically on success. |
# 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 comment
The 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 comment
The 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 comment
The 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.
# 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 $@ |
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:
golangci-lint run --enable-only="gofmt,gofumpt,goimports" --fix
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
As suggested here: #2051 (comment)
As suggested here: #2051 (comment)
See Makefile for explanation on difference between 'make fmt' and 'make lint'. I also removed lint.sh. Original motivation was to use it in aider, but it's not a good fit there, because aider passes filenames and it does not work well with most golang linters which requires whole packages to work. Follow up to #2062, #2056, #2051.
First stage is to run goimports and formatter, second is full suite.
This ensures that imports and formatting are fixed even in presence of other issues. Otherwise golanci-lint refuses to fix anything golangci/golangci-lint#5257
This helpful when running aider with config like this - aider will use that to autofix what it can after every update: