forked from Aptomi/k8s-app-engine
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
203 lines (164 loc) · 5.21 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
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
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
GIT_VERSION=dev-$(shell git describe --tags --long --dirty)
GIT_COMMIT=$(shell git rev-parse HEAD)
BUILD_DATE=$(shell date -u +'%Y-%m-%dT%H:%M:%SZ')
GOENV=env CGO_ENABLED=0
GOFLAGS=-ldflags "-X github.com/Aptomi/aptomi/pkg/version.gitVersion=${GIT_VERSION} -X github.com/Aptomi/aptomi/pkg/version.gitCommit=${GIT_COMMIT} -X github.com/Aptomi/aptomi/pkg/version.buildDate=${BUILD_DATE}"
GO=${GOENV} go
.PHONY: default
default: clean build test
.PHONY: vendor
vendor: prepare_glide
ifndef JENKINS_HOME
${GOENV} glide install --strip-vendor
else
${GOENV} glide --no-color install --strip-vendor
endif
cd webui; npm install
.PHONY: profile-engine
profile-engine:
@echo "Profiling CPU for 30 seconds"
${GO} test -bench . -benchtime 30s ./pkg/engine/apply -cpuprofile cpu.out
${GO} tool pprof -svg apply.test cpu.out > profile.svg
.PHONY: coverage
coverage:
@echo "Calculating code coverage (unit tests only)"
echo 'mode: atomic' > coverage.out && ${GO} list ./... | xargs -n1 -I{} sh -c "echo -n '' > coverage.tmp && ${GO} test -short -covermode=atomic -coverprofile=coverage.tmp {} && tail -n +2 coverage.tmp >> coverage.out" && rm coverage.tmp
${GO} tool cover -html=coverage.out -o coverage.html
.PHONY: coverage-full
coverage-full:
@echo "Calculating code coverage (unit and integration tests)"
echo 'mode: atomic' > coverage.out && ${GO} list ./... | xargs -n1 -I{} sh -c "echo -n '' > coverage.tmp && ${GO} test -covermode=atomic -coverprofile=coverage.tmp {} && tail -n +2 coverage.tmp >> coverage.out" && rm coverage.tmp
${GO} tool cover -html=coverage.out -o coverage.html
.PHONY: coverage-publish
coverage-publish: prepare_goveralls
BUILD_NUMBER="" goveralls -coverprofile coverage.out
.PHONY: test
test:
tools/with_etcd.sh ${GO} test -short -v ./...
@echo "\nAll unit tests passed"
.PHONY: test-race
test-race:
CGO_ENABLED=1 go test -race -short -v ./...
@echo "\nNo race conditions detected. Unit tests passed"
.PHONY: alltest
alltest: prepare_go_junit_report
ifndef JENKINS_HOME
tools/with_etcd.sh ${GO} test -v ./...
else
tools/with_etcd.sh ${GO} test -v ./... 2>&1 | go-junit-report | tee junit.xml
endif
${GO} test -bench . -count 1 ./pkg/engine/...
@echo "\nAll tests passed (unit, integration, benchmark)"
.PHONY: test-loop
test-loop:
while ${GO} test -v ./...; do :; done
.PHONY: smoke
smoke: install alltest
tools/smoke.sh
.PHONY: embed-ui
embed-ui: prepare_filebox
find webui -type f | grep -v '/node_modules' | grep -v '/dist' | sort | xargs shasum 2>/dev/null | shasum > .ui_hash_current
if diff .ui_hash_current .ui_hash_previous; then echo 'No changes in UI. Skipping UI build'; else rm -rf pkg/server/ui/*b0x*; cd webui; npm run build; cd ..; fileb0x webui/b0x.yaml; fi
cp .ui_hash_current .ui_hash_previous
#
# IMPORTANT
#
# Make sure to update .goreleaser.yml if doing any changes to build process
#
.PHONY: build
build: embed-ui
${GO} build ${GOFLAGS} -v -i ./...
${GO} build ${GOFLAGS} -v -i -o aptomi github.com/Aptomi/aptomi/cmd/aptomi
${GO} build ${GOFLAGS} -v -i -o aptomictl github.com/Aptomi/aptomi/cmd/aptomictl
#
# IMPORTANT
#
# Make sure to update .goreleaser.yml if doing any changes to install process
#
.PHONY: install
install: build
${GO} install -v ${GOFLAGS} github.com/Aptomi/aptomi/cmd/aptomi
${GO} install -v ${GOFLAGS} github.com/Aptomi/aptomi/cmd/aptomictl
.PHONY: release
release: prepare_goreleaser
goreleaser --rm-dist
tools/publish-charts.sh
.PHONY: fmt
fmt:
${GO} fmt ./...
${GOENV} goimports -w cmd examples pkg
.PHONY: clean
clean:
-rm -f aptomi aptomictl .ui_hash_current .ui_hash_previous
${GO} clean -r -i
.PHONY: lint
lint: prepare_golangci_lint embed-ui
ifdef JENKINS_HOME
${GOENV} golangci-lint run --out-format checkstyle | tee checkstyle.xml
else
${GOENV} golangci-lint run
endif
HAS_GOLANGCI_LINT := $(shell command -v golangci-lint)
.PHONY: prepare_golangci_lint
prepare_golangci_lint:
ifndef HAS_GOLANGCI_LINT
${GO} get -u gopkg.in/golangci/golangci-lint.v1/cmd/golangci-lint
endif
.PHONY: toc
toc: prepare_doctoc
doctoc README.md
doctoc docs/language.md
HAS_DOCTOC := $(shell command -v doctoc)
.PHONY: prepare_doctoc
prepare_doctoc:
ifndef HAS_DOCTOC
npm install -g doctoc
endif
HAS_GLIDE := $(shell command -v glide)
.PHONY: prepare_glide
prepare_glide:
ifndef HAS_GLIDE
${GO} get -u github.com/Masterminds/glide
endif
HAS_GO_JUNIT_REPORT := $(shell command -v go-junit-report)
.PHONY: prepare_go_junit_report
prepare_go_junit_report:
ifndef HAS_GO_JUNIT_REPORT
${GO} get -u github.com/jstemmer/go-junit-report
endif
HAS_GOVERALLS := $(shell command -v goveralls)
.PHONY: prepare_goveralls
prepare_goveralls:
ifndef HAS_GOVERALLS
${GO} get -u github.com/mattn/goveralls
endif
HAS_FILEBOX := $(shell command -v fileb0x)
.PHONY: prepare_filebox
prepare_filebox:
ifndef HAS_FILEBOX
${GO} get -u github.com/UnnoTed/fileb0x
endif
HAS_GORELEASER := $(shell command -v goreleaser)
.PHONY: prepare_goreleaser
prepare_goreleaser:
ifndef HAS_GORELEASER
${GO} get -u github.com/goreleaser/goreleaser
endif
.PHONY: w-dep
w-dep:
cd webui; npm install
.PHONY: w-test
w-test:
cd webui; npm test
.PHONY: w-test-unit
w-test-unit:
cd webui; npm run unit
.PHONY: w-test-e2e
w-test-e2e:
cd webui; npm run e2e
.PHONY: w-dev
w-dev:
cd webui; npm run dev
.PHONY: w-build
w-build:
cd webui; npm run build