forked from travis-ci/worker
/
Makefile
91 lines (72 loc) · 2.41 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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
PACKAGE_CHECKOUT := $(shell echo ${PWD})
PACKAGE := github.com/travis-ci/worker
ALL_PACKAGES := $(shell utils/list-packages) $(PACKAGE)/cmd/...
VERSION_VAR := $(PACKAGE).VersionString
VERSION_VALUE ?= $(shell git describe --always --dirty --tags 2>/dev/null)
REV_VAR := $(PACKAGE).RevisionString
REV_VALUE ?= $(shell git rev-parse HEAD 2>/dev/null || echo "'???'")
REV_URL_VAR := $(PACKAGE).RevisionURLString
REV_URL_VALUE ?= https://github.com/travis-ci/worker/tree/$(shell git rev-parse HEAD 2>/dev/null || echo "'???'")
GENERATED_VAR := $(PACKAGE).GeneratedString
GENERATED_VALUE ?= $(shell date -u +'%Y-%m-%dT%H:%M:%S%z')
COPYRIGHT_VAR := $(PACKAGE).CopyrightString
COPYRIGHT_VALUE ?= $(shell grep -i ^copyright LICENSE | sed 's/^[Cc]opyright //')
GO ?= go
GOXC ?= goxc
GVT ?= gvt
GOPATH := $(shell echo $${GOPATH%%:*})
GOBUILD_LDFLAGS ?= \
-X '$(VERSION_VAR)=$(VERSION_VALUE)' \
-X '$(REV_VAR)=$(REV_VALUE)' \
-X '$(REV_URL_VAR)=$(REV_URL_VALUE)' \
-X '$(GENERATED_VAR)=$(GENERATED_VALUE)' \
-X '$(COPYRIGHT_VAR)=$(COPYRIGHT_VALUE)'
export GO15VENDOREXPERIMENT
COVERPROFILES := \
backend-coverage.coverprofile \
config-coverage.coverprofile \
context-coverage.coverprofile \
image-coverage.coverprofile \
metrics-coverage.coverprofile
%-coverage.coverprofile:
$(GO) test -v -covermode=count -coverprofile=$@ \
-x -ldflags "$(GOBUILD_LDFLAGS)" \
$(PACKAGE)/$(subst -,/,$(subst -coverage.coverprofile,,$@))
.PHONY: %
%:
./utils/$@
.PHONY: all
all: clean test
.PHONY: test
test: deps lintall build fmtpolice test-no-cover coverage.html
.PHONY: test-no-cover
test-no-cover:
$(GO) test -v -x -ldflags "$(GOBUILD_LDFLAGS)" $(ALL_PACKAGES)
.PHONY: test-race
test-race: deps
$(GO) test -v -race -x -ldflags "$(GOBUILD_LDFLAGS)" $(ALL_PACKAGES)
coverage.html: coverage.coverprofile
$(GO) tool cover -html=$^ -o $@
coverage.coverprofile: $(COVERPROFILES)
./utils/fold-coverprofiles $^ > $@
$(GO) tool cover -func=$@
.PHONY: build
build: deps
$(GO) install -x -ldflags "$(GOBUILD_LDFLAGS)" $(ALL_PACKAGES)
.PHONY: crossbuild
crossbuild: .crossdeps deps
$(GOXC) -pv=$(VERSION_VALUE) -build-ldflags "$(GOBUILD_LDFLAGS)" xc
.crossdeps:
GOROOT_BOOTSTRAP=$(GOROOT) $(GOXC) -t
touch $@
.PHONY: distclean
distclean: clean
rm -f vendor/.deps-fetched
.PHONY: deps
deps: vendor/.deps-fetched
vendor/.deps-fetched:
$(GVT) rebuild
touch $@
.PHONY: annotations
annotations:
@git grep -E '(TODO|FIXME|XXX):' | grep -v -E 'Makefile|vendor/'