-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
58 lines (45 loc) · 1.72 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
all: help
BIN_NAME = netdbg
BIN_FOLDER := bin
COVERAGE_FILE = coverage.out
REPORT_FOLDER = reports
GO_LDFLAGS = -ldflags "-s -w"
help:
@echo ' Usage:'
@echo ' author Display author.'
@echo ' setup Setup development environment.'
@echo ' lint Download Go packages, format and vet.'
@echo ' test Execute tests.'
@echo ' install-lint Download and install golangci-lint.'
@echo ' static-check Execute golangci-lint.'
@echo ' build Compile to binary.'
@echo ' copy-hooks Configure git hooks.'
@echo ' clean Clean binay file.'
author:
@echo " Project by feliux"
@echo " https://github.com/feliux"
setup: install-lint copy-hooks
lint:
go get ./...
go fmt ./...
# golint ./...
go vet ./...
test: lint
go test ./... -coverprofile=$(REPORT_FOLDER)/$(COVERAGE_FILE)
go tool cover -func $(REPORT_FOLDER)/$(COVERAGE_FILE) | grep "total:" | awk '{ print ((int($$3) > 80) != 1) }'
go tool cover -html=$(REPORT_FOLDER)/$(COVERAGE_FILE) -o $(REPORT_FOLDER)/cover.html
check-format:
test -z $$(go fmt ./...) # check fmt command to see if there were any changes. If so, it returns a failing value
install-lint:
sudo curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $$(go env GOPATH)/bin v1.58.2
static-check:
golangci-lint run --issues-exit-code 1
build: lint test check-format static-check
GOARCH=arm64 GOOS=darwin go build $(GO_LDFLAGS) -o $(BIN_FOLDER)/${BIN_NAME}-darwin main.go
GOARCH=amd64 GOOS=linux go build $(GO_LDFLAGS) -o $(BIN_FOLDER)/${BIN_NAME} main.go
GOARCH=amd64 GOOS=windows go build $(GO_LDFLAGS) -o $(BIN_FOLDER)/${BIN_NAME}-windows main.go
copy-hooks:
chmod +x scripts/hooks/pre-commit
cp -r scripts/hooks/* .git/hooks/
clean:
rm -f $(BIN_FOLDER)*