Skip to content

tooling: enforce version of golangci-lint #20205

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

BBQing
Copy link

@BBQing BBQing commented Jun 23, 2025

Please read https://github.com/etcd-io/etcd/blob/main/CONTRIBUTING.md#contribution-flow.

fixes #20199

tested against no golangci-lint and latest version installed (I think it matter, if the version is 2 instead of 1)

add into makefile:
latest-golangci-lint:
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(GOPATH)/bin

vscode ➜ /workspaces/etcd (main) $ make latest-golangci-lint
curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b /go/bin
golangci/golangci-lint info checking GitHub for latest tag
golangci/golangci-lint info found version: 2.1.6 for v2.1.6/linux/amd64
golangci/golangci-lint info installed /go/bin/golangci-lint
vscode ➜ /workspaces/etcd (main) $ make verify-lint
./scripts/verify_golangci-lint_version.sh
different golangci-lint version installed: v2.1.6
Installing golangci-lint v1.64.8
golangci/golangci-lint info checking GitHub for tag 'v1.64.8'
golangci/golangci-lint info found version: 1.64.8 for v1.64.8/linux/amd64
golangci/golangci-lint info installed /go/bin/golangci-lint
golangci-lint version: v1.64.8
PASSES="lint" ./scripts/test.sh
Running with --race
Starting at: Sat Jun 21 12:22:51 PM UTC 2025

'lint' started at Sat Jun 21 12:22:51 PM UTC 2025
% (cd api && 'golangci-lint' 'run' '--config' '/workspaces/etcd/tools/.golangci.yaml' './...')
% (cd pkg && 'golangci-lint' 'run' '--config' '/workspaces/etcd/tools/.golangci.yaml' './...')
% (cd client/pkg && 'golangci-lint' 'run' '--config' '/workspaces/etcd/tools/.golangci.yaml' './...')
% (cd client/v3 && 'golangci-lint' 'run' '--config' '/workspaces/etcd/tools/.golangci.yaml' './...')
% (cd server && 'golangci-lint' 'run' '--config' '/workspaces/etcd/tools/.golangci.yaml' './...')
% (cd etcdutl && 'golangci-lint' 'run' '--config' '/workspaces/etcd/tools/.golangci.yaml' './...')
% (cd etcdctl && 'golangci-lint' 'run' '--config' '/workspaces/etcd/tools/.golangci.yaml' './...')
% (cd tests && 'golangci-lint' 'run' '--config' '/workspaces/etcd/tools/.golangci.yaml' './...')
% (cd tools/mod && 'golangci-lint' 'run' '--config' '/workspaces/etcd/tools/.golangci.yaml' './...')
% (cd tools/rw-heatmaps && 'golangci-lint' 'run' '--config' '/workspaces/etcd/tools/.golangci.yaml' './...')
% (cd tools/testgrid-analysis && 'golangci-lint' 'run' '--config' '/workspaces/etcd/tools/.golangci.yaml' './...')
% (cd cache && 'golangci-lint' 'run' '--config' '/workspaces/etcd/tools/.golangci.yaml' './...')
% 'golangci-lint' 'run' '--config' '/workspaces/etcd/tools/.golangci.yaml' './...'
'lint' PASSED and completed at Sat Jun 21 12:22:55 PM UTC 2025
SUCCESS

remove-lint:
rm -rf $(GOPATH)/bin/golangci-lint

vscode ➜ /workspaces/etcd (main) $ make remove-lint
rm -rf /go/bin/golangci-lint
vscode ➜ /workspaces/etcd (main) $ make verify-lint
./scripts/verify_golangci-lint_version.sh
golangci-lint is not available
Installing golangci-lint v1.64.8
golangci/golangci-lint info checking GitHub for tag 'v1.64.8'
golangci/golangci-lint info found version: 1.64.8 for v1.64.8/linux/amd64
golangci/golangci-lint info installed /go/bin/golangci-lint
PASSES="lint" ./scripts/test.sh
Running with --race
Starting at: Sat Jun 21 12:24:43 PM UTC 2025

'lint' started at Sat Jun 21 12:24:43 PM UTC 2025
% (cd api && 'golangci-lint' 'run' '--config' '/workspaces/etcd/tools/.golangci.yaml' './...')
% (cd pkg && 'golangci-lint' 'run' '--config' '/workspaces/etcd/tools/.golangci.yaml' './...')
% (cd client/pkg && 'golangci-lint' 'run' '--config' '/workspaces/etcd/tools/.golangci.yaml' './...')
% (cd client/v3 && 'golangci-lint' 'run' '--config' '/workspaces/etcd/tools/.golangci.yaml' './...')
% (cd server && 'golangci-lint' 'run' '--config' '/workspaces/etcd/tools/.golangci.yaml' './...')
% (cd etcdutl && 'golangci-lint' 'run' '--config' '/workspaces/etcd/tools/.golangci.yaml' './...')
% (cd etcdctl && 'golangci-lint' 'run' '--config' '/workspaces/etcd/tools/.golangci.yaml' './...')
% (cd tests && 'golangci-lint' 'run' '--config' '/workspaces/etcd/tools/.golangci.yaml' './...')
% (cd tools/mod && 'golangci-lint' 'run' '--config' '/workspaces/etcd/tools/.golangci.yaml' './...')
% (cd tools/rw-heatmaps && 'golangci-lint' 'run' '--config' '/workspaces/etcd/tools/.golangci.yaml' './...')
% (cd tools/testgrid-analysis && 'golangci-lint' 'run' '--config' '/workspaces/etcd/tools/.golangci.yaml' './...')
% (cd cache && 'golangci-lint' 'run' '--config' '/workspaces/etcd/tools/.golangci.yaml' './...')
% 'golangci-lint' 'run' '--config' '/workspaces/etcd/tools/.golangci.yaml' './...'
'lint' PASSED and completed at Sat Jun 21 12:24:46 PM UTC 2025
SUCCESS

vscode ➜ /workspaces/etcd (fix_verify_lint) $ make verify-shellcheck
PASSES="shellcheck" ./scripts/test.sh
Running with --race
Starting at: Mon Jun 23 12:54:40 PM UTC 2025

'shellcheck' started at Mon Jun 23 12:54:40 PM UTC 2025
Tool: 'shellcheck' not found on PATH. https://github.com/koalaman/shellcheck#installing
Installing shellcheck v0.10.0
shellcheck-v0.10.0/LICENSE.txt
shellcheck-v0.10.0/README.txt
shellcheck-v0.10.0/shellcheck
% './bin/shellcheck' '-fgcc' 'scripts/build-binary.sh' 'scripts/build-docker.sh' 'scripts/build_lib.sh' 'scripts/build-release.sh' 'scripts/build.sh' 'scripts/build_tools.sh' 'scripts/codecov_upload.sh' 'scripts/fix.sh' 'scripts/fuzzing.sh' 'scripts/genproto.sh' 'scripts/markdown_diff_lint.sh' 'scripts/measure-testgrid-flakiness.sh' 'scripts/release_mod.sh' 'scripts/release.sh' 'scripts/sync_go_toolchain_directive.sh' 'scripts/test_images.sh' 'scripts/test_lib.sh' 'scripts/test.sh' 'scripts/test_utils.sh' 'scripts/updatebom.sh' 'scripts/update_dep.sh' 'scripts/update_proto_annotations.sh' 'scripts/verify_genproto.sh' 'scripts/verify_golangci-lint_version.sh' 'scripts/verify_go_versions.sh' 'scripts/verify_proto_annotations.sh'
'shellcheck' PASSED and completed at Mon Jun 23 12:54:45 PM UTC 2025
SUCCESS

Signed-off-by: sprochazka <s.prochazka6@gmail.com>
@k8s-ci-robot
Copy link

Hi @BBQing. Thanks for your PR.

I'm waiting for a etcd-io 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.

@BBQing
Copy link
Author

BBQing commented Jun 23, 2025

@jmhbnz

Signed-off-by: sprochazka <s.prochazka6@gmail.com>
@jmhbnz
Copy link
Member

jmhbnz commented Jun 23, 2025

/ok-to-test

Copy link

codecov bot commented Jun 23, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 69.04%. Comparing base (32eeee6) to head (2e309c1).
Report is 11 commits behind head on main.

Additional details and impacted files

see 34 files with indirect coverage changes

@@            Coverage Diff             @@
##             main   #20205      +/-   ##
==========================================
- Coverage   69.33%   69.04%   -0.30%     
==========================================
  Files         413      410       -3     
  Lines       34367    34232     -135     
==========================================
- Hits        23827    23634     -193     
- Misses       9150     9182      +32     
- Partials     1390     1416      +26     

Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 32eeee6...2e309c1. Read the comment docs.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@BBQing
Copy link
Author

BBQing commented Jun 24, 2025

/test pull-etcd-e2e-amd64

Copy link
Member

@jmhbnz jmhbnz left a comment

Choose a reason for hiding this comment

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

LGTM - Thanks @BBQing

curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b "${GOPATH}/bin" "${GOLANGCI_LINT_VERSION}"
}

GOLANGCI_LINT_VERSION=$(cd tools/mod && go list -m -f '{{.Version}}' github.com/golangci/golangci-lint)
Copy link
Member

Choose a reason for hiding this comment

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

I re-created the issue by opening main in a GitHub codespace (which uses our devcontainer) and I get the same error as described in the linked issue due to the devcontainer having v2.x of golangci-lint installed.

Our configuration file for golangci-lint at tools/.golangci.yaml has not yet been updated to v2.x format so the error is valid.

At some point we need to migrate formats and update golangci-lint, though in the interim this resolves the broken development environment. There was a previous attempt to update the configuration in #19692 howver the pr was closed, @mmorel-35 do you have capacity to open a fresh pr for this migration?

Given our devcontainer environment is listed as a supported development environment we should merge this quickly. cc @ivanvc for a second review prior to merge.

Copy link
Member

Choose a reason for hiding this comment

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

The issue also impacts development against stable release branches in a codespace / devcontainer.

@k8s-ci-robot
Copy link

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: BBQing, jmhbnz

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

@jmhbnz jmhbnz requested a review from ivanvc July 3, 2025 09:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

Successfully merging this pull request may close these issues.

make verify-lint fails on devcontainer
3 participants