-
Notifications
You must be signed in to change notification settings - Fork 453
/
Makefile
75 lines (61 loc) · 1.88 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
OS := $(shell uname -s)
ARCH := $(shell uname -m)
GO_VERSION := $(shell go version | cut -f3 -d" ")
GO_MINOR_VERSION := $(shell echo $(GO_VERSION) | cut -f2 -d.)
GO_PATCH_VERSION := $(shell echo $(GO_VERSION) | cut -f3 -d. | sed "s/^\s*$$/0/")
MALLOC_ENV := $(shell [ $(OS) = Darwin -a $(GO_MINOR_VERSION) -eq 17 -a $(GO_PATCH_VERSION) -lt 6 ] && echo "MallocNanoZone=0")
.PHONY: all
all: setup build test bench fmt lint
.PHONY: test
test:
# NOTE: https://github.com/golang/go/issues/49138
$(MALLOC_ENV) go test -v -race -timeout 1m ./...
.PHONY: test-e2e
test-e2e: build container.build
scripts/test-e2e
timeout -v --foreground 20m scripts/test-e2e-hazelcast toxiproxy
.PHONY: test-release
test-release: lint fmt test bench test-e2e release-dry
scripts/test-release
.PHONY: bench
bench:
# TODO: Investigate why benchmarks require more sockets: ulimit -n 10240
go test -bench=. -v *.go
go test -bench=. -v toxics/*.go
.PHONY: fmt
fmt:
go fmt ./...
goimports -w **/*.go
golangci-lint run --fix
shfmt -l -s -w -kp -i 2 scripts/test-*
.PHONY: lint
lint:
golangci-lint run
shellcheck scripts/test-*
shfmt -l -s -d -kp -i 2 scripts/test-*
yamllint .
.PHONY: build
build: dist clean
go build -ldflags="-s -w" -o ./dist/toxiproxy-server ./cmd/server
go build -ldflags="-s -w" -o ./dist/toxiproxy-cli ./cmd/cli
.PHONY: container.build
container.build:
env GOOS=linux CGO_ENABLED=0 go build -ldflags="-s -w" -o ./dist/toxiproxy-server-linux-$(ARCH) ./cmd/server
env GOOS=linux CGO_ENABLED=0 go build -ldflags="-s -w" -o ./dist/toxiproxy-cli-linux-$(ARCH) ./cmd/cli
docker build -f Dockerfile -t toxiproxy dist
docker run --rm toxiproxy --version
.PHONY: release
release:
goreleaser release --rm-dist
.PHONY: release-dry
release-dry:
goreleaser release --rm-dist --skip-publish --skip-validate
.PHONY: setup
setup:
go mod download
go mod tidy
dist:
mkdir -p dist
.PHONY: clean
clean:
rm -fr dist/*