forked from zalando/skipper
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
161 lines (126 loc) · 5.49 KB
/
Makefile
File metadata and controls
161 lines (126 loc) · 5.49 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
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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
SOURCES = $(shell find . -name '*.go' -not -path "./vendor/*" -and -not -path "./_test_plugins" -and -not -path "./_test_plugins_fail" )
PACKAGES = $(shell go list ./...)
CURRENT_VERSION = $(shell git describe --tags --always --dirty)
VERSION ?= $(CURRENT_VERSION)
NEXT_MAJOR = $(shell go run packaging/version/version.go major $(CURRENT_VERSION))
NEXT_MINOR = $(shell go run packaging/version/version.go minor $(CURRENT_VERSION))
NEXT_PATCH = $(shell go run packaging/version/version.go patch $(CURRENT_VERSION))
COMMIT_HASH = $(shell git rev-parse --short HEAD)
TEST_ETCD_VERSION ?= v2.3.8
TEST_PLUGINS = _test_plugins/filter_noop.so \
_test_plugins/predicate_match_none.so \
_test_plugins/dataclient_noop.so \
_test_plugins/multitype_noop.so \
_test_plugins_fail/fail.so
GO111 ?= on
default: build
lib: $(SOURCES)
GO111MODULE=$(GO111) go build $(PACKAGES)
bindir:
mkdir -p bin
skipper: $(SOURCES) bindir
GO111MODULE=$(GO111) go build -ldflags "-X main.version=$(VERSION) -X main.commit=$(COMMIT_HASH)" -o bin/skipper ./cmd/skipper/*.go
eskip: $(SOURCES) bindir
GO111MODULE=$(GO111) go build -ldflags "-X main.version=$(VERSION) -X main.commit=$(COMMIT_HASH)" -o bin/eskip ./cmd/eskip/*.go
build: $(SOURCES) lib skipper eskip
build.osx:
GOOS=darwin GOARCH=amd64 CGO_ENABLED=0 GO111MODULE=on go build -o bin/skipper -ldflags "-X main.version=$(VERSION) -X main.commit=$(COMMIT_HASH)" ./cmd/skipper
build.windows:
GOOS=windows GOARCH=amd64 CGO_ENABLED=0 GO111MODULE=on go build -o bin/skipper -ldflags "-X main.version=$(VERSION) -X main.commit=$(COMMIT_HASH)" ./cmd/skipper
install: $(SOURCES)
GO111MODULE=on go install -ldflags "-X main.version=$(VERSION) -X main.commit=$(COMMIT_HASH)" ./cmd/skipper
GO111MODULE=on go install -ldflags "-X main.version=$(VERSION) -X main.commit=$(COMMIT_HASH)" ./cmd/eskip
check: build check-plugins
# go test $(PACKAGES)
#
# due to vendoring and how go test ./... is not the same as go test ./a/... ./b/...
# probably can be reverted once etcd is fully mocked away for tests
#
for p in $(PACKAGES); do GO111MODULE=on go test $$p || break; done
shortcheck: build check-plugins
# go test -test.short -run ^Test $(PACKAGES)
#
# due to vendoring and how go test ./... is not the same as go test ./a/... ./b/...
# probably can be reverted once etcd is fully mocked away for tests
#
for p in $(PACKAGES); do GO111MODULE=on go test -test.short -run ^Test $$p || break -1; done
check-plugins: $(TEST_PLUGINS)
GO111MODULE=on go test -run LoadPlugins
_test_plugins/%.so: _test_plugins/%.go
GO111MODULE=on go build -buildmode=plugin -o $@ $<
_test_plugins_fail/%.so: _test_plugins_fail/%.go
GO111MODULE=on go build -buildmode=plugin -o $@ $<
bench: build $(TEST_PLUGINS)
# go test -bench . $(PACKAGES)
#
# due to vendoring and how go test ./... is not the same as go test ./a/... ./b/...
# probably can be reverted once etcd is fully mocked away for tests
#
for p in $(PACKAGES); do GO111MODULE=on go test -bench . $$p; done
lint: build
gometalinter --enable-all --deadline=60s ./... | tee linter.log
clean:
go clean -i -cache -testcache ./...
rm -rf .coverprofile-all .cover
rm -f ./_test_plugins/*.so
rm -f ./_test_plugins_fail/*.so
deps:
./etcd/install.sh $(TEST_ETCD_VERSION)
vet: $(SOURCES)
GO111MODULE=on go vet $(PACKAGES)
fmt: $(SOURCES)
@gofmt -w -s $(SOURCES)
check-fmt: $(SOURCES)
@if [ "$$(gofmt -d $(SOURCES))" != "" ]; then false; else true; fi
precommit: fmt build shortcheck vet
check-precommit: check-fmt build shortcheck vet
.coverprofile-all: $(SOURCES) $(TEST_PLUGINS)
# go list -f \
# '{{if len .TestGoFiles}}"go test -coverprofile={{.Dir}}/.coverprofile {{.ImportPath}}"{{end}}' \
# $(PACKAGES) | xargs -i sh -c {}
#
# due to vendoring and how go test ./... is not the same as go test ./a/... ./b/...
# probably can be reverted once etcd is fully mocked away for tests
#
for p in $(PACKAGES); do \
go list -f \
'{{if len .TestGoFiles}}"GO111MODULE=on go test -coverprofile={{.Dir}}/.coverprofile {{.ImportPath}}"{{end}}' \
$$p | xargs -i sh -c {}; \
done
go get github.com/modocache/gover
gover . .coverprofile-all
cover: .coverprofile-all
go tool cover -func .coverprofile-all
show-cover: .coverprofile-all
go tool cover -html .coverprofile-all
publish-coverage: .coverprofile-all
curl -s https://codecov.io/bash -o codecov
bash codecov -f .coverprofile-all
tag:
git tag $(VERSION)
push-tags:
git push --tags https://$(GITHUB_AUTH)@github.com/zalando/skipper
release-major:
make VERSION=$(NEXT_MAJOR) tag push-tags
release-minor:
make VERSION=$(NEXT_MINOR) tag push-tags
release-patch:
make VERSION=$(NEXT_PATCH) tag push-tags
ci-user:
git config --global user.email "builds@travis-ci.com"
git config --global user.name "Travis CI"
ci-release-major: ci-user deps release-major
ci-release-minor: ci-user deps release-minor
ci-release-patch: ci-user deps release-patch
ci-trigger:
ifeq ($(TRAVIS_BRANCH)_$(TRAVIS_PULL_REQUEST)_$(findstring major-release,$(TRAVIS_COMMIT_MESSAGE)), master_false_major-release)
make deps publish-coverage ci-release-major
else ifeq ($(TRAVIS_BRANCH)_$(TRAVIS_PULL_REQUEST)_$(findstring minor-release,$(TRAVIS_COMMIT_MESSAGE)), master_false_minor-release)
make deps publish-coverage ci-release-minor
else ifeq ($(TRAVIS_BRANCH)_$(TRAVIS_PULL_REQUEST), master_false)
make deps publish-coverage ci-release-patch
else ifeq ($(TRAVIS_BRANCH), master)
make deps check-precommit
else
make deps shortcheck check-plugins
endif