Skip to content

Commit

Permalink
Get tool version from project root
Browse files Browse the repository at this point in the history
Signed-off-by: Ivan Valdes <[email protected]>
  • Loading branch information
ivanvc committed Aug 7, 2024
1 parent 3336a00 commit f0993c0
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 13 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ verify-govet-shadow:
verify-markdown-marker:
PASSES="markdown_marker" ./scripts/test.sh

YAMLFMT_VERSION = $(shell cd tools/mod && go list -m -f '{{.Version}}' github.com/google/yamlfmt)
YAMLFMT_VERSION = $(shell cd go list -m -f '{{.Version}}' github.com/google/yamlfmt)

.PHONY: fix-yamllint
fix-yamllint:
Expand All @@ -173,7 +173,7 @@ endif

# Tools

GOLANGCI_LINT_VERSION = $(shell cd tools/mod && go list -m -f {{.Version}} github.com/golangci/golangci-lint)
GOLANGCI_LINT_VERSION = $(shell go list -m -f {{.Version}} github.com/golangci/golangci-lint)
.PHONY: install-golangci-lint
install-golangci-lint:
ifeq (, $(shell which golangci-lint))
Expand Down
16 changes: 6 additions & 10 deletions scripts/test_lib.sh
Original file line number Diff line number Diff line change
Expand Up @@ -380,14 +380,10 @@ function tool_exists {
function tool_get_bin {
local tool="$1"
local pkg_part="$1"
if [[ "$tool" == *"@"* ]]; then
pkg_part=$(echo "${tool}" | cut -d'@' -f1)
# shellcheck disable=SC2086
run go install ${GOBINARGS:-} "${tool}" || return 2
else
# shellcheck disable=SC2086
run_for_module ./tools/mod run go install ${GOBINARGS:-} "${tool}" || return 2
fi

pkg_part=$(echo "${tool}" | cut -d'@' -f1)
# shellcheck disable=SC2086
run go install ${GOBINARGS:-} "${tool}" || return 2

# remove the version suffix, such as removing "/v3" from "go.etcd.io/etcd/v3".
local cmd_base_name
Expand All @@ -396,13 +392,13 @@ function tool_get_bin {
pkg_part=$(dirname "${pkg_part}")
fi

run_for_module ./tools/mod go list -f '{{.Target}}' "${pkg_part}"
go list -f '{{.Target}}' "${pkg_part}"
}

# tool_pkg_dir [pkg] - returns absolute path to a directory that stores given pkg.
# The pkg versions must be defined in ./tools/mod directory.
function tool_pkg_dir {
run_for_module ./tools/mod run go list -f '{{.Dir}}' "${1}"
run go list -f '{{.Dir}}' "${1}"
}

# tool_get_bin [tool]
Expand Down
2 changes: 1 addition & 1 deletion tests/robustness/makefile.mk
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ test-robustness-issue17529: /tmp/etcd-v3.5.12-beforeSendWatchResponse/bin
# Failpoints

GOPATH = $(shell go env GOPATH)
GOFAIL_VERSION = $(shell cd tools/mod && go list -m -f {{.Version}} go.etcd.io/gofail)
GOFAIL_VERSION = $(shell go list -m -f {{.Version}} go.etcd.io/gofail)

.PHONY:install-gofail
install-gofail: $(GOPATH)/bin/gofail
Expand Down

0 comments on commit f0993c0

Please sign in to comment.