forked from Shopify/toxiproxy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
76 lines (60 loc) · 2.94 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
SERVER_NAME=toxiproxy-server
CLI_NAME=toxiproxy-cli
VERSION=$(shell cat VERSION)
DEB=pkg/toxiproxy_$(VERSION)_amd64.deb
GODEP_PATH=$(shell pwd)/vendor
ORIGINAL_PATH=$(shell echo $(GOPATH))
COMBINED_GOPATH=$(GODEP_PATH):$(ORIGINAL_PATH)
.PHONY: packages deb test linux darwin windows
build:
GOPATH=$(COMBINED_GOPATH) go build -ldflags="-X github.com/Shopify/toxiproxy.Version=git-$(shell git rev-parse --short HEAD)" -o $(SERVER_NAME) ./cmd
GOPATH=$(COMBINED_GOPATH) go build -ldflags="-X github.com/Shopify/toxiproxy.Version=git-$(shell git rev-parse --short HEAD)" -o $(CLI_NAME) ./cli
all: deb linux darwin windows
deb: $(DEB)
darwin: tmp/build/$(SERVER_NAME)-darwin-amd64 tmp/build/$(CLI_NAME)-darwin-amd64
linux: tmp/build/$(SERVER_NAME)-linux-amd64 tmp/build/$(CLI_NAME)-linux-amd64
windows: tmp/build/$(SERVER_NAME)-windows-amd64.exe tmp/build/$(CLI_NAME)-windows-amd64.exe
release: all docker-release
clean:
rm -f tmp/build/*
rm -f $(SERVER_NAME)
rm -f $(CLI_NAME)
rm -f *.deb
test:
echo "Testing with" `go version`
GOMAXPROCS=4 GOPATH=$(COMBINED_GOPATH) go test -v -race ./...
tmp/build/$(SERVER_NAME)-linux-amd64:
GOOS=linux GOARCH=amd64 GOPATH=$(COMBINED_GOPATH) go build -ldflags="-X github.com/Shopify/toxiproxy.Version=$(VERSION)" -o $(@) ./cmd
tmp/build/$(SERVER_NAME)-darwin-amd64:
GOOS=darwin GOARCH=amd64 GOPATH=$(COMBINED_GOPATH) go build -ldflags="-X github.com/Shopify/toxiproxy.Version=$(VERSION)" -o $(@) ./cmd
tmp/build/$(SERVER_NAME)-windows-amd64.exe:
GOOS=windows GOARCH=amd64 GOPATH=$(COMBINED_GOPATH) go build -ldflags="-X github.com/Shopify/toxiproxy.Version=$(VERSION)" -o $(@) ./cmd
tmp/build/$(CLI_NAME)-linux-amd64:
GOOS=linux GOARCH=amd64 GOPATH=$(COMBINED_GOPATH) go build -ldflags="-X github.com/Shopify/toxiproxy.Version=$(VERSION)" -o $(@) ./cli
tmp/build/$(CLI_NAME)-darwin-amd64:
GOOS=darwin GOARCH=amd64 GOPATH=$(COMBINED_GOPATH) go build -ldflags="-X github.com/Shopify/toxiproxy.Version=$(VERSION)" -o $(@) ./cli
tmp/build/$(CLI_NAME)-windows-amd64.exe:
GOOS=windows GOARCH=amd64 GOPATH=$(COMBINED_GOPATH) go build -ldflags="-X github.com/Shopify/toxiproxy.Version=$(VERSION)" -o $(@) ./cli
$(DEB): tmp/build/$(SERVER_NAME)-linux-amd64 tmp/build/$(CLI_NAME)-linux-amd64
fpm -t deb \
-s dir \
-p tmp/build/ \
--name "toxiproxy" \
--version $(VERSION) \
--license MIT \
--no-depends \
--no-auto-depends \
--architecture amd64 \
--maintainer "Simon Eskildsen <[email protected]>" \
--description "TCP proxy to simulate network and system conditions" \
--url "https://github.com/Shopify/toxiproxy" \
$(word 1,$^)=/usr/bin/$(SERVER_NAME) \
$(word 2,$^)=/usr/bin/$(CLI_NAME) \
./share/toxiproxy.conf=/etc/init/toxiproxy.conf
docker:
docker build --tag="shopify/toxiproxy:git" .
docker-release: linux
docker build --rm=true --tag="idamf/toxiproxy:$(VERSION)" .
docker tag idamf/toxiproxy:$(VERSION) idamf/toxiproxy:latest
docker push idamf/toxiproxy:$(VERSION)
docker push idamf/toxiproxy:latest