github.com/diafour/helm@v3.0.0-beta.3+incompatible/Makefile (about)

     1  BINDIR     := $(CURDIR)/bin
     2  DIST_DIRS  := find * -type d -exec
     3  TARGETS    := darwin/amd64 linux/amd64 linux/386 linux/arm linux/arm64 linux/ppc64le windows/amd64
     4  BINNAME    ?= helm
     5  
     6  GOPATH        = $(shell go env GOPATH)
     7  DEP           = $(GOPATH)/bin/dep
     8  GOX           = $(GOPATH)/bin/gox
     9  GOIMPORTS     = $(GOPATH)/bin/goimports
    10  GOLANGCI_LINT = $(GOPATH)/bin/golangci-lint
    11  
    12  ACCEPTANCE_DIR:=$(GOPATH)/src/helm.sh/acceptance-testing
    13  # To specify the subset of acceptance tests to run. '.' means all tests
    14  ACCEPTANCE_RUN_TESTS=.
    15  
    16  # go option
    17  PKG        := ./...
    18  TAGS       :=
    19  TESTS      := .
    20  TESTFLAGS  :=
    21  LDFLAGS    := -w -s
    22  GOFLAGS    :=
    23  SRC        := $(shell find . -type f -name '*.go' -print)
    24  
    25  # Required for globs to work correctly
    26  SHELL      = /bin/bash
    27  
    28  GIT_COMMIT = $(shell git rev-parse HEAD)
    29  GIT_SHA    = $(shell git rev-parse --short HEAD)
    30  GIT_TAG    = $(shell git describe --tags --abbrev=0 --exact-match 2>/dev/null)
    31  GIT_DIRTY  = $(shell test -n "`git status --porcelain`" && echo "dirty" || echo "clean")
    32  
    33  ifdef VERSION
    34  	BINARY_VERSION = $(VERSION)
    35  endif
    36  BINARY_VERSION ?= ${GIT_TAG}
    37  
    38  # Only set Version if building a tag or VERSION is set
    39  ifneq ($(BINARY_VERSION),)
    40  	LDFLAGS += -X helm.sh/helm/internal/version.version=${BINARY_VERSION}
    41  endif
    42  
    43  # Clear the "unreleased" string in BuildMetadata
    44  ifneq ($(GIT_TAG),)
    45  	LDFLAGS += -X helm.sh/helm/internal/version.metadata=
    46  endif
    47  LDFLAGS += -X helm.sh/helm/internal/version.gitCommit=${GIT_COMMIT}
    48  LDFLAGS += -X helm.sh/helm/internal/version.gitTreeState=${GIT_DIRTY}
    49  
    50  .PHONY: all
    51  all: build
    52  
    53  # ------------------------------------------------------------------------------
    54  #  build
    55  
    56  .PHONY: build
    57  build: $(BINDIR)/$(BINNAME)
    58  
    59  $(BINDIR)/$(BINNAME): $(SRC) vendor
    60  	go build $(GOFLAGS) -tags '$(TAGS)' -ldflags '$(LDFLAGS)' -o $(BINDIR)/$(BINNAME) helm.sh/helm/cmd/helm
    61  
    62  # ------------------------------------------------------------------------------
    63  #  test
    64  
    65  .PHONY: test
    66  test: build
    67  test: TESTFLAGS += -race -v
    68  test: test-style
    69  test: test-unit
    70  
    71  .PHONY: test-unit
    72  test-unit: vendor
    73  	@echo
    74  	@echo "==> Running unit tests <=="
    75  	go test $(GOFLAGS) -run $(TESTS) $(PKG) $(TESTFLAGS)
    76  
    77  .PHONY: test-coverage
    78  test-coverage: vendor
    79  	@echo
    80  	@echo "==> Running unit tests with coverage <=="
    81  	@ ./scripts/coverage.sh
    82  
    83  .PHONY: test-style
    84  test-style: vendor $(GOLANGCI_LINT)
    85  	$(GOLANGCI_LINT) run
    86  	@scripts/validate-license.sh
    87  
    88  .PHONY: test-acceptance
    89  test-acceptance: TARGETS = linux/amd64
    90  test-acceptance: build build-cross
    91  	@if [ -d "${ACCEPTANCE_DIR}" ]; then \
    92  		cd ${ACCEPTANCE_DIR} && \
    93  			ROBOT_RUN_TESTS=$(ACCEPTANCE_RUN_TESTS) ROBOT_HELM_PATH=$(BINDIR) make acceptance; \
    94  	else \
    95  		echo "You must clone the acceptance_testing repo under $(ACCEPTANCE_DIR)"; \
    96  		echo "You can find the acceptance_testing repo at https://github.com/helm/acceptance-testing"; \
    97  	fi
    98  
    99  .PHONY: test-acceptance-completion
   100  test-acceptance-completion: ACCEPTANCE_RUN_TESTS = shells.robot
   101  test-acceptance-completion: test-acceptance
   102  
   103  .PHONY: verify-docs
   104  verify-docs: build
   105  	@scripts/verify-docs.sh
   106  
   107  .PHONY: coverage
   108  coverage:
   109  	@scripts/coverage.sh
   110  
   111  .PHONY: format
   112  format: $(GOIMPORTS)
   113  	go list -f '{{.Dir}}' ./... | xargs $(GOIMPORTS) -w -local helm.sh/helm
   114  
   115  # ------------------------------------------------------------------------------
   116  #  dependencies
   117  
   118  .PHONY: bootstrap
   119  bootstrap: vendor
   120  
   121  $(DEP):
   122  	go get -u github.com/golang/dep/cmd/dep
   123  
   124  $(GOX):
   125  	go get -u github.com/mitchellh/gox
   126  
   127  $(GOLANGCI_LINT):
   128  	go get -u github.com/golangci/golangci-lint/cmd/golangci-lint
   129  
   130  $(GOIMPORTS):
   131  	go get -u golang.org/x/tools/cmd/goimports
   132  
   133  # install vendored dependencies
   134  vendor: Gopkg.lock
   135  	$(DEP) ensure --vendor-only
   136  
   137  # update vendored dependencies
   138  Gopkg.lock: Gopkg.toml
   139  	$(DEP) ensure --no-vendor
   140  
   141  Gopkg.toml: $(DEP)
   142  
   143  # ------------------------------------------------------------------------------
   144  #  release
   145  
   146  .PHONY: build-cross
   147  build-cross: LDFLAGS += -extldflags "-static"
   148  build-cross: vendor
   149  build-cross: $(GOX)
   150  	CGO_ENABLED=0 $(GOX) -parallel=3 -output="_dist/{{.OS}}-{{.Arch}}/$(BINNAME)" -osarch='$(TARGETS)' $(GOFLAGS) -tags '$(TAGS)' -ldflags '$(LDFLAGS)' helm.sh/helm/cmd/helm
   151  
   152  .PHONY: dist
   153  dist:
   154  	( \
   155  		cd _dist && \
   156  		$(DIST_DIRS) cp ../LICENSE {} \; && \
   157  		$(DIST_DIRS) cp ../README.md {} \; && \
   158  		$(DIST_DIRS) tar -zcf helm-${VERSION}-{}.tar.gz {} \; && \
   159  		$(DIST_DIRS) zip -r helm-${VERSION}-{}.zip {} \; \
   160  	)
   161  
   162  .PHONY: checksum
   163  checksum:
   164  	for f in _dist/*.{gz,zip} ; do \
   165  		shasum -a 256 "$${f}"  | awk '{print $$1}' > "$${f}.sha256" ; \
   166  	done
   167  
   168  # ------------------------------------------------------------------------------
   169  
   170  .PHONY: docs
   171  docs: build
   172  	@scripts/update-docs.sh
   173  
   174  .PHONY: clean
   175  clean:
   176  	@rm -rf $(BINDIR) ./_dist
   177  
   178  .PHONY: info
   179  info:
   180  	 @echo "Version:           ${VERSION}"
   181  	 @echo "Git Tag:           ${GIT_TAG}"
   182  	 @echo "Git Commit:        ${GIT_COMMIT}"
   183  	 @echo "Git Tree State:    ${GIT_DIRTY}"