-
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?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -13,32 +13,31 @@ | |||||
| # See the License for the specific language governing permissions and | ||||||
| # limitations under the License. | ||||||
|
|
||||||
| # - download golangci-lint if needed (replace existing if incorrect version) | ||||||
| # - run golangci-lint | ||||||
|
|
||||||
| set -o errexit | ||||||
| set -o nounset | ||||||
| set -o pipefail | ||||||
|
|
||||||
| REPO_ROOT=$(dirname "${BASH_SOURCE[0]}")/.. | ||||||
| GOLANGCI_LINT_VER="v1.59.0" | ||||||
| GOLANGCI_LINT_VER="1.59.0" | ||||||
| GOLANGCI_LINT="./bin/golangci-lint" | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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}
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||||||
|
|
||||||
| cd "${REPO_ROOT}" | ||||||
| source "hack/util.sh" | ||||||
| mkdir -p bin | ||||||
|
|
||||||
| if util::cmd_exist golangci-lint ; then | ||||||
| echo "Using golangci-lint version:" | ||||||
| golangci-lint version | ||||||
| else | ||||||
| echo "Installing golangci-lint ${GOLANGCI_LINT_VER}" | ||||||
| # https://golangci-lint.run/usage/install/#other-ci | ||||||
| curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin ${GOLANGCI_LINT_VER} | ||||||
| if ! (test -f "${GOLANGCI_LINT}" && ${GOLANGCI_LINT} --version | grep " ${GOLANGCI_LINT_VER} " >/dev/null); then | ||||||
| rm -f ${GOLANGCI_LINT} && echo "Installing ${GOLANGCI_LINT} ${GOLANGCI_LINT_VER}" | ||||||
| curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b bin -d "v${GOLANGCI_LINT_VER}" | ||||||
| fi | ||||||
|
|
||||||
| if golangci-lint run; then | ||||||
| if ${GOLANGCI_LINT} run; then | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
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. |
||||||
| echo 'Congratulations! All Go source files have passed staticcheck.' | ||||||
| else | ||||||
| echo # print one empty line, separate from warning messages. | ||||||
| echo 'Please review the above warnings.' | ||||||
| echo 'Tips: The golangci-lint might help you fix some issues, try with the command "golangci-lint run --fix".' | ||||||
| echo "Tips: The ${GOLANGCI_LINT} might help you fix some issues, try with the command "${GOLANGCI_LINT} run --fix"." | ||||||
| echo 'If the above warnings do not make sense, feel free to file an issue.' | ||||||
| exit 1 | ||||||
| fi | ||||||
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.
How about mimicking the
_outputdirectory and naming it_toolor_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 havePATH=./binthen 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.
agree