forked from streamdal/plumber
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
145 lines (120 loc) · 5.42 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
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/options.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`
.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)-*
### Generation
.PHONY: generate/docs
generate/docs: description = Generate documentation
generate/docs:
go run tools/docs-generator/main.go -type env -output markdown > docs/env.md
### 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_SQS_QUEUE_NAME=PlumberTestQueue \
-e PLUMBER_RELAY_SQS_AUTO_DELETE=true \
-e PLUMBER_DEBUG=true \
-d batchcorp/$(BINARY):local aws-sqs
### 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
.PHONE: test/fakes
test/fakes: description = Generate test fakes
test/fakes: GOFLAGS=
test/fakes:
$(GO) run github.com/maxbrunsfeld/counterfeiter/v6 -o tools/fake_tstorage.go github.com/nakabonne/tstorage.Storage &
$(GO) run github.com/maxbrunsfeld/counterfeiter/v6 -o backends/pulsar/pulsarfakes/fake_pulsar.go github.com/apache/pulsar-client-go/pulsar.Client &
$(GO) run github.com/maxbrunsfeld/counterfeiter/v6 -o backends/pulsar/pulsarfakes/fake_producer.go github.com/apache/pulsar-client-go/pulsar.Producer &
$(GO) run github.com/maxbrunsfeld/counterfeiter/v6 -o backends/pulsar/pulsarfakes/fake_consumer.go github.com/apache/pulsar-client-go/pulsar.Consumer &
$(GO) run github.com/maxbrunsfeld/counterfeiter/v6 -o backends/pulsar/pulsarfakes/fake_message.go github.com/apache/pulsar-client-go/pulsar.Message &
$(GO) run github.com/maxbrunsfeld/counterfeiter/v6 -o backends/pulsar/pulsarfakes/fake_messageid.go github.com/apache/pulsar-client-go/pulsar.MessageID &
$(GO) run github.com/maxbrunsfeld/counterfeiter/v6 -o backends/mqtt/mqttfakes/fake_mqtt.go github.com/eclipse/paho.mqtt.golang.Client &
$(GO) run github.com/maxbrunsfeld/counterfeiter/v6 -o backends/rabbitmq/rabbitfakes/fake_rabbit.go github.com/batchcorp/rabbit.IRabbit &
$(GO) run github.com/maxbrunsfeld/counterfeiter/v6 -o backends/awssns/snsfakes/fake_sns.go github.com/aws/aws-sdk-go/service/sns/snsiface.SNSAPI &
$(GO) run github.com/maxbrunsfeld/counterfeiter/v6 -o backends/awssqs/sqsfakes/fake_sqs.go github.com/aws/aws-sdk-go/service/sqs/sqsiface.SQSAPI &
$(GO) run github.com/maxbrunsfeld/counterfeiter/v6 -o backends/awskinesis/kinesisfakes/fake_kinesis.go github.com/aws/aws-sdk-go/service/kinesis/kinesisiface.KinesisAPI &
$(GO) run github.com/maxbrunsfeld/counterfeiter/v6 -o backends/nats-streaming/stanfakes/fake_stan.go github.com/nats-io/stan.go.Conn &
$(GO) run github.com/maxbrunsfeld/counterfeiter/v6 -o backends/nats-streaming/stanfakes/fake_subscription.go github.com/nats-io/stan.go.Subscription &
$(GO) generate ./...