-
-
Notifications
You must be signed in to change notification settings - Fork 6
/
Makefile
65 lines (46 loc) · 1.33 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
APP_NAME = teler-proxy
VERSION = $(shell git describe --always --tags)
GO_MOD_VERSION := $(shell grep -Po '^go \K([0-9]+\.[0-9]+(\.[0-9]+)?)$$' go.mod)
GO := go${GO_MOD_VERSION}
GO_LDFLAGS = "-s -w -X 'github.com/teler-sh/teler-proxy/common.Version=${VERSION}'"
ifeq ($(shell which ${GO}),)
GO = go
endif
vet:
$(GO) vet ./...
lint:
golangci-lint run --tests=false ./...
semgrep:
semgrep --config auto
bench:
$(GO) test ./pkg/tunnel/... -run "^$$" -bench . -cpu 4 -benchmem $(ARGS)
cover: FILE := /tmp/teler-coverage.out # Define coverage file
cover: PKG := ./pkg/tunnel/...
cover:
$(GO) test -race -coverprofile=$(FILE) -covermode=atomic $(PKG)
$(GO) tool cover -func=$(FILE)
pprof: ARGS := -cpuprofile=cpu.out -memprofile=mem.out -benchtime 30s
pprof: bench
pgo: pprof
pgo:
cp cpu.out default.pgo
test:
$(GO) test -race -v ./pkg/tunnel/...
test-all: test vet lint semgrep
report:
goreportcard-cli
build:
@echo "Building binary"
@mkdir -p bin/
CGO_ENABLED="1" go build -ldflags ${GO_LDFLAGS} -trimpath $(ARGS) -o ./bin/${APP_NAME} ./cmd/${APP_NAME}
build-pgo: ARGS := -pgo=$(shell pwd)/default.pgo
build-pgo: build
docker:
@echo "Building image"
docker build -t ${APP_NAME}:latest --build-arg="VERSION=${VERSION}" .
clean:
@echo "Removing binaries"
@rm -rf bin/
teler-proxy: build
ci: vet build clean
all: test report build