-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
148 lines (127 loc) · 4.56 KB
/
Makefile
File metadata and controls
148 lines (127 loc) · 4.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
.PHONY: build build-release build-sncli build-sn-manager
.PHONY: install-lumera setup-supernodes system-test-setup install-deps
.PHONY: gen-cascade gen-supernode
.PHONY: test-e2e test-unit test-integration test-system
# Build variables
VERSION ?= $(shell git describe --tags --always --dirty 2>/dev/null || echo "dev")
GIT_COMMIT ?= $(shell git rev-parse --short HEAD 2>/dev/null || echo "unknown")
BUILD_TIME ?= $(shell date -u '+%Y-%m-%d_%H:%M:%S')
# Linker flags for version information
LDFLAGS = -X github.com/LumeraProtocol/supernode/v2/supernode/cmd.Version=$(VERSION) \
-X github.com/LumeraProtocol/supernode/v2/supernode/cmd.GitCommit=$(GIT_COMMIT) \
-X github.com/LumeraProtocol/supernode/v2/supernode/cmd.BuildTime=$(BUILD_TIME)
# Linker flags for sn-manager
SN_MANAGER_LDFLAGS = -X main.Version=$(VERSION) \
-X main.GitCommit=$(GIT_COMMIT) \
-X main.BuildTime=$(BUILD_TIME)
build:
@mkdir -p release
CGO_ENABLED=1 \
GOOS=linux \
GOARCH=amd64 \
echo "Building supernode..."
go build \
-trimpath \
-ldflags="-s -w $(LDFLAGS)" \
-o release/supernode-linux-amd64 \
./supernode
@chmod +x release/supernode-linux-amd64
@echo "supernode built successfully at release/supernode-linux-amd64"
build-sncli: release/sncli
SNCLI_SRC := $(wildcard cmd/sncli/*.go) \
$(wildcard cmd/sncli/**/*.go)
release/sncli: $(SNCLI_SRC) cmd/sncli/go.mod cmd/sncli/go.sum
@mkdir -p release
@echo "Building sncli..."
@RELEASE_DIR=$(CURDIR)/release && \
cd cmd/sncli && \
CGO_ENABLED=1 \
GOOS=linux \
GOARCH=amd64 \
go build \
-trimpath \
-ldflags="-s -w $(LDFLAGS)" \
-o $$RELEASE_DIR/sncli && \
chmod +x $$RELEASE_DIR/sncli && \
echo "sncli built successfully at $$RELEASE_DIR/sncli"
build-sn-manager:
@mkdir -p release
@echo "Building sn-manager..."
@cd sn-manager && \
CGO_ENABLED=0 \
GOOS=linux \
GOARCH=amd64 \
go build \
-trimpath \
-ldflags="-s -w $(SN_MANAGER_LDFLAGS)" \
-o ../release/sn-manager \
.
@chmod +x release/sn-manager
@echo "sn-manager built successfully at release/sn-manager"
test-unit:
go test -v ./...
test-integration:
go test -v -p 1 -count=1 -tags=integration ./...
test-system:
cd tests/system && go test -tags=system_test -v .
gen-cascade:
protoc \
--proto_path=proto \
--go_out=gen \
--go_opt=paths=source_relative \
--go-grpc_out=gen \
--go-grpc_opt=paths=source_relative \
proto/supernode/action/cascade/service.proto
gen-supernode:
protoc \
--proto_path=proto \
--proto_path=$$(go list -m -f '{{.Dir}}' github.com/grpc-ecosystem/grpc-gateway)/third_party/googleapis \
--go_out=gen \
--go_opt=paths=source_relative \
--go-grpc_out=gen \
--go-grpc_opt=paths=source_relative \
--grpc-gateway_out=gen \
--grpc-gateway_opt=paths=source_relative \
--openapiv2_out=gen \
proto/supernode/supernode.proto
# Define the paths
SUPERNODE_SRC=supernode/main.go
DATA_DIR=tests/system/supernode-data1
DATA_DIR2=tests/system/supernode-data2
DATA_DIR3=tests/system/supernode-data3
CONFIG_FILE=tests/system/config.test-1.yml
CONFIG_FILE2=tests/system/config.test-2.yml
CONFIG_FILE3=tests/system/config.test-3.yml
# Setup script
SETUP_SCRIPT=tests/scripts/setup-supernodes.sh
# Install Lumera
# Optional: specify lumera binary path to skip download
LUMERAD_BINARY ?=
# Optional: specify installation mode (latest-release, latest-tag, or vX.Y.Z)
INSTALL_MODE ?=latest-tag
install-lumera:
@echo "Installing Lumera..."
@chmod +x tests/scripts/install-lumera.sh
@sudo LUMERAD_BINARY="$(LUMERAD_BINARY)" tests/scripts/install-lumera.sh $(INSTALL_MODE)
@echo "PtTDUHythfRfXHh63yzyiGDid4TZj2P76Zd,18749999981413" > ~/claims.csv
# Setup supernode environments
setup-supernodes:
@echo "Setting up all supernode environments..."
@chmod +x $(SETUP_SCRIPT)
@bash $(SETUP_SCRIPT) all $(SUPERNODE_SRC) $(DATA_DIR) $(CONFIG_FILE) $(DATA_DIR2) $(CONFIG_FILE2) $(DATA_DIR3) $(CONFIG_FILE3)
# Complete system test setup (Lumera + Supernodes)
system-test-setup: install-lumera setup-supernodes
@echo "System test environment setup complete."
@if [ -f claims.csv ]; then cp claims.csv ~/; echo "Copied claims.csv to home directory."; fi
# Run system tests with complete setup
test-e2e:
@echo "Running system tests..."
@cd tests/system && go test -tags=system_test -v .
# Run cascade e2e tests only
test-cascade:
@echo "Running cascade e2e tests..."
@cd tests/system && go mod tidy && go test -tags=system_test -v -run TestCascadeE2E .
# Run sn-manager e2e tests only
test-sn-manager:
@echo "Running sn-manager e2e tests..."
@cd tests/system && go test -tags=system_test -v -run '^TestSNManager' .