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

use golangci-lint as linter #170

Merged
merged 4 commits into from
Apr 6, 2024
Merged

Conversation

embik
Copy link
Member

@embik embik commented Apr 3, 2024

golangci-lint is a pretty good linter for Go projects. This updates the existing hack/verify-golint.sh script to install that instead of golang.org/x/lint/golint.

The .golangci.yml configuration file is adapted from https://github.com/kubernetes-sigs/krew/blob/master/.golangci.yml. Felt like a pretty good starting point, we can gradually enable linters that seem useful.

This PR is currently a WIP because the new linter uncovers a couple of problems, but some of them are already addressed in #165. I'll wait for that PR to move forward (in any direction) before fixing linter-discovered problems in this PR to minimise conflict with the existing PR.

@k8s-ci-robot k8s-ci-robot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Apr 3, 2024
@k8s-ci-robot
Copy link
Contributor

Welcome @embik!

It looks like this is your first PR to kubernetes-sigs/hydrophone 🎉. Please refer to our pull request process documentation to help your PR have a smooth ride to approval.

You will be prompted by a bot to use commands during the review process. Do not be afraid to follow the prompts! It is okay to experiment. Here is the bot commands documentation.

You can also check if kubernetes-sigs/hydrophone has its own contribution guidelines.

You may want to refer to our testing guide if you run into trouble with your tests not passing.

If you are having difficulty getting your pull request seen, please follow the recommended escalation practices. Also, for tips and tricks in the contribution process you may want to read the Kubernetes contributor cheat sheet. We want to make sure your contribution gets all the attention it needs!

Thank you, and welcome to Kubernetes. 😃

@k8s-ci-robot k8s-ci-robot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Apr 3, 2024
@k8s-ci-robot
Copy link
Contributor

Hi @embik. Thanks for your PR.

I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@k8s-ci-robot k8s-ci-robot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Apr 3, 2024
@rjsadow
Copy link
Collaborator

rjsadow commented Apr 3, 2024

/lgtm
/approve
Thanks! I was wanting to move to golangci-lint.

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Apr 3, 2024
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: embik, rjsadow

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Apr 3, 2024
@embik
Copy link
Member Author

embik commented Apr 3, 2024

level=error msg="Running error: context loading failed: no go files to analyze: running go mod tidy may solve the problem"

Will look into why this is happening. make verify works fine on my local system, I'll see what is the difference to the prow job.

@k8s-ci-robot k8s-ci-robot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed lgtm "Looks good to me", indicates that a PR is ready to be merged. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. labels Apr 4, 2024
@embik embik changed the title WIP: Use golangci-lint as linter Use golangci-lint as linter Apr 4, 2024
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Apr 4, 2024
@embik
Copy link
Member Author

embik commented Apr 4, 2024

I've fixed the linter issues post-merge of #165, but I'm not sure why the prow job was failing in the first place. Tried to reproduce it by running public.ecr.aws/docker/library/golang:1.22, which was happily executing make verify.

@rjsadow PR is ready for review now, so maybe this could get an ok-to-test? If the job keeps failing I might need to push 1-2 debug commits to dissect the job environment.

@embik embik changed the title Use golangci-lint as linter use golangci-lint as linter Apr 4, 2024
@rjsadow
Copy link
Collaborator

rjsadow commented Apr 4, 2024

/ok-to-test

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Apr 4, 2024
@xmudrii
Copy link
Member

xmudrii commented Apr 4, 2024

/retest

@embik
Copy link
Member Author

embik commented Apr 4, 2024

It was a timeout issue due to the constrained nature of the prow job. I'll open a PR in test-infra to bump the job to 2 cpu cores. But it works now.

Signed-off-by: Marvin Beckers <marvin@kubermatic.com>
@rjsadow
Copy link
Collaborator

rjsadow commented Apr 4, 2024

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Apr 4, 2024
@rjsadow
Copy link
Collaborator

rjsadow commented Apr 4, 2024

/hold

@k8s-ci-robot k8s-ci-robot added the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Apr 4, 2024
@rjsadow rjsadow removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Apr 4, 2024
@rjsadow
Copy link
Collaborator

rjsadow commented Apr 4, 2024

@embik This looks good, but can you please remove the error handling changes from this PR? I think we've got some other issues and PRs that are looking to update some of that which might conflict.

@embik
Copy link
Member Author

embik commented Apr 4, 2024

@embik This looks good, but can you please remove the error handling changes from this PR? I think we've got some other issues and PRs that are looking to update some of that which might conflict.

I can do that, but then I'll still need to add //nolint directives which might also result in conflicts. I currently don't see any PRs open that relate to this, #165 by my colleague @xrstf was changing a lot of error handling but it's already merged and I rebased this PR accordingly.

Do you still want me to go ahead with that?

Signed-off-by: Marvin Beckers <marvin@kubermatic.com>
Signed-off-by: Marvin Beckers <marvin@kubermatic.com>
Signed-off-by: Marvin Beckers <marvin@kubermatic.com>
@embik
Copy link
Member Author

embik commented Apr 5, 2024

@rjsadow realised you can just add //nolint to a whole file, so I've put a temporary one in place for cmd/root.go. Should be good to go now!

@rjsadow
Copy link
Collaborator

rjsadow commented Apr 6, 2024

@embik looks good,thanks for doing this!
/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Apr 6, 2024
@rjsadow rjsadow removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Apr 6, 2024
@k8s-ci-robot k8s-ci-robot merged commit f6fa8e5 into kubernetes-sigs:main Apr 6, 2024
7 checks passed
@embik embik deleted the golangci-lint branch April 11, 2024 06:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants