forked from manifoldco/promptui
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Makefile
65 lines (47 loc) · 1.77 KB
/
Makefile
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
LINTERS=$(shell grep "// lint" tools.go | awk '{gsub(/\"/, "", $$1); print $$1}' | awk -F / '{print $$NF}') \
gofmt \
vet
ci: $(LINTERS) cover
.PHONY: ci
#################################################
# Bootstrapping for base golang package and tool deps
#################################################
CMD_PKGS=$(shell grep ' "' tools.go | awk -F '"' '{print $$2}')
define VENDOR_BIN_TMPL
vendor/bin/$(notdir $(1)): vendor/$(1) | vendor
go build -a -o $$@ ./vendor/$(1)
VENDOR_BINS += vendor/bin/$(notdir $(1))
vendor/$(1): vendor
endef
$(foreach cmd_pkg,$(CMD_PKGS),$(eval $(call VENDOR_BIN_TMPL,$(cmd_pkg))))
$(patsubst %,%-bin,$(filter-out gofmt vet,$(LINTERS))): %-bin: vendor/bin/%
gofmt-bin vet-bin:
vendor: go.sum
GO111MODULE=on go mod vendor
mod-update:
GO111MODULE=on go get -u -m
GO111MODULE=on go mod tidy
mod-tidy:
GO111MODULE=on go mod tidy
.PHONY: $(CMD_PKGS)
.PHONY: mod-update mod-tidy
#################################################
# Test and linting
#################################################
test: vendor
CGO_ENABLED=0 go test $$(go list ./... | grep -v generated)
$(LINTERS): %: vendor/bin/gometalinter %-bin vendor
PATH=`pwd`/vendor/bin:$$PATH gometalinter --tests --disable-all --vendor \
--deadline=5m -s data --enable $@ ./...
COVER_TEST_PKGS:=$(shell find . -type f -name '*_test.go' | grep -v vendor | rev | cut -d "/" -f 2- | rev | grep -v generated | sort -u)
$(COVER_TEST_PKGS:=-cover): %-cover: all-cover.txt
@CGO_ENABLED=0 go test -v -coverprofile=$@.out -covermode=atomic ./$*
@if [ -f $@.out ]; then \
grep -v "mode: atomic" < $@.out >> all-cover.txt; \
rm $@.out; \
fi
all-cover.txt:
echo "mode: atomic" > all-cover.txt
cover: vendor all-cover.txt $(COVER_TEST_PKGS:=-cover)
.PHONY: $(LINTERS) test
.PHONY: cover all-cover.txt