Skip to content

Conversation

@grosser
Copy link
Contributor

@grosser grosser commented Jul 28, 2024

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:

./hack/verify-staticcheck.sh
Installing golangci-lint v1.59.0
golangci/golangci-lint info checking GitHub for tag 'v1.59.0'
golangci/golangci-lint info found version: 1.59.0 for v1.59.0/darwin/arm64
golangci/golangci-lint info installed /Users/mgrosser/go/bin/golangci-lint
./hack/verify-staticcheck.sh: line 36: golangci-lint: command not found

Please review the above warnings.
Tips: The golangci-lint might help you fix some issues, try with the command "golangci-lint run --fix".
If the above warnings do not make sense, feel free to file an issue.

also it uses whatever random local version a user might have installed which is unreliable

Does this PR introduce a user-facing change?:

NONE

@karmada-bot karmada-bot added kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. kind/failing-test Categorizes issue or PR as related to a consistently or frequently failing test. labels Jul 28, 2024
@karmada-bot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign rainbowmango for approval. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found here.

Details 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

@karmada-bot karmada-bot added the size/S Denotes a PR that changes 10-29 lines, ignoring generated files. label Jul 28, 2024
@codecov-commenter
Copy link

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 28.24%. Comparing base (21b330c) to head (7605b69).

❗ 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     
Flag Coverage Δ
unittests 28.24% <ø> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@XiShanYongYe-Chang
Copy link
Member

/retest
/cc @chaosi-zju

@karmada-bot karmada-bot requested a review from chaosi-zju July 29, 2024 01:56
@zhzhuang-zju
Copy link
Contributor

./hack/verify-staticcheck.sh: line 36: golangci-lint: command not found

Refer to

curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin ${GOLANGCI_LINT_VER}

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"
Copy link
Contributor

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.

Copy link
Contributor Author

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 🤷

Copy link
Contributor

@liangyuanpeng liangyuanpeng Jul 29, 2024

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}

Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor Author

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

Copy link
Contributor

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/

@grosser
Copy link
Contributor Author

grosser commented Jul 29, 2024

I know why the error happened, but I don't want it to happen + I want it to use the correct version

@chaosi-zju
Copy link
Member

also it uses whatever random local version a user might have installed which is unreliable

I think this makes sense.

Maybe the user himself has installed an unexpected version of binary under /usr/local/bin. When we execute the golangci-lint run command, we may use an unexpected version.

No matter where we place the binary we download, it would be better to use absolute paths.

# Folders used by make
_tmp/
_output/
bin/
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
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.

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 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

Copy link
Contributor

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
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
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.

@XiShanYongYe-Chang
Copy link
Member

Hi @grosser, how is it going now?

@grosser
Copy link
Contributor Author

grosser commented Aug 3, 2024

afaik this is ready to merge
... then can make more PRs to move the other local tools to ./bin (did not check how many more there are)

@XiShanYongYe-Chang
Copy link
Member

There seems to be some discussion going on.

@grosser
Copy link
Contributor Author

grosser commented Aug 3, 2024

yeah, not sure where that discussion is going or what the exact proposal is
... still think bin/ is the best and would work for everyone

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind/cleanup Categorizes issue or PR as related to cleaning up code, process, or technical debt. kind/failing-test Categorizes issue or PR as related to a consistently or frequently failing test. 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.

7 participants