-
Notifications
You must be signed in to change notification settings - Fork 8
/
Makefile
69 lines (57 loc) · 1.42 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
GOLANG_CI_LINT_VER:=v1.61.0
GORELEASER_VERSION:=v2.3.2
OUT_BIN?=${PWD}/bin/jlv
COVER_PACKAGES=./...
VERSION?=${shell git describe --tags}
all: lint test build
run: build
./bin/jlv assets/example.log
.PHONY: run
run.version: build
./bin/jlv --version
.PHONY: run.version
run.stdin: build
./bin/jlv < assets/example.log
.PHONY: run.stdin
build:
@echo "building ${VERSION}"
go build \
-o ${OUT_BIN} \
--ldflags "-s -w -X main.version=${VERSION}" \
./cmd/jlv
.PHONY: build
install:
go install ./cmd/jlv
.PHONY: install
lint: bin/golangci-lint-${GOLANG_CI_LINT_VER}
./bin/golangci-lint-${GOLANG_CI_LINT_VER} run
.PHONY: lint
fix: bin/golangci-lint-${GOLANG_CI_LINT_VER}
gofumpt -l -w .
./bin/golangci-lint-${GOLANG_CI_LINT_VER} run --fix
.PHONY: lint-fix
test:
go test \
-coverpkg=${COVER_PACKAGES} \
-covermode=atomic \
-race \
-coverprofile=coverage.out \
./...
go tool cover -func=coverage.out
.PHONY: test
vendor:
go mod tidy
go mod vendor
.PHONY: vendor
goreleaser.check:
docker run --rm -it \
-v ${PWD}:/go/src/github.com/hedhyw/json-log-viewer \
-w /go/src/github.com/hedhyw/json-log-viewer \
goreleaser/goreleaser:${GORELEASER_VERSION} check
.PHONY: goreleaser.check
bin/golangci-lint-${GOLANG_CI_LINT_VER}:
curl \
-sSfL \
https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh \
| sh -s $(GOLANG_CI_LINT_VER)
mv ./bin/golangci-lint ./bin/golangci-lint-${GOLANG_CI_LINT_VER}