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

Enable golint with golangci-lint #825

Merged
merged 1 commit into from
Apr 12, 2021

Conversation

elfosardo
Copy link
Member

Most linters are disabled by default when using golangci-lint, we need
to explicitely enable them if we want them to run.
This change enables the basic golint support.
For more info please check https://golangci-lint.run/usage/quick-start

@metal3-io-bot metal3-io-bot added the size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. label Mar 23, 2021
@elfosardo
Copy link
Member Author

golint should now fail

@elfosardo
Copy link
Member Author

@dhellmann golint and govet now fail, not sure which options we want to keep
if we leave golint, we need to fix the rest besides what's fixed in #823

@dhellmann
Copy link
Member

I think all of the failures are things we should fix, so I'm OK with the set of rules that are enabled.

The govet and golint jobs are running the same thing. Is govet enabled? We could probably drop one of the jobs if the same tool runs all of the tests in one job.

@elfosardo
Copy link
Member Author

I think all of the failures are things we should fix, so I'm OK with the set of rules that are enabled.

The govet and golint jobs are running the same thing. Is govet enabled? We could probably drop one of the jobs if the same tool runs all of the tests in one job.

yes, govet is included in golint
I agree we should drop govet and just run golint, I don't have that power though :)
I'm going to fix the rest of the lint errors here

@metal3-io-bot metal3-io-bot added size/L Denotes a PR that changes 100-499 lines, ignoring generated files. and removed size/XS Denotes a PR that changes 0-9 lines, ignoring generated files. labels Mar 23, 2021
@elfosardo
Copy link
Member Author

I will leave vet in makefile until govet job has been removed

@elfosardo elfosardo force-pushed the enable-golint branch 2 times, most recently from 0ac721e to dc7f4e8 Compare March 23, 2021 15:33
@elfosardo
Copy link
Member Author

/test-integration

@elfosardo
Copy link
Member Author

/assign @dhellmann @hardys

@fmuyassarov
Copy link
Member

I will leave vet in makefile until govet job has been removed

If the plan is to remove the govet from mandatory CI jobs, that can be done here https://github.com/metal3-io/project-infra/blob/ebe2d90c26bb3bf284fd34c2c171a82058249da6/prow/config/config.yaml#L252-L265

@elfosardo
Copy link
Member Author

I will leave vet in makefile until govet job has been removed

If the plan is to remove the govet from mandatory CI jobs, that can be done here https://github.com/metal3-io/project-infra/blob/ebe2d90c26bb3bf284fd34c2c171a82058249da6/prow/config/config.yaml#L252-L265

oh cool, thanks for pointing that out!
I will submit a patch for that, but I think we should merge this first

elfosardo added a commit to elfosardo/project-infra that referenced this pull request Mar 29, 2021
elfosardo added a commit to elfosardo/project-infra that referenced this pull request Mar 29, 2021
@dtantsur
Copy link
Member

What's with this p vs m in methods? It doesn't seem like a meaningful change to me, and it makes this patch conflict with everything other patch in existence. Maybe skip that?

@elfosardo
Copy link
Member Author

What's with this p vs m in methods? It doesn't seem like a meaningful change to me, and it makes this patch conflict with everything other patch in existence. Maybe skip that?

@dtantsur it's unfortunately a valid lint error:
pkg/provisioner/demo/demo.go:81:1: receiver name p should be consistent with previous receiver name m for demoProvisioner

we never really ran golint here that's why now we need to make these changes

pkg/provisioner/demo/demo.go Outdated Show resolved Hide resolved
Makefile Outdated Show resolved Hide resolved
Makefile Outdated Show resolved Hide resolved
Makefile Outdated Show resolved Hide resolved
@metal3-io-bot metal3-io-bot added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Apr 8, 2021
Copy link
Member

@dhellmann dhellmann left a comment

Choose a reason for hiding this comment

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

One nit, but I'm not sure it really matters.

Thanks for working on this!

/approve

@@ -118,7 +112,7 @@ demo: generate lint manifests ## Run in demo mode
go run -ldflags $(LDFLAGS) ./main.go -namespace=$(RUN_NAMESPACE) -dev -demo-mode

.PHONY: run-test-mode
run-test-mode: generate fmt vet manifests ## Run against the configured Kubernetes cluster in ~/.kube/config
run-test-mode: generate fmt-check lint manifests ## Run against the configured Kubernetes cluster in ~/.kube/config
Copy link
Member

Choose a reason for hiding this comment

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

I think this was using fmt instead of fmt-check so that code would be fixed before being passed to the compiler.

Copy link
Member Author

Choose a reason for hiding this comment

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

I think fmt-check is correct as it's using the gofmt.sh script under /hack
fmt was just an alias for lint
vet is also an alias, but we will remove it later to not break the current jobs

@dhellmann
Copy link
Member

/test-integration

@dhellmann
Copy link
Member

oh, now there are merge conflicts

Most linters are disabled by default when using golangci-lint, we need
to explicitely enable them if we want them to run.
This change enables the basic golint support.
For more info please check https://golangci-lint.run/usage/quick-start

Also remove useless or duplicated entries from Makefile.
@elfosardo
Copy link
Member Author

/test-integration

@elfosardo elfosardo requested a review from dhellmann April 9, 2021 18:22
@elfosardo
Copy link
Member Author

/assign @asalkeld

@dhellmann
Copy link
Member

/approve
/lgtm

Let's get this in so we don't regress the lint job and have to keep fixing issues in this PR.

@metal3-io-bot metal3-io-bot added the lgtm Indicates that a PR is ready to be merged. label Apr 9, 2021
@metal3-io-bot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: dhellmann, elfosardo

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

@metal3-io-bot metal3-io-bot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Apr 9, 2021
@elfosardo
Copy link
Member Author

@dhellmann not sure why this is "Not mergeable", CI seems ok now :/

@dhellmann
Copy link
Member

There are some issues with the upstream Prow instance.

@maelk @kashifest @zaneb is it safe for me to merge this PR by hand?

@kashifest
Copy link
Member

There are some issues with the upstream Prow instance.

@maelk @kashifest @zaneb is it safe for me to merge this PR by hand?

OK for me. By the way since tide is still working, we tested IPAM repo with enabling Travis to do a the tests and making prow optional and tide was able to merge it. We configured Travis test as required now. I have a PR to do the same for CAPM3 and Dev-Env. Shall I do the same for BMO? metal3-io/project-infra#179. You have to configure Travis tests as required.

@dhellmann
Copy link
Member

There are some issues with the upstream Prow instance.
@maelk @kashifest @zaneb is it safe for me to merge this PR by hand?

OK for me. By the way since tide is still working, we tested IPAM repo with enabling Travis to do a the tests and making prow optional and tide was able to merge it. We configured Travis test as required now. I have a PR to do the same for CAPM3 and Dev-Env. Shall I do the same for BMO? metal3-io/project-infra#179. You have to configure Travis tests as required.

It sounds like that's probably a good idea, but we should talk about it somewhere that more community members will be able to offer their opinion. Maybe the mailing list?

In the mean time, I'll merge this one by hand.

@dhellmann dhellmann merged commit 64898fa into metal3-io:master Apr 12, 2021
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. lgtm Indicates that a PR is ready to be merged. size/S Denotes a PR that changes 10-29 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants