mirror of https://github.com/helm/helm
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
184 lines
4.7 KiB
184 lines
4.7 KiB
BINDIR := $(CURDIR)/bin
|
|
DIST_DIRS := find * -type d -exec
|
|
TARGETS := darwin/amd64 linux/amd64 linux/386 linux/arm linux/arm64 linux/ppc64le windows/amd64
|
|
BINNAME ?= helm
|
|
|
|
GOPATH = $(shell go env GOPATH)
|
|
DEP = $(GOPATH)/bin/dep
|
|
GOX = $(GOPATH)/bin/gox
|
|
GOIMPORTS = $(GOPATH)/bin/goimports
|
|
GOLANGCI_LINT = $(GOPATH)/bin/golangci-lint
|
|
|
|
ACCEPTANCE_DIR:=$(GOPATH)/src/helm.sh/acceptance-testing
|
|
# To specify the subset of acceptance tests to run. '.' means all tests
|
|
ACCEPTANCE_RUN_TESTS=.
|
|
|
|
# go option
|
|
PKG := ./...
|
|
TAGS :=
|
|
TESTS := .
|
|
TESTFLAGS :=
|
|
LDFLAGS := -w -s
|
|
GOFLAGS :=
|
|
SRC := $(shell find . -type f -name '*.go' -print)
|
|
|
|
# Required for globs to work correctly
|
|
SHELL = /bin/bash
|
|
|
|
GIT_COMMIT = $(shell git rev-parse HEAD)
|
|
GIT_SHA = $(shell git rev-parse --short HEAD)
|
|
GIT_TAG = $(shell git describe --tags --abbrev=0 --exact-match 2>/dev/null)
|
|
GIT_DIRTY = $(shell test -n "`git status --porcelain`" && echo "dirty" || echo "clean")
|
|
|
|
ifdef VERSION
|
|
BINARY_VERSION = $(VERSION)
|
|
endif
|
|
BINARY_VERSION ?= ${GIT_TAG}
|
|
|
|
# Only set Version if building a tag or VERSION is set
|
|
ifneq ($(BINARY_VERSION),)
|
|
LDFLAGS += -X helm.sh/helm/internal/version.version=${BINARY_VERSION}
|
|
endif
|
|
|
|
# Clear the "unreleased" string in BuildMetadata
|
|
ifneq ($(GIT_TAG),)
|
|
LDFLAGS += -X helm.sh/helm/internal/version.metadata=
|
|
endif
|
|
LDFLAGS += -X helm.sh/helm/internal/version.gitCommit=${GIT_COMMIT}
|
|
LDFLAGS += -X helm.sh/helm/internal/version.gitTreeState=${GIT_DIRTY}
|
|
|
|
.PHONY: all
|
|
all: build
|
|
|
|
# ------------------------------------------------------------------------------
|
|
# build
|
|
|
|
.PHONY: build
|
|
build: $(BINDIR)/$(BINNAME)
|
|
|
|
$(BINDIR)/$(BINNAME): $(SRC) vendor
|
|
go build $(GOFLAGS) -tags '$(TAGS)' -ldflags '$(LDFLAGS)' -o $(BINDIR)/$(BINNAME) helm.sh/helm/cmd/helm
|
|
|
|
# ------------------------------------------------------------------------------
|
|
# test
|
|
|
|
.PHONY: test
|
|
test: build
|
|
test: TESTFLAGS += -race -v
|
|
test: test-style
|
|
test: test-unit
|
|
|
|
.PHONY: test-unit
|
|
test-unit: vendor
|
|
@echo
|
|
@echo "==> Running unit tests <=="
|
|
go test $(GOFLAGS) -run $(TESTS) $(PKG) $(TESTFLAGS)
|
|
|
|
.PHONY: test-coverage
|
|
test-coverage: vendor
|
|
@echo
|
|
@echo "==> Running unit tests with coverage <=="
|
|
@ ./scripts/coverage.sh
|
|
|
|
.PHONY: test-style
|
|
test-style: vendor $(GOLANGCI_LINT)
|
|
$(GOLANGCI_LINT) run
|
|
@scripts/validate-license.sh
|
|
|
|
.PHONY: test-acceptance
|
|
test-acceptance: TARGETS = linux/amd64
|
|
test-acceptance: build build-cross
|
|
@if [ -d "${ACCEPTANCE_DIR}" ]; then \
|
|
cd ${ACCEPTANCE_DIR} && \
|
|
ROBOT_RUN_TESTS=$(ACCEPTANCE_RUN_TESTS) ROBOT_HELM_PATH=$(BINDIR) make acceptance; \
|
|
else \
|
|
echo "You must clone the acceptance_testing repo under $(ACCEPTANCE_DIR)"; \
|
|
echo "You can find the acceptance_testing repo at https://github.com/helm/acceptance-testing"; \
|
|
fi
|
|
|
|
.PHONY: test-acceptance-completion
|
|
test-acceptance-completion: ACCEPTANCE_RUN_TESTS = shells.robot
|
|
test-acceptance-completion: test-acceptance
|
|
|
|
.PHONY: verify-docs
|
|
verify-docs: build
|
|
@scripts/verify-docs.sh
|
|
|
|
.PHONY: coverage
|
|
coverage:
|
|
@scripts/coverage.sh
|
|
|
|
.PHONY: format
|
|
format: $(GOIMPORTS)
|
|
go list -f '{{.Dir}}' ./... | xargs $(GOIMPORTS) -w -local helm.sh/helm
|
|
|
|
# ------------------------------------------------------------------------------
|
|
# dependencies
|
|
|
|
.PHONY: bootstrap
|
|
bootstrap: vendor
|
|
|
|
$(DEP):
|
|
go get -u github.com/golang/dep/cmd/dep
|
|
|
|
$(GOX):
|
|
go get -u github.com/mitchellh/gox
|
|
|
|
$(GOLANGCI_LINT):
|
|
go get -u github.com/golangci/golangci-lint/cmd/golangci-lint
|
|
|
|
$(GOIMPORTS):
|
|
go get -u golang.org/x/tools/cmd/goimports
|
|
|
|
# install vendored dependencies
|
|
vendor: Gopkg.lock
|
|
$(DEP) ensure --vendor-only
|
|
|
|
# update vendored dependencies
|
|
Gopkg.lock: Gopkg.toml
|
|
$(DEP) ensure --no-vendor
|
|
|
|
Gopkg.toml: $(DEP)
|
|
|
|
# ------------------------------------------------------------------------------
|
|
# release
|
|
|
|
.PHONY: build-cross
|
|
build-cross: LDFLAGS += -extldflags "-static"
|
|
build-cross: vendor
|
|
build-cross: $(GOX)
|
|
CGO_ENABLED=0 $(GOX) -parallel=3 -output="_dist/{{.OS}}-{{.Arch}}/$(BINNAME)" -osarch='$(TARGETS)' $(GOFLAGS) -tags '$(TAGS)' -ldflags '$(LDFLAGS)' helm.sh/helm/cmd/helm
|
|
|
|
.PHONY: dist
|
|
dist:
|
|
( \
|
|
cd _dist && \
|
|
$(DIST_DIRS) cp ../LICENSE {} \; && \
|
|
$(DIST_DIRS) cp ../README.md {} \; && \
|
|
$(DIST_DIRS) tar -zcf helm-${VERSION}-{}.tar.gz {} \; && \
|
|
$(DIST_DIRS) zip -r helm-${VERSION}-{}.zip {} \; \
|
|
)
|
|
|
|
.PHONY: checksum
|
|
checksum:
|
|
for f in _dist/*.{gz,zip} ; do \
|
|
shasum -a 256 "$${f}" | awk '{print $$1}' > "$${f}.sha256" ; \
|
|
done
|
|
|
|
# ------------------------------------------------------------------------------
|
|
|
|
.PHONY: docs
|
|
docs: build
|
|
@scripts/update-docs.sh
|
|
|
|
.PHONY: clean
|
|
clean:
|
|
@rm -rf $(BINDIR) ./_dist
|
|
|
|
.PHONY: info
|
|
info:
|
|
@echo "Version: ${VERSION}"
|
|
@echo "Git Tag: ${GIT_TAG}"
|
|
@echo "Git Commit: ${GIT_COMMIT}"
|
|
@echo "Git Tree State: ${GIT_DIRTY}"
|