-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
64 lines (48 loc) · 1.73 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
all: push
BUILDTAGS=
# Use the 0.0.0 tag for testing, it shouldn't clobber any release builds
APP=cicd
USERSPACE?=k8s-community
RELEASE?=0.5.0
PROJECT?=github.com/${USERSPACE}/${APP}
GOOS?=linux
# App configuration: what service to listen to etc
SERVICE_HOST?=0.0.0.0
SERVICE_PORT?=8080
GITHUBINT_BASE_URL?=https://services.k8s.community/k8s-community/github-integration
REPO_INFO=$(shell git config --get remote.origin.url)
ifndef COMMIT
COMMIT := git-$(shell git rev-parse --short HEAD)
endif
build:
cd service \
&& CGO_ENABLED=0 GOOS=${GOOS} go build -a -installsuffix cgo \
-ldflags "-s -w -X ${PROJECT}/version.RELEASE=${RELEASE} -X ${PROJECT}/version.COMMIT=${COMMIT} -X ${PROJECT}/version.REPO=${REPO_INFO}" \
-o ../${APP}
install: build
sudo ./${APP} install --service-host ${SERVICE_HOST} --service-port ${SERVICE_PORT} \
--githubint-base-url ${GITHUBINT_BASE_URL}
remove:
sudo ./${APP} remove
stop:
sudo ./${APP} stop
start:
sudo ./${APP} start
fmt:
@echo "+ $@"
@go list -f '{{if len .TestGoFiles}}"gofmt -s -l {{.Dir}}"{{end}}' $(shell go list ${PROJECT}/... | grep -v vendor) | xargs -L 1 sh -c
lint: utils
@echo "+ $@"
go get -u github.com/golang/lint/golint
@go list -f '{{if len .TestGoFiles}}"golint {{.Dir}}/..."{{end}}' $(shell go list ${PROJECT}/... | grep -v vendor) | xargs -L 1 sh -c
vet:
@echo "+ $@"
@go vet $(shell go list ${PROJECT}/... | grep -v vendor)
test: utils fmt lint vet
@echo "+ $@"
@go test -v -race -tags "$(BUILDTAGS) cgo" $(shell go list ${PROJECT}/... | grep -v vendor)
cover:
@echo "+ $@"
@go list -f '{{if len .TestGoFiles}}"go test -coverprofile={{.Dir}}/.coverprofile {{.ImportPath}}"{{end}}' $(shell go list ${PROJECT}/... | grep -v vendor) | xargs -L 1 sh -c
clean:
rm -f ${APP}