-
Notifications
You must be signed in to change notification settings - Fork 14
/
Makefile
68 lines (54 loc) · 1.39 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
.PHONY: dev run test cover cover-html fmt 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 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
dev: check-pre-commit
pre-commit install
run:
go build -o tinysyslog-bin ./cmd/tinysyslogd && ./tinysyslog-bin
build:
go build -o tinysyslog-bin ./cmd/tinysyslogd
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 .
pre-commit: check-pre-commit
pre-commit
docker-build:
docker build -t tinysyslog .
docker-run:
docker run -p 5140:5140/udp --rm tinysyslog