-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathMakefile
More file actions
133 lines (113 loc) · 5.1 KB
/
Copy pathMakefile
File metadata and controls
133 lines (113 loc) · 5.1 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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
# Copyright 2026 H0llyW00dzZ
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
.PHONY: all proto lint-proto build test test-cover test-e2e vet fmt gocyclo clean deps header
# Test packages (excludes generated proto code that has no tests).
TEST_PKGS := $(shell go list ./src/... | grep -v /grpc/pakasir/)
# Print ASCII art banner.
header:
@printf '%s\n' ' ____ _ _ '
@printf '%s\n' ' | _ \ __ _ | | __ __ _ ___ (_) _ __ '
@printf '%s\n' ' | |_) / _` || |/ // _` / __|| || '"'"'__| '
@printf '%s\n' ' | __/ (_| || <| (_| \__ \| || | '
@printf '%s\n' ' |_| \__,_||_|\_\\__,_|___/|_||_| '
@printf '%s\n' ' '
@printf '%s\n' ' Go SDK by H0llyW00dzZ (@github.com/H0llyW00dzZ)'
@echo ""
# Default target.
all: header build test
## ──────────────────────────────────────────────
## Proto Generation
## ──────────────────────────────────────────────
# Generate Go code from proto files using buf.
proto: header
@echo "==> Generating proto..."
buf generate
@echo "==> Done."
# Lint proto files.
lint-proto: header
@echo "==> Linting proto files..."
buf lint
@echo "==> Done."
## ──────────────────────────────────────────────
## Build
## ──────────────────────────────────────────────
# Build all packages (compile check, no binary output).
build: header
@echo "==> Building all packages..."
go build ./...
@echo "==> Done."
## ──────────────────────────────────────────────
## Quality
## ──────────────────────────────────────────────
# Run all tests with race detector.
test: header
@echo "==> Running tests..."
go test $(TEST_PKGS) -race -v -count=1
@echo "==> Done."
# Run tests with coverage report.
# To view in browser: go tool cover -html=coverage.txt
test-cover: header
@echo "==> Running tests with coverage..."
go test $(TEST_PKGS) -race -v -coverprofile=coverage.txt -covermode=atomic -count=1
go tool cover -func=coverage.txt
@echo "==> Done. (To view in browser: go tool cover -html=coverage.txt)"
# Run the gRPC end-to-end payment flow test.
# This exercises the full lifecycle: create -> simulate pay -> verify completed.
test-e2e: header
@echo "==> Running gRPC E2E test..."
go test -v -race -run TestE2EPaymentFlowSuccess ./src/grpc/
@echo "==> Done."
# Run go vet.
vet: header
@echo "==> Running go vet..."
go vet ./src/...
@echo "==> Done."
# Run cyclomatic complexity analysis (requires gocyclo).
# Scans src/ only — generated protobuf code in grpc/pakasir/v1 is excluded.
# Usage:
# make gocyclo # report functions with complexity > 10
# make gocyclo CYCLO_THRESHOLD=15 # custom threshold
CYCLO_THRESHOLD ?= 10
gocyclo: header
@echo "==> Running gocyclo (threshold=$(CYCLO_THRESHOLD))..."
gocyclo -over $(CYCLO_THRESHOLD) $(shell go list -f '{{.Dir}}' ./src/... | grep -v /grpc/pakasir/)
@echo "==> Done."
# Check formatting (must produce no output).
fmt: header
@echo "==> Checking gofmt..."
@DIFF=$$(gofmt -s -d .); \
if [ -n "$$DIFF" ]; then \
echo "$$DIFF"; \
echo ""; \
echo "ERROR: gofmt found formatting issues. Run: gofmt -s -w ."; \
exit 1; \
fi
@echo "==> Done."
## ──────────────────────────────────────────────
## Cleanup
## ──────────────────────────────────────────────
# Remove generated coverage files.
clean: header
rm -f coverage.txt
@echo "==> Cleaned."
## ──────────────────────────────────────────────
## Dependencies
## ──────────────────────────────────────────────
# Install required tools for proto generation and analysis.
deps: header
go install github.com/bufbuild/buf/cmd/buf@latest
go install google.golang.org/protobuf/cmd/protoc-gen-go@latest
go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest
go install github.com/fzipp/gocyclo/cmd/gocyclo@latest
@echo "==> Done."