-
Notifications
You must be signed in to change notification settings - Fork 11
/
Makefile
67 lines (55 loc) · 1.55 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
GOCMD=go
GOSECCMD=gosec
GOBUILD=$(GOCMD) build
GOCLEAN=$(GOCMD) clean
GOTEST=$(GOCMD) test -v ./...
GOGET=$(GOCMD) get -u -v
OS := $(shell uname -s | awk '{print tolower($$0)}')
BINARY = app
GOARCH = amd64
LDFLAGS = -ldflags="$$(govvv -flags)"
SHELL=/bin/bash
.PHONY: tools
tools:
go get golang.org/x/tools/cmd/goimports
go get github.com/kisielk/errcheck
go get github.com/golangci/golangci-lint/cmd/golangci-lint
go get github.com/axw/gocov/gocov
go get github.com/matm/gocov-html
go get github.com/ahmetb/govvv
go get github.com/cespare/reflex
go get github.com/swaggo/swag/cmd/swag
go get github.com/securego/gosec/v2/cmd/gosec
pip install pre-commit
pre-commit install
.PHONY: run
run: bin
./$(BINARY)-$(OS)-$(GOARCH) # Execute the binary
.PHONY: watch
watch:
reflex -s -r '\.go$$' go run cmd/main.go
.PHONY: bin
bin:
env CGO_ENABLED=0 GOOS=$(OS) GOARCH=${GOARCH} go build -a -installsuffix cgo ${LDFLAGS} -o ${BINARY}-$(OS)-${GOARCH} cmd/main.go ;
.PHONY: http-docs
http-docs:
swag init -g pkg/server/server.go
.PHONY: test
test:
set -o pipefail && $(GOTEST) | sed ''/PASS/s//$$(printf "\033[32mPASS\033[0m")/'' | sed ''/FAIL/s//$$(printf "\033[31mFAIL\033[0m")/'' | grep -v RUN
.PHONY: sectest
sectest:
$(GOSECCMD) -fmt=json ./...
.PHONY: lint
lint:
golangci-lint run $(go list ./... | grep -v /vendor/)
.PHONY: cover
cover:
${GOCMD} test -coverprofile=coverage.out ./... && ${GOCMD} tool cover -html=coverage.out -o coverage.html
.SILENT: clean
.PHONY: clean
clean:
$(GOCLEAN)
@rm -f ${BINARY}-$(OS)-${GOARCH}
@rm -f coverage.out
@rm -rf vendor