-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
56 lines (40 loc) · 1.31 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
ROOT_DIR := $(shell dirname $(realpath $(lastword $(MAKEFILE_LIST))))
SHELL := /bin/sh
VERSION ?= $(shell git describe --tags --always --dirty --abbrev=0)
SOURCES = $(shell find $(ROOT_DIR) -name "*.go" -print | grep -v /vendor/)
TESTS = $(shell go list ./... | grep -v test/e2e)
GOOS ?= linux
GOARCH ?= amd64
GOPATH ?= $(shell pwd)
COVERAGE_DIR ?= $(PWD)/coverage
export GO111MODULE = on
default: all
all: build check
check: checkfmt test lint
vendor:
go mod vendor
go mod verify
clean:
rm -f build/main
server: build
go build -o ./build/distrox ./cmd/distrox #-gcflags '-m -m'
run: fmt server
./build/distrox
bench:
GOMAXPROCS=4 go test ./pkg/distrox/ -bench='Set|Get' -benchtime=10s
test:
go test -race -v $(TESTS)
coverage:
mkdir -p $(COVERAGE_DIR)
go test -v $(TESTS) -coverpkg=./... -coverprofile=$(COVERAGE_DIR)/coverage.out
go test -v $(TESTS) -coverpkg=./... -covermode=count -coverprofile=$(COVERAGE_DIR)/count.out fmt
go tool cover -func=$(COVERAGE_DIR)/coverage.out
go tool cover -func=$(COVERAGE_DIR)/count.out
go tool cover -html=$(COVERAGE_DIR)/coverage.out -o $(COVERAGE_DIR)/index.html
checkfmt:
@[ -z $$(gofmt -l $(SOURCES)) ] || (echo "Sources not formatted correctly. Fix by running: make fmt" && false)
fmt: $(SOURCES)
gofmt -s -w $(SOURCES)
goimports -w $(SOURCES)
lint:
golangci-lint run