-
Notifications
You must be signed in to change notification settings - Fork 174
Expand file tree
/
Copy pathMakefile
More file actions
103 lines (83 loc) · 3.58 KB
/
Copy pathMakefile
File metadata and controls
103 lines (83 loc) · 3.58 KB
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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
PACKAGES=$(shell go list ./... | grep -v 'tests' | grep -v 'grpc/gen')
ifneq (,$(filter $(OS),Windows_NT MINGW64))
EXE = .exe
endif
# Handle sed differences between macOS and Linux
ifeq ($(shell uname),Darwin)
SED_CMD = sed -i ''
else
SED_CMD = sed -i
endif
all: build test
########################################
### Tools needed for development
devtools:
@echo "Installing devtools"
go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.12.2
go install github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-grpc-gateway@v2.29.0
go install github.com/grpc-ecosystem/grpc-gateway/v2/protoc-gen-openapiv2@v2.29.0
go install github.com/NathanBaulch/protoc-gen-cobra@v1.2.1
go install github.com/pactus-project/protoc-gen-doc/cmd/protoc-gen-doc@v0.0.0-20260124125944-b6e7c1776266
go install github.com/bufbuild/buf/cmd/buf@v1.71.0
go install mvdan.cc/gofumpt@latest
go install github.com/pacviewer/jrpc-gateway/protoc-gen-jrpc-gateway@v0.6
go install go.uber.org/mock/mockgen@latest
########################################
### Building
build:
go build -o ./build/pactus-daemon$(EXE) ./cmd/daemon
go build -o ./build/pactus-wallet$(EXE) ./cmd/wallet
go build -o ./build/pactus-shell$(EXE) ./cmd/shell
build_race:
go build -race -o ./build/pactus-daemon$(EXE) ./cmd/daemon
go build -race -o ./build/pactus-wallet$(EXE) ./cmd/wallet
build_gui:
go build -tags gtk -o ./build/pactus-gui$(EXE) ./cmd/gtk
########################################
### Testing
mocks:
@echo "Generating mocks..."
@mockgen -source=store/interface.go -destination=store/store_mock.go -package=store
@mockgen -source=state/interface.go -destination=state/state_mock.go -package=state
@mockgen -source=consensus/interface.go -destination=consensus/consensus_mock.go -package=consensus
@mockgen -source=consensus/manager/interface.go -destination=consensus/manager/manager_mock.go -package=manager
@mockgen -source=txpool/interface.go -destination=txpool/txpool_mock.go -package=txpool
@mockgen -source=wallet/manager/interface.go -destination=wallet/manager/manager_mock.go -package=manager
@mockgen -source=wallet/provider/interface.go -destination=wallet/provider/provider_mock.go -package=provider
@mockgen -source=wallet/storage/interface.go -destination=wallet/storage/storage_mock.go -package=storage
@mockgen -source=execution/executor/interface.go -destination=execution/executor/executor_mock.go -package=executor
@mockgen -source=committee/interface.go -destination=committee/committee_mock.go -package=committee
@mockgen -source=sandbox/interface.go -destination=sandbox/sandbox_mock.go -package=sandbox
unit_test:
@go test $(PACKAGES)
test:
@go test ./... -covermode=atomic
test_race:
@go test ./... --race
########################################
### Docker
docker:
docker build --tag pactus .
########################################
### proto
# This target works only on Unix-like terminals.
proto:
rm -rf www/grpc/gen
cd www/grpc && buf generate --template ./buf/buf.gen.yaml --config ./buf/buf.yaml ./proto
proto-check:
cd www/grpc && buf lint --config ./buf/buf.yaml
proto-format:
cd www/grpc && buf format --config ./buf/buf.yaml -w
########################################
### Formatting the code
fmt:
gofumpt -l -w .
check:
golangci-lint run --build-tags "${BUILD_TAG}" --timeout=20m0s
# To avoid unintended conflicts with file names, always add to .PHONY
# unless there is a reason not to.
# https://www.gnu.org/software/make/manual/html_node/Phony-Targets.html
.PHONY: build build_gui
.PHONY: test unit_test test_race mocks
.PHONY: proto proto-format proto-check
.PHONY: devtools fmt check docker