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

chore(golangci-lint): v1.54.2 pinning and config file #256

Conversation

prometherion
Copy link
Contributor

What this PR does / why we need it:

Currently, there's no version pinning for the golangci-lint utility used, I had to manually retrieve it.

Rather, having it declared, makes it easy for contributors to linting the code.

A local binary will be stored in the ./bin folder to avoid collision with global installed Go modules.

Which issue this PR fixes:

Untracked

Special notes for your reviewer:

Release notes:

NONE

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Aug 17, 2023
@k8s-ci-robot k8s-ci-robot added the size/L Denotes a PR that changes 100-499 lines, ignoring generated files. label Aug 17, 2023
Copy link
Contributor

@nunnatsa nunnatsa left a comment

Choose a reason for hiding this comment

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

@prometherion - thanks for this PR.

Added some inline comments.

@@ -50,7 +50,8 @@ jobs:
- name: golangci-lint
uses: golangci/golangci-lint-action@v3
with: # TODO: remove this when the deprecated function will be removed (issue #85)
args: --exclude SA1019 --timeout=5m -E ginkgolinter
args: --timeout=5m -v
version: v1.44.0
Copy link
Contributor

Choose a reason for hiding this comment

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

The latest version of the golangci-lint is v1.54.1 - any reason not to use it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

As stated in the previous comment section, the idea was to install the golangci-lint binary using go install to avoid interferences from global packages.

However, the latest releases are requiring Go +v1.19 and the go.mod is referencing 1.18. We can decouple from the local development environment from the build one, it should be then well documented without giving anything for granted.

Copy link
Contributor

Choose a reason for hiding this comment

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

1.18 is deprecated anyway. Maybe we better upgrade to 1.20 or 1.21?

Copy link
Contributor

Choose a reason for hiding this comment

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

Alternatively, we can download the binary

Copy link
Contributor

Choose a reason for hiding this comment

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

So @prometherion, I'm working on a new PR to bump golang, here: #257

It's now failing on the unit test, but this is as result of changes in #255. I'll try to fix it next week. But anyway, I think we need to find ways to use newer version of the golangci-lint. v1.44 is way too old.

Copy link
Contributor Author

@prometherion prometherion Aug 17, 2023

Choose a reason for hiding this comment

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

Glad I introduced a feature and a bug at the same time, story of my life.
If you need help with this, please, assign it to me, I'm happy to contribute to the project.

Once we bump to 1.20 we can easily install using the go-install-tool helper: downloading the binary could be cumbersome and require more kinds of checks such as architecture, os, etc.

Copy link
Contributor

Choose a reason for hiding this comment

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

I plan to look at it next week. But if you'll have some time, here is the unit test failure log:

------------------------------
•! [PANICKED] [0.001 seconds]
Reconcile
/home/nunnatsa/GIT/cluster-api-provider-kubevirt/controllers/kubevirtcluster_controller_test.go:37
  reconcile cluster with finalizer and deletion time stamp
  /home/nunnatsa/GIT/cluster-api-provider-kubevirt/controllers/kubevirtcluster_controller_test.go:142
    [It] should succeed with the kubevirt cluster being deleted.
    /home/nunnatsa/GIT/cluster-api-provider-kubevirt/controllers/kubevirtcluster_controller_test.go:154

  Test Panicked
  In [It] at: /usr/local/go1.20.3/src/runtime/panic.go:260

  runtime error: invalid memory address or nil pointer dereference

  Full Stack Trace
    sigs.k8s.io/cluster-api-provider-kubevirt/controllers.(*KubevirtClusterReconciler).deleteExtraGVK(0x37b3ce0, 0xc000707100, {{0x2614d0d, 0x0}, {0x2614d0e, 0x2}, {0x2622de1, 0xd}})
        /home/nunnatsa/GIT/cluster-api-provider-kubevirt/controllers/kubevirtcluster_controller.go:292 +0x323
    sigs.k8s.io/cluster-api-provider-kubevirt/controllers.(*KubevirtClusterReconciler).reconcileDelete(0x37b3ce0, 0xc000707100, 0x7f37fced24a8?)
        /home/nunnatsa/GIT/cluster-api-provider-kubevirt/controllers/kubevirtcluster_controller.go:255 +0x5ec
    sigs.k8s.io/cluster-api-provider-kubevirt/controllers.(*KubevirtClusterReconciler).Reconcile(0x37b3ce0, {0x28db298?, 0xc00004c120}, {{{0x0?, 0x37e4790?}, {0x2631233?, 0x37e4790?}}})
        /home/nunnatsa/GIT/cluster-api-provider-kubevirt/controllers/kubevirtcluster_controller.go:155 +0xaaa
    sigs.k8s.io/cluster-api-provider-kubevirt/controllers_test.glob..func1.5.3()
        /home/nunnatsa/GIT/cluster-api-provider-kubevirt/controllers/kubevirtcluster_controller_test.go:167 +0x1ea
------------------------------

What we'll need to do is to mock the new KubevirtClusterReconciler.APIReader.

.golangci.yml Show resolved Hide resolved
.golangci.yml Show resolved Hide resolved
Makefile Outdated Show resolved Hide resolved
@nunnatsa
Copy link
Contributor

@prometherion - #257 was just merged, bumping golang to version 1.20

Could you please try again with the latest version of golangci-lint?

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Aug 21, 2023
@qinqon
Copy link
Contributor

qinqon commented Aug 21, 2023

/retest

@prometherion prometherion force-pushed the chore/declarative-golangci-lint branch from 86beaa4 to f4be09f Compare August 21, 2023 14:28
@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Aug 21, 2023
@k8s-ci-robot k8s-ci-robot added size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Aug 21, 2023
@prometherion prometherion force-pushed the chore/declarative-golangci-lint branch 3 times, most recently from d0c41fd to 093335c Compare August 21, 2023 14:29
@nunnatsa
Copy link
Contributor

/ok-to-test

@k8s-ci-robot k8s-ci-robot added the ok-to-test Indicates a non-member PR verified by an org member that is safe to test. label Aug 21, 2023
@nunnatsa
Copy link
Contributor

/hold

Need to run ci

@davidvossel I think there is a button for admins to allow ci to run. Could you please check?

@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 Aug 21, 2023
.golangci.yml Outdated Show resolved Hide resolved
@nunnatsa
Copy link
Contributor

nunnatsa commented Aug 21, 2023

@prometherion, could you please update PR title with the right version of golangci-lint?

@nunnatsa
Copy link
Contributor

/hold

Need to run ci

@davidvossel I think there is a button for admins to allow ci to run. Could you please check?

@agradouski @cchengleo - could you do that?

@prometherion prometherion changed the title chore(golangci-lint): v1.44.0 pinning and config file chore(golangci-lint): v1.54.2 pinning and config file Aug 22, 2023
@prometherion prometherion force-pushed the chore/declarative-golangci-lint branch from 093335c to d9065fa Compare August 22, 2023 07:26
@nunnatsa
Copy link
Contributor

/lgtm

@prometherion - the setting of this repo require one-time approval from an admin. This is why the github actions are not running. The funny thing is that it's is possible to merge even without it... Let's wait for one of the admins to approve you as a contributor.

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Aug 22, 2023
@qinqon
Copy link
Contributor

qinqon commented Aug 22, 2023

/approve

@agradouski
Copy link
Contributor

/lgtm

@nunnatsa
Copy link
Contributor

/approve

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: nunnatsa, prometherion, qinqon

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 Aug 22, 2023
@nunnatsa
Copy link
Contributor

/unhold

@k8s-ci-robot k8s-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Aug 22, 2023
@k8s-ci-robot k8s-ci-robot merged commit 0fe9004 into kubernetes-sigs:main Aug 22, 2023
8 of 9 checks passed
@prometherion prometherion deleted the chore/declarative-golangci-lint branch August 22, 2023 15: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/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants