This repository has been archived by the owner on Dec 22, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
76 lines (56 loc) · 1.61 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
TOOLS := github.com/golangci/golangci-lint/cmd/[email protected] \
google.golang.org/grpc/cmd/[email protected] \
google.golang.org/protobuf/cmd/[email protected] \
github.com/bufbuild/buf/cmd/[email protected] \
github.com/goreleaser/[email protected]
PIP ?= pip
COVERAGE_FOLDER ?= coverage
CMD_FOLDER ?= ./cmd
COVERAGE_FILE := $(COVERAGE_FOLDER)/coverage.out
COVERAGE_FILE_HTML := $(COVERAGE_FOLDER)/coverage.html
TEST_COMMON_FLAGS ?= -v -failfast -timeout 1m
.PHONY: clean
clean:
rm -rf $(COVERAGE_FOLDER)
.PHONY: install-tools
install-tools:
for tool in $(TOOLS); do \
go install $$tool; \
done
$(PIP) install pre-commit==2.20.0
.PHONY: setup
setup: install-tools
pre-commit install
.PHONE: buf-build
buf-build:
buf build
.PHONY: build
build: install-tools buf-build
.PHONY: buf-lint
buf-lint:
buf lint
.PHONE: go-lint
go-lint:
golangci-lint run
.PHONY: lint
lint: install-tools buf-lint go-lint
.PHONY: buf-generate
buf-generate:
buf generate -o pkg/proto proto/internal
.PHONY: generate
generate: install-tools buf-generate
.PHONY: release-snapshot
release-snapshot: install-tools
goreleaser release --snapshot --rm-dist
.PHONY:
test-unit:
go test $(TEST_COMMON_FLAGS) -tags unit -race ./...
.PHONY: ensure-coverage
ensure-coverage:
mkdir -p $(COVERAGE_FOLDER)
.PHONY: test-unit-coverage
test-unit-coverage: clean ensure-coverage
go test $(TEST_COMMON_FLAGS) -tags unit -race -coverpkg ./... -covermode atomic -coverprofile $(COVERAGE_FILE) ./...
.PHONY: test-unit-coverage-html
test-unit-coverage-html: test-unit-coverage
go tool cover -html $(COVERAGE_FILE) -o $(COVERAGE_FILE_HTML)