-
Notifications
You must be signed in to change notification settings - Fork 1k
make golangci-lint run locally with correct version #5266
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
base: master
Are you sure you want to change the base?
Conversation
|
[APPROVALNOTIFIER] This PR is NOT APPROVED This pull-request has been approved by: The full list of commands accepted by this bot can be found here. DetailsNeeds approval from an approver in each of these files:Approvers can indicate their approval by writing |
Signed-off-by: Michael Grosser <[email protected]>
|
Codecov ReportAll modified and coverable lines are covered by tests ✅
❗ Your organization needs to install the Codecov GitHub app to enable full functionality. Additional details and impacted files@@ Coverage Diff @@
## master #5266 +/- ##
==========================================
+ Coverage 28.23% 28.24% +0.01%
==========================================
Files 632 632
Lines 43753 43753
==========================================
+ Hits 12355 12360 +5
+ Misses 30496 30493 -3
+ Partials 902 900 -2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
|
/retest |
Refer to karmada/hack/verify-staticcheck.sh Line 33 in 21b330c
In fact, when golang-lint is not present, a specific version of golang-lint is automatically downloaded to the path $(go env GOPATH)/bin. Based on the output of your script, it appears that the download was successful, but ultimately resulted in a "command not found" error. This may be because the path $(go env GOPATH) is not included in your $PATH. You can check what paths are included in your current $PATH by running the command echo $PATH.
|
| REPO_ROOT=$(dirname "${BASH_SOURCE[0]}")/.. | ||
| GOLANGCI_LINT_VER="v1.59.0" | ||
| GOLANGCI_LINT_VER="1.59.0" | ||
| GOLANGCI_LINT="./bin/golangci-lint" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
seems like you want to download the tools to the project folder and not GOPATH, I think this makes sense, but currently karmada downloads tools into GOPATH, which might be worth discussing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yeah, other tools would need to follow that pattern, so better get consensus
idk of any reason not to do it 🤷
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't have much background here, I think it would be possible to add a parameter to have the tool download to the specifically directory, defaulting to gopath, what do you think?
Maybe:
GO_PATH=$(go env GOPATH)
TOOLS_PATH=${TOOLS_PATH:-$GO_PATH}There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that would fix the error
if we also want the correct version it would need to switch and replace the binaries in gopath depending on what version the current project needs, should mostly be fine just weird when using different projects with different version requirements
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we can provide the capability to install to a specific path, but considering that minimizing the impact on users who may have already installed their own golang-lint, the default path could be set to ./bin/
|
I know why the error happened, but I don't want it to happen + I want it to use the correct version |
I think this makes sense. Maybe the user himself has installed an unexpected version of binary under No matter where we place the binary we download, it would be better to use absolute paths. |
| # Folders used by make | ||
| _tmp/ | ||
| _output/ | ||
| bin/ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| bin/ | |
| _tool |
How about mimicking the _output directory and naming it _tool or _bin? This directory can be specifically used to place tools for maintaining Karmada.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the beauty of bin/ is that if users have PATH=./bin then things "just work" :)
not against _tool either to be consistent with the other _ folders
never really saw a project use _ folders 🤷
everything could be in tmp/ (tmp/output tmp/bin/ etc)
but either way is fine for me
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
the beauty of bin/ is that if users have PATH=./bin then things "just work" :)
agree
| fi | ||
|
|
||
| if golangci-lint run; then | ||
| if ${GOLANGCI_LINT} run; then |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| if ${GOLANGCI_LINT} run; then | |
| if $(go env GOPATH)/bin/golangci-lint run; then |
maybe this is enough to solve your problem.
As for where to put the downloaded files, we can continue to discuss in the above comment.
|
Hi @grosser, how is it going now? |
|
afaik this is ready to merge |
|
There seems to be some discussion going on. |
|
yeah, not sure where that discussion is going or what the exact proposal is |
What type of PR is this?
/kind cleanup
/kind failing-test
Issues:
ref
What this PR does / why we need it:
currently verify-staticcheck does not work for me:
also it uses whatever random local version a user might have installed which is unreliable
Does this PR introduce a user-facing change?: