update Makefile
This commit is contained in:
parent
4682cea41f
commit
671c108032
27
Makefile
27
Makefile
@ -32,10 +32,12 @@ GOFLAGS :=
|
|||||||
BINDIR := $(CURDIR)/bin
|
BINDIR := $(CURDIR)/bin
|
||||||
BINARIES := k3d
|
BINARIES := k3d
|
||||||
|
|
||||||
|
K3D_IMAGE_TAG := $(GIT_TAG)
|
||||||
|
|
||||||
# Go Package required
|
# Go Package required
|
||||||
PKG_GOX := github.com/mitchellh/gox@v1.0.1
|
PKG_GOX := github.com/mitchellh/gox@v1.0.1
|
||||||
PKG_GOLANGCI_LINT_VERSION := 1.22.2
|
PKG_GOLANGCI_LINT_VERSION := 1.22.2
|
||||||
|
PKG_GOLANGCI_LINT_SCRIPT := https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh
|
||||||
PKG_GOLANGCI_LINT := github.com/golangci/golangci-lint/cmd/golangci-lint@v${PKG_GOLANGCI_LINT_VERSION}
|
PKG_GOLANGCI_LINT := github.com/golangci/golangci-lint/cmd/golangci-lint@v${PKG_GOLANGCI_LINT_VERSION}
|
||||||
|
|
||||||
# configuration adjustments for golangci-lint
|
# configuration adjustments for golangci-lint
|
||||||
@ -62,12 +64,16 @@ LINT_DIRS := $(DIRS) $(foreach dir,$(REC_DIRS),$(dir)/...)
|
|||||||
all: clean fmt check build
|
all: clean fmt check build
|
||||||
|
|
||||||
build:
|
build:
|
||||||
CGO_ENABLED=0 $(GO) build -i $(GOFLAGS) -tags '$(TAGS)' -ldflags '$(LDFLAGS)' -o '$(BINDIR)/$(BINARIES)'
|
CGO_ENABLED=0 $(GO) build $(GOFLAGS) -tags '$(TAGS)' -ldflags '$(LDFLAGS)' -o '$(BINDIR)/$(BINARIES)'
|
||||||
|
|
||||||
build-cross: LDFLAGS += -extldflags "-static"
|
build-cross: LDFLAGS += -extldflags "-static"
|
||||||
build-cross:
|
build-cross:
|
||||||
CGO_ENABLED=0 gox -parallel=3 -output="_dist/$(BINARIES)-{{.OS}}-{{.Arch}}" -osarch='$(TARGETS)' $(GOFLAGS) $(if $(TAGS),-tags '$(TAGS)',) -ldflags '$(LDFLAGS)'
|
CGO_ENABLED=0 gox -parallel=3 -output="_dist/$(BINARIES)-{{.OS}}-{{.Arch}}" -osarch='$(TARGETS)' $(GOFLAGS) $(if $(TAGS),-tags '$(TAGS)',) -ldflags '$(LDFLAGS)'
|
||||||
|
|
||||||
|
build-docker: Dockerfile
|
||||||
|
@echo "Building Docker image k3d:$(K3D_IMAGE_TAG)"
|
||||||
|
docker build -t k3d:$(K3D_IMAGE_TAG) .
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
@rm -rf $(BINDIR) _dist/
|
@rm -rf $(BINDIR) _dist/
|
||||||
|
|
||||||
@ -79,6 +85,9 @@ extra-clean: clean
|
|||||||
fmt:
|
fmt:
|
||||||
@gofmt -s -l -w $(GO_SRC)
|
@gofmt -s -l -w $(GO_SRC)
|
||||||
|
|
||||||
|
e2e: build-docker
|
||||||
|
@echo "Running e2e tests in k3d:$(K3D_IMAGE_TAG)"
|
||||||
|
tests/dind.sh "${K3D_IMAGE_TAG}"
|
||||||
# check-fmt returns an error code if any source code contains format error.
|
# check-fmt returns an error code if any source code contains format error.
|
||||||
check-fmt:
|
check-fmt:
|
||||||
@test -z $(shell gofmt -s -l $(GO_SRC) | tee /dev/stderr) || echo "[WARN] Fix formatting issues with 'make fmt'"
|
@test -z $(shell gofmt -s -l $(GO_SRC) | tee /dev/stderr) || echo "[WARN] Fix formatting issues with 'make fmt'"
|
||||||
@ -98,15 +107,27 @@ ifndef HAS_GOX
|
|||||||
($(GO) get $(PKG_GOX))
|
($(GO) get $(PKG_GOX))
|
||||||
endif
|
endif
|
||||||
ifndef HAS_GOLANGCI
|
ifndef HAS_GOLANGCI
|
||||||
(curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh| sh -s -- -b ${GOPATH}/bin v${PKG_GOLANGCI_LINT_VERSION})
|
(curl -sfL $(PKG_GOLANGCI_LINT_SCRIPT) | sh -s -- -b ${GOPATH}/bin v${PKG_GOLANGCI_LINT_VERSION})
|
||||||
endif
|
endif
|
||||||
ifdef HAS_GOLANGCI
|
ifdef HAS_GOLANGCI
|
||||||
ifeq ($(HAS_GOLANGCI_VERSION),)
|
ifeq ($(HAS_GOLANGCI_VERSION),)
|
||||||
ifdef INTERACTIVE
|
ifdef INTERACTIVE
|
||||||
@echo "Warning: Your installed version of golangci-lint (interactive: ${INTERACTIVE}) differs from what we'd like to use. Switch to v${PKG_GOLANGCI_LINT_VERSION}? [Y/n]"
|
@echo "Warning: Your installed version of golangci-lint (interactive: ${INTERACTIVE}) differs from what we'd like to use. Switch to v${PKG_GOLANGCI_LINT_VERSION}? [Y/n]"
|
||||||
@read line; if [ $$line == "y" ]; then (curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh| sh -s -- -b ${GOPATH}/bin v${PKG_GOLANGCI_LINT_VERSION}); fi
|
@read line; if [ $$line == "y" ]; then (curl -sfL $(PKG_GOLANGCI_LINT_SCRIPT) | sh -s -- -b ${GOPATH}/bin v${PKG_GOLANGCI_LINT_VERSION}); fi
|
||||||
else
|
else
|
||||||
@echo "Warning: you're not using the same version of golangci-lint as us (v${PKG_GOLANGCI_LINT_VERSION})"
|
@echo "Warning: you're not using the same version of golangci-lint as us (v${PKG_GOLANGCI_LINT_VERSION})"
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
ci-setup:
|
||||||
|
@echo "Installing Go tools..."
|
||||||
|
curl -sfL $(PKG_GOLANGCI_LINT_SCRIPT) | sh -s -- -b ${GOPATH}/bin v$(PKG_GOLANGCI_LINT_VERSION)
|
||||||
|
go get $(PKG_GOX)
|
||||||
|
|
||||||
|
@echo "Installing kubectl..."
|
||||||
|
curl -LO https://storage.googleapis.com/kubernetes-release/release/`curl -s https://storage.googleapis.com/kubernetes-release/release/stable.txt`/bin/linux/amd64/kubectl
|
||||||
|
chmod +x ./kubectl
|
||||||
|
sudo mv ./kubectl /usr/local/bin/kubectl
|
||||||
|
|
||||||
|
ci-tests: fmt check e2e
|
||||||
|
Loading…
Reference in New Issue
Block a user