-
Notifications
You must be signed in to change notification settings - Fork 16
/
Makefile
87 lines (70 loc) · 1.87 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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
.PHONY: dev run test cover fmt mock openapi-lint pre-commit docker-build docker-run
.DEFAULT: help
help:
@echo "make dev"
@echo " setup development environment"
@echo "make run"
@echo " run app"
@echo "make test"
@echo " run go test"
@echo "make cover"
@echo " run go test with -cover"
@echo "make cover-html"
@echo " run go test with -cover and show HTML"
@echo "make tidy"
@echo " run go mod tidy"
@echo "make fmt"
@echo " run gofumpt"
@echo "make mock"
@echo " run mockery"
@echo "make openapi-lint"
@echo " lint openapi spec"
@echo "make pre-commit"
@echo " run pre-commit hooks"
@echo "make docker-build"
@echo " build docker image"
@echo "make docker-run"
@echo " run docker image"
check-gofumpt:
ifeq (, $(shell which gofumpt))
$(error "gofumpt not in $(PATH), gofumpt (https://pkg.go.dev/mvdan.cc/gofumpt) is required")
endif
check-pre-commit:
ifeq (, $(shell which pre-commit))
$(error "pre-commit not in $(PATH), pre-commit (https://pre-commit.com) is required")
endif
check-redocly:
ifeq (, $(shell which redocly))
$(error "redocly not in $(PATH), redocly (https://redocly.com/docs/cli/installation/) is required")
endif
dev: check-pre-commit
ifeq (,$(wildcard ./private-key.pem))
@echo "No private key file, generating one..."
openssl genrsa -out private-key.pem 4096
endif
pre-commit install
run:
go build -o server-bin ./cmd/server && ./server-bin
build:
go build -o server-bin ./cmd/server
test:
go test -v ./...
cover:
go test -cover -v ./...
cover-html:
go test -v -coverprofile=coverage.out ./...
go tool cover -html=coverage.out
tidy:
go mod tidy
fmt: check-gofumpt
gofumpt -l -w .
mock:
mockery
openapi-lint: check-redocly
redocly lint openapi/openapi.yaml
pre-commit: check-pre-commit
pre-commit
docker-build:
docker build -t echo-boilerplate .
docker-run:
docker run -p 1323:1323 --rm echo-boilerplate --http-bind-address 0.0.0.0