10000 ci: migrate golangci lint to v2 by LJTian · Pull Request #20658 · kubernetes/minikube · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

ci: migrate golangci lint to v2 #20658

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

Merged
merged 2 commits into from
May 9, 2025
Merged

Conversation

LJTian
Copy link
Contributor
@LJTian LJTian commented Apr 28, 2025

Update golint from v1.64.5 to v2.1.2

add .golangci.yaml file

Fixes #20654

@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 28, 2025
@k8s-ci-robot
Copy link
Contributor

Hi @LJTian. Thanks for your PR.

I'm waiting for a kubernetes 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-sigs/prow repository.

@k8s-ci-robot k8s-ci-robot added cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Apr 28, 2025
@minikube-bot
Copy link
Collaborator

Can one of the admins verify this patch?

@LJTian
Copy link
Contributor Author
LJTian commented Apr 28, 2025

/lint

@medyagh
Copy link
Member
medyagh commented Apr 28, 2025

/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 28, 2025
@medyagh
Copy link
Member
medyagh commented Apr 28, 2025

thank you @LJTian for picking this up ! are the Excludes in this PR new ? are they easy to fix in a follow up PR?

@medyagh medyagh changed the title update golangci lint migrate golangci lint to v2 Apr 28, 2025
Makefile Outdated
@@ -525,7 +524,7 @@ out/linters/golangci-lint-$(GOLINT_VERSION):
ifeq ($(MINIKUBE_BUILD_IN_DOCKER),y)
lint:
docker run --rm -v $(pwd):/app -w /app golangci/golangci-lint:$(GOLINT_VERSION) \
golangci-lint run ${GOLINT_OPTIONS} --skip-dirs "cmd/drivers/kvm|cmd/drivers/hyperkit|pkg/drivers/kvm|pkg/drivers/hyperkit" ./...
golangci-lint run ${GOLINT_OPTIONS} --config .golangci-build-in-docker.yaml ./...
Copy link
Member

Choose a reason for hiding this comment

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

why do we have a different file for build in docker? can we use the same file for simplicity ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Since version 2 removed parameters like --skip-dirs , the same functionality can only be achieved through configuration files.
I personally prefer to use a single configuration file to reduce maintenance costs, and I'd like to spend some time to investigate further to see if there is a better way to solve this problem.

Copy link
Member

Choose a reason for hiding this comment

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

What is the Difference bwtween the current two config files ? can we at least comment What is the diff in the top of the file if there is only one Line difference, we can comment so the next person editing one edit the other one too

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The main difference between these two configuration files is that some directories are skipped

@minikube-pr-bot

This comment has been minimized.

@LJTian
Copy link
Contributor Author
LJTian commented Apr 29, 2025

thank you @LJTian for picking this up ! are the Excludes in this PR new ? are they easy to fix in a follow up PR?

"Please take a look at the issue on GitHub: #20654."

@minikube-pr-bot

This comment has been minimized.

disabled: true
gocritic:
# See https://go-critic.com/overview.html
disabled-checks:
Copy link
Member

Choose a reason for hiding this comment

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

are these skipped in v1 too ? can we create an issue to fix all these Skipped Lint Issues as a follow up PR

Copy link
Contributor Author
@LJTian LJTian May 6, 2025

Choose a reason for hiding this comment

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

old version info :

# options for lint (golangci-lint)
GOLINT_OPTIONS = --timeout 7m \
	  --build-tags "${MINIKUBE_INTEGRATION_BUILD_TAGS}" \
	  --enable gofmt,goimports,gocritic,revive,gocyclo,misspell,nakedret,stylecheck,unconvert,unparam,dogsled \
	  --exclude 'variable on range scope.*in function literal|ifElseChain'

In our previous makfile, we mainly used regular expressions to skip some issues. In fact, we should use configuration to disable them instead of regular expressions.
We can add a new PR to fix the issues we think need to be fixed. What we need to know is that these fixes are only code style fixes, not code errors or code vulnerabilities.

Makefile Outdated
golangci-lint run ${GOLINT_OPTIONS} --skip-dirs "cmd/drivers/kvm|cmd/drivers/hyperkit|pkg/drivers/kvm|pkg/drivers/hyperkit" ./...
mkdir -p ./out/linters
@if [ ! -f ./out/linters/yq ] ; then \
wget https://github.com/mikefarah/yq/releases/download/${YQ_VERSION}/${YQ_BINARY_NAME} -O ./out/linters/yq && chmod +x ./out/linters/yq; \
Copy link
Member

Choose a reason for hiding this comment

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

this doesnt seem right to install things using wget, and we we need to install this ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Currently this code is still under debugging. I submit this PR mainly for the convenience of discussion. I will merge and submit it later. Then notify you again.

@k8s-ci-robot k8s-ci-robot added lgtm "Looks good to me", indicates that a PR is ready to be merged. approved Indicates a PR has been approved by an approver from all required OWNERS files. labels May 1, 2025
Makefile Outdated
-i .golangci.yaml && echo "yq add data ok"

docker run --rm -v `pwd`:/app -w /app golangci/golangci-lint:$(GOLINT_VERSION) \
bash -c "apt update && apt -y install libvirt-dev && golangci-lint run ${GOLINT_OPTIONS} ./..."
Copy link
Member

Choose a reason for hiding this comment

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

did we really need to do apt update and install libvirt ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Currently this code is still under debugging. I submit this PR mainly for the convenience of discussion. I will merge and submit it later. Then notify you again.

Copy link
Member
@medyagh medyagh left a comment

Choose a reason for hiding this comment

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

PR looks almost ready to merge, just need to add some comments in the code for why doing things that way
and also do we really need to apt update and install in docker run ? the image no longer has those packages by itself?

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: LJTian, medyagh

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

@LJTian
Copy link
Contributor Author
LJTian commented May 6, 2025

PR looks almost ready to merge, just need to add some comments in the code for why doing things that way and also do we really need to apt update and install in docker run ? the image no longer has those packages by itself?

Currently this code is still under debugging. I submit this PR mainly for the convenience of discussion. I will merge and submit it later. Then notify you again.

@LJTian
Copy link
Contributor Author
LJTian commented May 6, 2025

PR looks almost ready to merge, just need to add some comments in the code for why doing things that way and also do we really need to apt update and install in docker run ? the image no longer has those packages by itself?

I use the vscode space environment to verify the "build in docker" method, but it always times out. I am still looking for a new environment for verification. After the verification is completed, I will add corresponding comments and remove some redundant information.

@k8s-ci-robot
Copy link
Contributor

New changes are detected. LGTM label has been removed.

@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label May 6, 2025
@LJTian
Copy link
Contributor Author
LJTian commented May 6, 2025

/cc @medyagh Hello, I have merged all the commits and this is the latest version.
I tried to use the yq tool to modify ".golangci.yaml" and implement the "--skip-dirs" parameter function. However, in my subsequent verification, I found that modifying the yq tool would cause the ".golangci.yaml" file format to change, resulting in some errors. So I gave up this method and chose the annotation method you suggested. At first I considered using the sed tool, but because sed is not very convenient to modify the yaml file and it is easy to cause the format to be messed up.
Regarding the issue with libvirt-deve, I don't think this problem should be fixed in this PR. If there is a problem, a new PR should be created to fix it.

@minikube-pr-bot

This comment has been minimized.

@medyagh
Copy link
Member
medyagh commented May 8, 2025

d that modifying the yq tool would cause the ".golangci.yaml

if our yaml format needs to be standardized so the yq doesnt mess it up, it is okay to change our yaml format

let me know when you are satisfied with the PR to be Ready for Review ! feel free to ping me on public minikube chat room on slack

@minikube-pr-bot
Copy link

kvm2 driver with docker runtime

+----------------+----------+---------------------+
|    COMMAND     | MINIKUBE | MINIKUBE (PR 20658) |
+----------------+----------+---------------------+
| minikube start | 52.5s    | 53.3s               |
| enable ingress | 18.3s    | 17.9s               |
+----------------+----------+---------------------+

Times for minikube ingress: 19.7s 18.5s 15.6s 18.6s 19.1s
Times for minikube (PR 20658) ingress: 20.6s 19.7s 15.6s 15.1s 18.6s

Times for minikube start: 53.4s 50.8s 52.0s 51.5s 55.0s
Times for minikube (PR 20658) start: 54.2s 56.9s 51.8s 49.4s 54.3s

docker driver with docker runtime

+----------------+----------+---------------------+
|    COMMAND     | MINIKUBE | MINIKUBE (PR 20658) |
+----------------+----------+---------------------+
| minikube start | 26.1s    | 24.2s               |
| enable ingress | 12.6s    | 12.9s               |
+----------------+----------+---------------------+

Times for minikube start: 26.4s 26.4s 24.7s 26.7s 26.5s
Times for minikube (PR 20658) start: 24.2s 26.2s 22.8s 23.9s 23.7s

Times for minikube ingress: 12.8s 12.3s 12.4s 12.3s 13.4s
Times for minikube (PR 20658) ingress: 13.3s 13.3s 12.4s 13.3s 12.3s

docker driver with containerd runtime

+----------------+----------+---------------------+
|    COMMAND     | MINIKUBE | MINIKUBE (PR 20658) |
+----------------+----------+---------------------+
| minikube start | 23.4s    | 23.7s               |
| enable ingress | 32.4s    | 26.0s               |
+----------------+----------+---------------------+

Times for minikube start: 22.9s 22.6s 25.6s 23.2s 22.8s
Times for minikube (PR 20658) start: 21.0s 25.0s 25.9s 24.6s 22.1s

Times for minikube ingress: 38.8s 22.8s 38.8s 22.8s 38.9s
Times for minikube (PR 20658) ingress: 38.8s 22.8s 22.8s 22.8s 22.8s

@medyagh medyagh merged commit 8575bee into kubernetes:master May 9, 2025
27 of 34 checks passed
@medyagh medyagh changed the title migrate golangci lint to v2 ci: migrate golangci lint to v2 May 9, 2025
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. 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.

fix all lints for new linter
5 participants
0