forked from Shopify/toxiproxy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
66 lines (53 loc) · 1.44 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
OS := $(shell uname -s)
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
scripts/test-e2e
.PHONY: test-release
test-release: 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: 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/*