forked from streamdal/plumber
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
120 lines (98 loc) · 3.28 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
VERSION ?= $(shell git rev-parse --short HEAD)
SHORT_SHA ?= $(shell git rev-parse --short HEAD)
GIT_TAG ?= $(shell git describe --tags --abbrev=0)
BINARY = plumber
GO = CGO_ENABLED=$(CGO_ENABLED) GONOPROXY=github.com/batchcorp GOFLAGS=-mod=vendor go
CGO_ENABLED ?= 0
GO_BUILD_FLAGS = -ldflags '-X "github.com/batchcorp/plumber/cli.version=${VERSION}"'
# Pattern #1 example: "example : description = Description for example target"
# Pattern #2 example: "### Example separator text
help: HELP_SCRIPT = \
if (/^([a-zA-Z0-9-\.\/]+).*?: description\s*=\s*(.+)/) { \
printf "\033[34m%-40s\033[0m %s\n", $$1, $$2 \
} elsif(/^\#\#\#\s*(.+)/) { \
printf "\033[33m>> %s\033[0m\n", $$1 \
}
.PHONY: help
help:
@perl -ne '$(HELP_SCRIPT)' $(MAKEFILE_LIST)
### Dev
.PHONY: setup/linux
setup/linux: description = Install dev tools for linux
setup/linux:
GO111MODULE=off go get github.com/maxbrunsfeld/counterfeiter
.PHONY: setup/darwin
setup/darwin: description = Install dev tools for darwin
setup/darwin:
GO111MODULE=off go get github.com/maxbrunsfeld/counterfeiter
.PHONY: run
run: description = Run $(BINARY)
run:
$(GO) run `ls -1 *.go | grep -v _test.go` -d
.PHONY: start/deps
start/deps: description = Start dependencies
start/deps:
docker-compose up -d rabbitmq kafka
### Build
.PHONY: build
build: description = Build $(BINARY)
build: clean build/linux build/darwin build/windows
.PHONY: build/linux
build/linux: description = Build $(BINARY) for linux
build/linux: clean
GOOS=linux GOARCH=amd64 $(GO) build $(GO_BUILD_FLAGS) -o ./build/$(BINARY)-linux
.PHONY: build/darwin
build/darwin: description = Build $(BINARY) for darwin
build/darwin: clean
GOOS=darwin GOARCH=amd64 $(GO) build $(GO_BUILD_FLAGS) -o ./build/$(BINARY)-darwin
.PHONY: build/windows
build/windows: description = Build $(BINARY) for windows
build/windows: clean
GOOS=windows GOARCH=amd64 $(GO) build $(GO_BUILD_FLAGS) -o ./build/$(BINARY)-windows.exe
.PHONY: clean
clean: description = Remove existing build artifacts
clean:
$(RM) ./build/$(BINARY)-*
### Docker
docker/build: description = Build docker image
docker/build:
docker build \
-t batchcorp/$(BINARY):$(SHORT_SHA) \
-t batchcorp/$(BINARY):$(GIT_TAG) \
-t batchcorp/$(BINARY):latest \
-t batchcorp/$(BINARY):local \
-f ./Dockerfile .
.PHONY: docker/push
docker/push: description = Push local docker image
docker/push:
docker push batchcorp/$(BINARY):$(SHORT_SHA) && \
docker push batchcorp/$(BINARY):$(GIT_TAG) && \
docker push batchcorp/$(BINARY):latest
.PHONY: docker/run
docker/run: description = Run local plumber in Docker
docker/run:
docker run --name plumber -p 8080:8080 \
-e PLUMBER_RELAY_TOKEN=48b30466-e3cb-4a58-9905-45b74284709f \
-e PLUMBER_RELAY_GRPC_ADDRESS=localhost:9000 \
-e PLUMBER_RELAY_GRPC_DISABLE_TLS=true \
-e PLUMBER_RELAY_TYPE=aws-sqs \
-e PLUMBER_RELAY_SQS_QUEUE_NAME=PlumberTestQueue \
-e PLUMBER_RELAY_SQS_AUTO_DELETE=true \
-e PLUMBER_DEBUG=true \
-d batchcorp/$(BINARY):local
### Test
.PHONY: test
test: description = Run Go unit tests
test: GOFLAGS=
test:
$(GO) test ./...
.PHONY: testv
testv: description = Run Go unit tests (verbose)
testv: GOFLAGS=
testv:
$(GO) test ./... -v
.PHONY: test/functional
test/functional: description = Run functional tests
test/functional: GOFLAGS=
test/functional:
$(GO) test ./... --tags=functional