-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
48 lines (37 loc) · 1.23 KB
/
Makefile
File metadata and controls
48 lines (37 loc) · 1.23 KB
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
GO_SRC_FILES = $(shell find . -type f -name '*.go' | sed /vendor/d )
GO_SRC_PACKAGES =$(shell go list ./... | sed /vendor/d )
GOLINT_SRC = ./vendor/github.com/golang/lint/golint
# vanity
GREEN = \033[0;32m
MAGENTA = \033[0;35m
RESET = \033[0;0m
# setup
.PHONY: setup
setup: vendor bin/golint
vendor: Gopkg.toml Gopkg.lock
@echo "$(GREEN)installing vendored dependencies...$(RESET)"
@# use the vendor-only flag to prevent us from removing dependencies before
@# they are added to the docker container
@dep ensure -v --vendor-only
bin/golint: vendor
@echo "$(MAGENTA)building $(@)...$(RESET)"
@go build -o $(@) $(GOLINT_SRC)
# build
.PHONY: build
build: bin/logfmt2json
GO_BUILD_LDFLAGS=-s -w -X github.com/ntindall/logfmt2json/cmd.version=$(shell git tag --list | tail -n 1)
bin/logfmt2json: $(GO_SRC_FILES)
@echo "$(MAGENTA)building $(@)...$(RESET)"
go build -ldflags "$(GO_BUILD_LDFLAGS)" -o bin/logfmt2json ./logfmt2json.go
.PHONY: test
test: go-test go-lint build
.PHONY: lint
lint: go-lint
.PHONY: go-test
go-test:
@echo "$(MAGENTA)running go tests...$(RESET)"
@go test -v $(GO_SRC_PACKAGES)
.PHONY: go-lint
go-lint: bin/golint
@echo "$(MAGENTA)linting $(GO_SRC_PACKAGES)$(RESET)"
@bin/golint -set_exit_status $(GO_SRC_PACKAGES)