Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
162 lines (135 loc) · 5.56 KB
/
Copy pathMakefile
File metadata and controls
162 lines (135 loc) · 5.56 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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
ROOT_PATH := $(dir $(realpath $(lastword $(MAKEFILE_LIST))))
COVERAGE_PATH := $(ROOT_PATH).coverage/
# Use the locally installed Go toolchain.
export GOTOOLCHAIN=local
# Ensure our local tools are preferred
export PATH := $(ROOT_PATH)tools/bin:$(PATH)
include $(ROOT_PATH)tools/tools.mk
GOARCH ?= $(shell uname -m)
ifeq ($(GOARCH), x86_64)
override GOARCH = amd64
endif
CLI_BIN := $(ROOT_PATH)cli/bin/cli
MCP_BIN := $(ROOT_PATH)mcp/bin/mcp
SERVICES_BIN_PATH ?= $(ROOT_PATH)services/bin
.PHONY: build-gateway-http-path-service
build-gateway-http-path-service:
@echo "Building gateway HTTP path service..."
@go build -o $(SERVICES_BIN_PATH)/gateway-http-path ./services/gateway-http-path
@echo "Gateway HTTP path service built successfully at $(SERVICES_BIN_PATH)/gateway-http-path"
.PHONY: build-gateway-http-body-service
build-gateway-http-body-service:
@echo "Building gateway HTTP body service..."
@go build -o $(SERVICES_BIN_PATH)/gateway-http-body ./services/gateway-http-body
@echo "Gateway HTTP body service built successfully at $(SERVICES_BIN_PATH)/gateway-http-body"
.PHONY: build-gateway-grpc-message-service
build-gateway-grpc-message-service:
@echo "Building gateway gRPC message service..."
@go build -o $(SERVICES_BIN_PATH)/gateway-grpc-message ./services/gateway-grpc-message
@echo "Gateway gRPC message service built successfully at $(SERVICES_BIN_PATH)/gateway-grpc-message"
.PHONY: build-gateway-grpc-method-service
build-gateway-grpc-method-service:
@echo "Building gateway gRPC method service..."
@go build -o $(SERVICES_BIN_PATH)/gateway-grpc-method ./services/gateway-grpc-method
@echo "Gateway gRPC method service built successfully at $(SERVICES_BIN_PATH)/gateway-grpc-method"
.PHONY: build-ok-http-service
build-ok-http-service:
@echo "Building ok HTTP service..."
@go build -o $(SERVICES_BIN_PATH)/ok-http ./services/ok-http
@echo "Ok HTTP service built successfully at $(SERVICES_BIN_PATH)/ok-http"
.PHONY: build-ok-grpc-service
build-ok-grpc-service:
@echo "Building ok gRPC service..."
@go build -o $(SERVICES_BIN_PATH)/ok-grpc ./services/ok-grpc
@echo "Ok gRPC service built successfully at $(SERVICES_BIN_PATH)/ok-grpc"
.PHONY: build-telemetry-http-service
build-telemetry-http-service:
@echo "Building telemetry HTTP service..."
@go build -o $(SERVICES_BIN_PATH)/telemetry-http ./services/telemetry-http
@echo "Telemetry HTTP service built successfully at $(SERVICES_BIN_PATH)/telemetry-http"
.PHONY: protoc-ok-service
protoc-ok-service:
@echo "Generating protobuf code for ok service..."
@protoc \
--go_out=. \
--go_opt=module=github.com/e2engine/tests \
--go-grpc_out=. \
--go-grpc_opt=module=github.com/e2engine/tests \
services/ok-grpc/ok.proto
@echo "Protobuf code generated successfully for ok service."
DOCKER_SERVICES_BIN_PATH := $(ROOT_PATH)services/docker-bin
.PHONY: build-ok-http-image
build-ok-http-image:
@echo "Checking Docker availability..."
@docker info >/dev/null 2>&1 || (echo "Docker is not available" && exit 1)
@echo "Building ok HTTP service for Linux..."
@CGO_ENABLED=0 GOOS=linux GOARCH=$(GOARCH) go build \
-o $(DOCKER_SERVICES_BIN_PATH)/ok-http ./services/ok-http
@file $(DOCKER_SERVICES_BIN_PATH)/ok-http
@docker buildx build \
--platform linux/$(GOARCH) \
--load \
--build-arg SERVICE=ok-http \
-t e2engine-test-ok-http:local \
-f services/Dockerfile \
services
@echo "ok-http image built successfully"
.PHONY: build-telemetry-http-image
build-telemetry-http-image:
@CGO_ENABLED=0 GOOS=linux GOARCH=$(GOARCH) go build \
-o $(DOCKER_SERVICES_BIN_PATH)/telemetry-http ./services/telemetry-http
@docker buildx build \
--platform linux/$(GOARCH) \
--load \
--build-arg SERVICE=telemetry-http \
-t e2engine-test-telemetry-http:local \
-f services/Dockerfile \
services
.PHONY: lint
lint: install-golangci-lint
@echo "Running linter..."
$(GOLANGCI_LINT) run
.PHONY: vulncheck
vulncheck: install-govulncheck
@echo "Checking for known vulnerabilities..."
$(GOVULNCHECK) ./...
.PHONY: build
build: build-gateway-http-path-service \
build-gateway-http-body-service \
build-gateway-grpc-message-service \
build-gateway-grpc-method-service \
build-ok-http-service \
build-ok-grpc-service \
build-telemetry-http-service \
build-ok-http-image \
build-telemetry-http-image
@echo "All test helper binaries and images built successfully."
.PHONY: verify
verify: lint vulncheck test-cli-prebuilt test-docker-prebuilt test-mcp-prebuilt
@echo "All verifications passed successfully."
.PHONY: test-cli-prebuilt
test-cli-prebuilt: build-gateway-http-path-service \
build-gateway-http-body-service \
build-gateway-grpc-message-service \
build-gateway-grpc-method-service \
build-ok-http-service \
build-ok-grpc-service \
build-telemetry-http-service
@test -x $(CLI_BIN) || { echo "Prebuilt CLI binary not found or not executable: $(CLI_BIN)"; exit 1; }
@echo "Running CLI tests with prebuilt binary..."
@go test ./cli/... -count=1
.PHONY: check-cli-image
check-cli-image:
@docker image inspect e2engine:local >/dev/null 2>&1 || { echo "Prebuilt CLI Docker image not found: e2engine:local"; exit 1; }
.PHONY: test-docker-prebuilt
test-docker-prebuilt: check-cli-image \
build-ok-http-image \
build-telemetry-http-image
@echo "Running tests with prebuilt Docker image..."
@go test ./docker/... -count=1
.PHONY: test-mcp-prebuilt
test-mcp-prebuilt: export GOFLAGS=-mod=mod
test-mcp-prebuilt: build-telemetry-http-service
@test -x $(MCP_BIN) || { echo "Prebuilt MCP binary not found or not executable: $(MCP_BIN)"; exit 1; }
@echo "Running MCP tests with prebuilt binary..."
@go test ./mcp/... -count=1