1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78
|
# Set V to 1 for verbose output from the Makefile
Q=$(if $V,,@)
PREFIX?=
SRC=$(shell find . -type f -name '*.go' -not -path "./vendor/*")
GOOS_OVERRIDE ?=
OUTPUT_ROOT=output/
all: test lint
travis: travis-test lint
.PHONY: all
#########################################
# Bootstrapping
#########################################
bootstra%:
$Q GO111MODULE=on go get github.com/golangci/golangci-lint/cmd/golangci-lint@v1.24.0
.PHONY: bootstra%
#################################################
# Determine the type of `push` and `version`
#################################################
# Version flags to embed in the binaries
VERSION ?= $(shell [ -d .git ] && git describe --tags --always --dirty="-dev")
# If we are not in an active git dir then try reading the version from .VERSION.
# .VERSION contains a slug populated by `git archive`.
VERSION := $(or $(VERSION),$(shell ./.version.sh .VERSION))
VERSION := $(shell echo $(VERSION) | sed 's/^v//')
NOT_RC := $(shell echo $(VERSION) | grep -v -e -rc)
# If TRAVIS_TAG is set then we know this ref has been tagged.
ifdef TRAVIS_TAG
ifeq ($(NOT_RC),)
PUSHTYPE=release-candidate
else
PUSHTYPE=release
endif
else
PUSHTYPE=master
endif
#########################################
# Test
#########################################
test:
$Q $(GOFLAGS) go test -short -coverprofile=coverage.out ./...
travis-test:
$Q $(GOFLAGS) TRAVIS=1 go test -short -coverprofile=coverage.out ./...
.PHONY: test travis-test
#########################################
# Linting
#########################################
fmt:
$Q gofmt -l -w $(SRC)
lint:
$Q LOG_LEVEL=error golangci-lint run
.PHONY: lint fmt
#########################################
# Clean
#########################################
clean:
ifneq ($(BINNAME),"")
$Q rm -f bin/$(BINNAME)
endif
.PHONY: clean
|