-
Notifications
You must be signed in to change notification settings - Fork 660
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
chore: setup golangci-lint config file #913
base: main
Are you sure you want to change the base?
Conversation
Skipping CI for Draft Pull Request. |
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: mmorel-35 The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these files:
Approvers can indicate their approval by writing |
fc0938b
to
b18d1a2
Compare
b18d1a2
to
eed906a
Compare
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 for the pull request, @mmorel-35. This is a great start, I suggest breaking this pull request into two (or at least two commits).
- Add the
.golangci.yaml
file. - Enable the testifylint linter.
.gitattributes
Outdated
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.
Do we want or need this file? We don't have it in any of our other repositories.
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.
Yes, you do because without the gofmt is fail on Windows platform.
I guess golangc-lint doesn't run on Windows with golangci-lint and gofmt/gofumpt enabled on the other repositories ?
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.
Ah, this may be a fair point. I believe we don't have much support for Windows development.
I also know that @jmhbnz is not a fan of cluttering the top-level repositories. But this is a valid point. Do you think we should consider adding this file to other repositories? Or should we just add it to this repository, as it is the only one that runs workflows on Windows? Although technically, any new file created by a Windows contributor may have Windows line breaks.
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.
In our main repo we make it clear the only supported development environment for etcd is linux:
For both options, the only supported architecture is linux-amd64. Bug reports for other environments will generally be ignored. Supporting new environments requires the introduction of proper tests and maintainer support that is currently lacking in the etcd project.
https://github.com/etcd-io/etcd/blob/main/CONTRIBUTING.md#Set-up-development-environment
I defer to bbolt maintainers however on if that should apply for bbolt.
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.
I have no strong opinion on this.
We don't officially support Windows (neither runtime env, nor development env), so I really don't want to spend time to handle anything related to Windows for now. So I prefer to letting contributors to configure their local git configuration.
We should be good as long as the linter (i.e gofmt
) can identify such inconsistency (CRLF
vs LF
).
git config --global core.autocrlf <true|input>
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.
We don't officially support Windows (neither runtime env, nor development env)
Sorry, it's true for etcd, but it might not be true for bbolt. bbolt isn't only used by etcd, it's also used in other use cases. But we can still expect contributors to configure their local git configuration as mentioned above.
We do support Windows.
https://github.com/etcd-io/bbolt/blob/main/bolt_windows.go
Then, the best option is not to run the golangci-lint in our Windows workflows.
Looks like I am missing something. Why the best option is not to run golangci-lint on Windows? Is it because it will definitely fail if gofmt
is enabled? If Yes, WHY?
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.
Looks like I am missing something. Why the best option is not to run golangci-lint on Windows? Is it because it will definitely fail if gofmt is enabled? If Yes, WHY?
We're already running the linter in the Linux workflows. The result shouldn't be platform-specific. So, if we run the workflow only on Linux, we wouldn't need to add the .gitattributes
file.
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.
Never mind. I thought that golangci-lint
would run the linters over every go file in the project. After reading their documentation (and testing locally), I realized it only runs the linters for the host's platform (it doesn't even work with GOOS
/GOARCH
, ref: golangci/golangci-lint#5159).
So, following their documentation (you need to expand the "Multi OS example"), we need this .gitattributes
file in the repository.
It made me realize that the only two architecture/OS files being linted are: bbolt_linux.go
and bbolt_windows.go
.
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.
we need this
.gitattributes
file in the repository.
Adding .gitattributes
works. But not adding the file will also work as long as we have linter to identify any such inconsistency (CRLF vs LF), please correct me if I am wrong. As mentioned above, we expect contributors to configure their local git config git config --global core.autocrlf <true|input>
.
We don't want to add much much configuration files at the root directory, and add more maintain effort, although it's trivial for now.
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.
I believe that .gitattributes
requires less effort than any other options that I know
fca12ea
to
b53602c
Compare
b53602c
to
44306fb
Compare
Signed-off-by: Matthieu MOREL <[email protected]>
44306fb
to
47910f1
Compare
Description
This defines a golangci-lint config file