Download all dependent binaries into repo/bin

This commit is contained in:
Tomasz Sęk 2021-01-27 16:12:47 +01:00
parent e03b3f25a5
commit ea861d8bd5
No known key found for this signature in database
GPG Key ID: DC356D23F6A644D0
3 changed files with 18 additions and 16 deletions

View File

@ -66,22 +66,22 @@ fmt: ## Verifies all files have been `gofmt`ed
@go fmt $(PACKAGES) @go fmt $(PACKAGES)
.PHONY: lint .PHONY: lint
HAS_GOLINT := $(shell which golangci-lint) HAS_GOLINT := $(shell which $(PROJECT_DIR)/bin/golangci-lint)
lint: ## Verifies `golint` passes lint: ## Verifies `golint` passes
@echo "+ $@" @echo "+ $@"
ifndef HAS_GOLINT ifndef HAS_GOLINT
go get github.com/golangci/golangci-lint/cmd/golangci-lint@v1.26.0 $(call go-get-tool,$(PROJECT_DIR)/bin/golangci-lint,github.com/golangci/golangci-lint/cmd/golangci-lint@v1.26.0)
endif endif
@golangci-lint run @bin/golangci-lint run
.PHONY: goimports .PHONY: goimports
HAS_GOIMPORTS := $(shell which goimports) HAS_GOIMPORTS := $(shell which $(PROJECT_DIR)/bin/goimports)
goimports: ## Verifies `goimports` passes goimports: ## Verifies `goimports` passes
@echo "+ $@" @echo "+ $@"
ifndef HAS_GOIMPORTS ifndef HAS_GOIMPORTS
go get -u golang.org/x/tools/cmd/goimports $(call go-get-tool,$(PROJECT_DIR)/bin/goimports,golang.org/x/tools/cmd/goimports@v0.1.0)
endif endif
@goimports -l -e $(shell find . -type f -name '*.go' -not -path "./vendor/*") @bin/goimports -l -e $(shell find . -type f -name '*.go' -not -path "./vendor/*")
.PHONY: test .PHONY: test
test: ## Runs the go tests test: ## Runs the go tests
@ -99,19 +99,20 @@ vet: ## Verifies `go vet` passes
@echo "+ $@" @echo "+ $@"
@go vet $(PACKAGES) @go vet $(PACKAGES)
#FIXME download to tmp not locally
.PHONY: staticcheck .PHONY: staticcheck
HAS_STATICCHECK := $(shell which staticcheck) HAS_STATICCHECK := $(shell which $(PROJECT_DIR)/bin/staticcheck)
PLATFORM = $(shell echo $(UNAME_S) | tr A-Z a-z) PLATFORM = $(shell echo $(UNAME_S) | tr A-Z a-z)
staticcheck: ## Verifies `staticcheck` passes staticcheck: ## Verifies `staticcheck` passes
@echo "+ $@" @echo "+ $@"
ifndef HAS_STATICCHECK ifndef HAS_STATICCHECK
wget -O staticcheck_$(PLATFORM)_amd64.tar.gz https://github.com/dominikh/go-tools/releases/download/2020.1.3/staticcheck_$(PLATFORM)_amd64.tar.gz $(eval TMP_DIR := $(shell mktemp -d))
tar zxvf staticcheck_$(PLATFORM)_amd64.tar.gz wget -O $(TMP_DIR)/staticcheck_$(PLATFORM)_amd64.tar.gz https://github.com/dominikh/go-tools/releases/download/2020.1.3/staticcheck_$(PLATFORM)_amd64.tar.gz
mkdir -p $(GOPATH)/bin tar zxvf $(TMP_DIR)/staticcheck_$(PLATFORM)_amd64.tar.gz -C $(TMP_DIR)
mv staticcheck/staticcheck $(GOPATH)/bin mkdir -p $(PROJECT_DIR)/bin
mv $(TMP_DIR)/staticcheck/staticcheck $(PROJECT_DIR)/bin
rm -rf $(TMP_DIR)
endif endif
@staticcheck $(PACKAGES) @$(PROJECT_DIR)/bin/staticcheck $(PACKAGES)
.PHONY: cover .PHONY: cover
cover: ## Runs go test with coverage cover: ## Runs go test with coverage
@ -410,7 +411,6 @@ kustomize:
$(call go-get-tool,$(KUSTOMIZE),sigs.k8s.io/kustomize/kustomize/v3@v3.8.7) $(call go-get-tool,$(KUSTOMIZE),sigs.k8s.io/kustomize/kustomize/v3@v3.8.7)
# go-get-tool will 'go get' any package $2 and install it to $1. # go-get-tool will 'go get' any package $2 and install it to $1.
PROJECT_DIR := $(shell dirname $(abspath $(lastword $(MAKEFILE_LIST))))
define go-get-tool define go-get-tool
@[ -f $(1) ] || { \ @[ -f $(1) ] || { \
set -e ;\ set -e ;\

View File

@ -69,7 +69,7 @@ func printInfo() {
func init() { func init() {
utilruntime.Must(clientgoscheme.AddToScheme(scheme)) utilruntime.Must(clientgoscheme.AddToScheme(scheme))
utilruntime.Must(v1alpha2.AddToScheme(scheme)) utilruntime.Must(v1alpha2.AddToScheme(scheme))
utilruntime.Must(routev1.AddToScheme(scheme)) // FIXME optional utilruntime.Must(routev1.AddToScheme(scheme))
utilruntime.Must(corev1.AddToScheme(scheme)) utilruntime.Must(corev1.AddToScheme(scheme))
// +kubebuilder:scaffold:scheme // +kubebuilder:scaffold:scheme
} }

View File

@ -94,4 +94,6 @@ else
GOBIN=$(shell go env GOBIN) GOBIN=$(shell go env GOBIN)
endif endif
ENVTEST_ASSETS_DIR=$(shell pwd)/testbin ENVTEST_ASSETS_DIR=$(shell pwd)/testbin
PROJECT_DIR := $(shell dirname $(abspath $(lastword $(MAKEFILE_LIST))))