-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
77 lines (54 loc) · 2.21 KB
/
Copy pathMakefile
File metadata and controls
77 lines (54 loc) · 2.21 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
PACKAGES = $(shell go list ./...)
TEST_PACKAGES = $(shell go list ./src/... | grep -v vendor)
.PHONY: build fmt test test-cover-html test-cover-func collect-cover-data
export GO15VENDOREXPERIMENT=1
# Used to populate version variable in main package.
VERSION=$(shell git describe --always --tags --abbre=0)
BUILD_TIME=$(shell date -u +%Y-%m-%d:%H-%M-%S)
PKG=$(shell go list .)
gitCommit=$(shell git describe --tags)
gitDirty=$(shell git status --porcelain --untracked-files=no)
GIT_COMMIT=$(gitCommit)
ifneq ($(gitDirty),"")
GIT_COMMIT=$(gitCommit)-dirty
endif
GO_LDFLAGS=-X $(PKG)/src/version.version=$(VERSION) -X $(PKG)/src/version.gitCommit=$(GIT_COMMIT) -X $(PKG)/src/version.buildTime=$(BUILD_TIME) -w
default: build
docker-build:
docker run --rm -w /go/src/github.com/Dataman-Cloud/swan -e CGO_ENABLED=0 -e GOOS=linux -e GOARCH=amd64 -v $(shell pwd):/go/src/github.com/Dataman-Cloud/swan golang:1.8.1-alpine sh -c 'go build -ldflags "${GO_LDFLAGS}" -v -o bin/swan main.go'
build: fmt
go build -ldflags "${GO_LDFLAGS}" -v -o bin/swan main.go
install:
install -v bin/swan /usr/local/bin
install -v bin/swancfg /usr/local/bin
generate:
go generate ./src/manager/framework/state/constraints.go
clean:
rm -rf bin/*
fmt:
go fmt ./src/...
test:
go test -cover=true ${TEST_PACKAGES}
collect-cover-data:
@echo "mode: count" > coverage-all.out
$(foreach pkg,$(TEST_PACKAGES),\
go test -v -coverprofile=coverage.out -covermode=count $(pkg) || exit $?;\
if [ -f coverage.out ]; then\
tail -n +2 coverage.out >> coverage-all.out;\
fi\
;)
test-cover-html:
go tool cover -html=coverage-all.out -o coverage.html
test-cover-func:
go tool cover -func=coverage-all.out
release: list-authors
list-authors:
./contrib/list-authors.sh
build-docker-image:
docker build --tag swan:$(VERSION) --rm .
docker-run-manager-init:
docker rm -f swan-manager 2>&1 || echo 0
docker run --interactive --tty --env-file ./contrib/envfiles/Envfile_manager --name swan-manager --rm -p 9999:9999 swan:$(VERSION) manager
docker-run-agent:
docker rm -f swan-agent 2>&1 || echo 0
docker run --interactive --tty --env-file ./contrib/envfiles/Envfile_agent --name swan-agent --rm -p 9998:9998 -p 53:53/udp -p 80:80 -p 5000:5000 swan:$(VERSION) agent