-
Notifications
You must be signed in to change notification settings - Fork 19
/
Copy pathMakefile
69 lines (60 loc) · 1.99 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
68
69
DOCS_DIR := ./docs
OUT_DIR := ./out
TESTS_DIR := ./tests
GO_FILES := $(shell find . -type f \( -iname '*.go' \))
GO_MODULE := github.com/pushbits/server
.PHONY: build
build:
mkdir -p $(OUT_DIR)
go build -ldflags="-w -s" -o $(OUT_DIR)/pushbits ./cmd/pushbits
.PHONY: clean
clean:
rm -rf $(DOCS_DIR)
rm -rf $(OUT_DIR)
.PHONY: test
test:
if [ -n "$$(gofumpt -l $(GO_FILES))" ]; then echo "Code is not properly formatted"; exit 1; fi
if [ -n "$$(goimports -l -local $(GO_MODULE) $(GO_FILES))" ]; then echo "Imports are not properly formatted"; exit 1; fi
go vet ./...
misspell -error $(GO_FILES)
gocyclo -over 10 $(GO_FILES)
staticcheck ./...
errcheck -ignoregenerated -exclude errcheck_excludes.txt ./...
gocritic check -disable='#experimental,#opinionated' -@ifElseChain.minThreshold 3 ./...
revive -set_exit_status -exclude ./docs ./...
nilaway ./...
go test -v -cover ./...
gosec -exclude-generated -exclude-dir=tests ./...
govulncheck ./...
@printf '\n%s\n' "> Test successful"
.PHONY: setup
setup:
go install github.com/client9/misspell/cmd/misspell@latest
go install github.com/fzipp/gocyclo/cmd/gocyclo@latest
go install github.com/go-critic/go-critic/cmd/gocritic@latest
go install github.com/kisielk/errcheck@latest
go install github.com/mgechev/revive@latest
go install github.com/securego/gosec/v2/cmd/gosec@latest
go install github.com/swaggo/swag/cmd/swag@latest
go install go.uber.org/nilaway/cmd/nilaway@latest
go install golang.org/x/tools/cmd/goimports@latest
go install golang.org/x/vuln/cmd/govulncheck@latest
go install honnef.co/go/tools/cmd/staticcheck@latest
go install mvdan.cc/gofumpt@latest
.PHONY: fmt
fmt:
gofumpt -l -w $(GO_FILES)
.PHONY: swag
swag: build
swag init --parseDependency=true --exclude $(TESTS_DIR) -g cmd/pushbits/main.go
.PHONY: docker_build_dev
docker_build_dev:
podman build \
-t local/pushbits .
.PHONY: run_postgres_debug
podman run \
--rm \
--name=postgres \
--network=host \
--env-file \
postgres-debug.env docker.io/library/postgres:15