-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMakefile
More file actions
145 lines (113 loc) · 4.32 KB
/
Makefile
File metadata and controls
145 lines (113 loc) · 4.32 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
.PHONY: build test clean run setup db-up db-down docker-build docker-run deploy-contracts install-mockery check-mockery generate-mocks test-e2e test-e2e-api test-e2e-bridge test-e2e-indexer lint lint-e2e test-coverage test-coverage-check
GREEN := \033[0;32m
RED := \033[0;31m
RESET := \033[0m
MOCKERY_VERSION ?= v2.53.6
COVERAGE_THRESHOLD ?= 10
# Build the relayer binary
build:
go build -o bin/relayer ./cmd/relayer
# Run tests
test:
go test -v ./...
# Run tests with coverage
test-coverage:
go test -v -coverprofile=coverage.out -covermode=atomic ./...
go tool cover -html=coverage.out -o coverage.html
@go tool cover -func=coverage.out | tail -1
# Run tests with coverage and enforce minimum threshold
test-coverage-check: test-coverage
@total=$$(go tool cover -func=coverage.out | grep '^total:' | awk '{print $$3}' | tr -d '%'); \
echo "Coverage: $${total}% (threshold: $(COVERAGE_THRESHOLD)%)"; \
if [ $$(awk "BEGIN {print ($${total} < $(COVERAGE_THRESHOLD))}") -eq 1 ]; then \
echo "$(RED)FAIL: Coverage $${total}% is below $(COVERAGE_THRESHOLD)% threshold$(RESET)"; \
exit 1; \
else \
echo "$(GREEN)PASS: Coverage $${total}% meets $(COVERAGE_THRESHOLD)% threshold$(RESET)"; \
fi
# Clean build artifacts
clean:
rm -rf bin/
rm -f coverage.out coverage.html
# Run the relayer
run:
go run ./cmd/relayer -config config.yaml
# Install dependencies
deps:
go mod download
go mod tidy
install-mockery:
go install github.com/vektra/mockery/v2@$(MOCKERY_VERSION)
get_lint:
if [ ! -f ./bin/golangci-lint ]; then \
curl -sfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s v2.9.0; \
fi;
# Run linter (main code + E2E tests)
lint: get_lint
./bin/golangci-lint run
./bin/golangci-lint run --build-tags e2e ./tests/e2e/...
# Run linter for E2E tests only
lint-e2e: get_lint
./bin/golangci-lint run --build-tags e2e ./tests/e2e/...
# Format code
fmt:
go fmt ./...
# Code generation
generate-protos:
./scripts/generate-protos.sh
generate-eth-bindings:
cd contracts/ethereum-wayfinder && \
forge build && \
mkdir -p ../../pkg/ethereum/contracts && \
jq '.abi' out/CantonBridge.sol/CantonBridge.json > /tmp/CantonBridge.abi.json && \
abigen --abi /tmp/CantonBridge.abi.json --pkg contracts --type CantonBridge --out ../../pkg/ethereum/contracts/bridge.go && \
jq '.abi' out/PromptToken.sol/PromptToken.json > /tmp/PromptToken.abi.json && \
abigen --abi /tmp/PromptToken.abi.json --pkg contracts --type PromptToken --out ../../pkg/ethereum/contracts/prompt_token.go
generate: generate-protos generate-eth-bindings
# Ethereum contract operations
ETH_RPC_URL ?= http://localhost:8545
PRIVATE_KEY ?= 0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80
RELAYER_ADDRESS ?= 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266
USER ?= 0x70997970C51812dc3A010C7d01b50e0d17dc79C8
deploy-contracts:
cd contracts/ethereum-wayfinder && \
PRIVATE_KEY=$(PRIVATE_KEY) RELAYER_ADDRESS=$(RELAYER_ADDRESS) USER=$(USER) \
forge script script/Deploy.s.sol:DeployScript --rpc-url $(ETH_RPC_URL) --broadcast
deploy-contracts-dry-run:
cd contracts/ethereum-wayfinder && \
PRIVATE_KEY=$(PRIVATE_KEY) RELAYER_ADDRESS=$(RELAYER_ADDRESS) USER=$(USER) \
forge script script/Deploy.s.sol:DeployScript --rpc-url $(ETH_RPC_URL)
test-contracts:
cd contracts/ethereum-wayfinder && forge test -vvv
# Database setup
db-up:
docker run --name canton-bridge-db -e POSTGRES_PASSWORD=changeme -e POSTGRES_USER=bridge -e POSTGRES_DB=canton_bridge -p 5432:5432 -d postgres:15
db-down:
docker stop canton-bridge-db
docker rm canton-bridge-db
db-migrate:
@echo "Running relayer database migrations..."
go run ./cmd/relayer/migrate/main.go -config config.yaml up
@echo "Running API server database migrations..."
go run ./cmd/api-server/migrate/main.go -config config.api-server.yaml up
# Docker build
docker-build:
docker build -t canton-bridge-relayer:latest .
docker-run:
docker-compose up -d
# Development setup
setup: deps db-up
@echo "Waiting for database to be ready..."
@sleep 3
$(MAKE) db-migrate
cp config.example.yaml config.yaml
@echo "Setup complete! Edit config.yaml and run 'make run'"
# E2E tests
E2E_COMPOSE := tests/e2e/docker-compose.e2e.yaml
test-e2e: test-e2e-api test-e2e-bridge test-e2e-indexer
test-e2e-api:
@echo "not yet implemented"
test-e2e-bridge:
@echo "not yet implemented"
test-e2e-indexer:
@echo "not yet implemented"