|
| 1 | +#!/usr/bin/make -f |
| 2 | + |
| 3 | +# Fix version extraction and use hardcoded values for problematic dependencies |
| 4 | +GOPATH=$(shell go env GOPATH) |
| 5 | +COSMOS_VERSION=$(shell go list -m all | grep "github.com/cosmos/cosmos-sdk" | awk '{print $$NF}' | head -1) |
| 6 | +COSMOS_LOG_VERSION=$(shell go list -m all | grep "cosmossdk.io/log" | awk '{print $$NF}' | head -1) |
| 7 | +# Use a known stable version instead of trying to extract it |
| 8 | +GOGO_PROTO_VERSION=v1.3.2 |
| 9 | +GRPC_GATEWAY_VERSION=v1.16.0 |
| 10 | + |
| 11 | +.PHONY: install build clean mod |
| 12 | + |
| 13 | +install: go.sum |
| 14 | + @echo "Installing reporterd..." |
| 15 | + @go install -mod=readonly ./cmd |
| 16 | + @echo "Completed install!" |
| 17 | + |
| 18 | +build: |
| 19 | + @echo "Building reporterd..." |
| 20 | + go build -o bin/reporterd ./cmd |
| 21 | + |
| 22 | +clean: |
| 23 | + @echo "Cleaning build artifacts..." |
| 24 | + rm -rf bin/ |
| 25 | + go clean |
| 26 | + |
| 27 | +mod: |
| 28 | + @echo "--> Updating go.mod" |
| 29 | + @go mod tidy |
| 30 | + |
| 31 | + |
| 32 | +############################################################################### |
| 33 | +### tests ### |
| 34 | +############################################################################### |
| 35 | +.PHONY: test mock-gen-daemon |
| 36 | + |
| 37 | +mock-gen-daemon: |
| 38 | + @go run github.com/vektra/mockery/v2 --name=AppOptions --dir=$(GOPATH)/pkg/mod/github.com/cosmos/cosmos-sdk@$(COSMOS_VERSION)/server/types --recursive --output=$(CURDIR)/mocks |
| 39 | + @go run github.com/vektra/mockery/v2 --name=ExchangeQueryHandler --dir=$(CURDIR)/pricefeed/client/queryhandler --recursive --output=$(CURDIR)/mocks |
| 40 | + @go run github.com/vektra/mockery/v2 --name=ExchangeToMarketPrices --dir=$(CURDIR)/pricefeed/client/types --recursive --output=$(CURDIR)/mocks |
| 41 | + @go run github.com/vektra/mockery/v2 --name=GrpcClient --dir=$(CURDIR)/types --recursive --output=$(CURDIR)/mocks |
| 42 | + @go run github.com/vektra/mockery/v2 --name=Logger --dir=$(GOPATH)/pkg/mod/cosmossdk.io/log@$(COSMOS_LOG_VERSION) --recursive --output=$(CURDIR)/mocks |
| 43 | + @go run github.com/vektra/mockery/v2 --name=PricefeedMutableMarketConfigs --dir=$(CURDIR)/pricefeed/client/types --filename=PriceFeedMutableMarketConfigs.go --recursive --output=$(CURDIR)/mocks |
| 44 | + @go run github.com/vektra/mockery/v2 --name=QueryClient --dir=$(CURDIR)/testutil/grpc --recursive --output=$(CURDIR)/mocks |
| 45 | + @go run github.com/vektra/mockery/v2 --name=RequestHandler --dir=$(CURDIR)/types --recursive --output=$(CURDIR)/mocks |
| 46 | + @go run github.com/vektra/mockery/v2 --name=TimeProvider --dir=$(CURDIR)/lib/time --recursive --output=$(CURDIR)/mocks |
| 47 | + |
| 48 | + |
| 49 | +test: |
| 50 | + @echo "Running tests..." |
| 51 | + go test -v ./... |
| 52 | + |
| 53 | +############################################################################### |
| 54 | +### linting ### |
| 55 | +############################################################################### |
| 56 | +.PHONY: lint lint-fix install-lint-deps |
| 57 | + |
| 58 | +lint: |
| 59 | + @echo "Linting daemon code..." |
| 60 | + golangci-lint run ./... |
| 61 | + |
| 62 | +# Fix linting issues where possible |
| 63 | +lint-fix: |
| 64 | + @echo "Fixing linting issues..." |
| 65 | + golangci-lint run --fix ./... |
| 66 | + |
| 67 | +install-lint-deps: |
| 68 | + @echo "Checking for golangci-lint..." |
| 69 | + @if ! command -v golangci-lint &> /dev/null; then \ |
| 70 | + echo "Installing golangci-lint..."; \ |
| 71 | + go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest; \ |
| 72 | + else \ |
| 73 | + echo "golangci-lint already installed"; \ |
| 74 | + fi |
| 75 | + |
| 76 | + |
| 77 | +############################################################################### |
| 78 | +### proto ### |
| 79 | +############################################################################### |
| 80 | +.PHONY: proto proto-gen proto-install proto-check proto-deps |
| 81 | + |
| 82 | +proto-gen: |
| 83 | + @echo "Generating protocol buffer files using buf..." |
| 84 | + @if ! command -v buf > /dev/null; then \ |
| 85 | + echo "buf not found. Installing..."; \ |
| 86 | + go install github.com/bufbuild/buf/cmd/buf@latest; \ |
| 87 | + fi |
| 88 | + @echo "Resolving dependencies..." |
| 89 | + @cd proto && buf dep update |
| 90 | + @echo "Generating code..." |
| 91 | + @cd proto && buf generate --template buf.gen.gogo.yaml |
| 92 | + @echo "Proto generation completed" |
| 93 | + |
| 94 | +proto-install: |
| 95 | + @echo "Installing protobuf dependencies for Cosmos SDK compatibility..." |
| 96 | + @go install github.com/cosmos/gogoproto/protoc-gen-gocosmos@latest |
| 97 | + @go install github.com/grpc-ecosystem/grpc-gateway/protoc-gen-grpc-gateway@$(GRPC_GATEWAY_VERSION) |
| 98 | + @go install google.golang.org/protobuf/cmd/protoc-gen-go@latest |
| 99 | + @go install google.golang.org/grpc/cmd/protoc-gen-go-grpc@latest |
| 100 | + @go install github.com/bufbuild/buf/cmd/buf@latest |
| 101 | + @echo "Proto tooling installation completed" |
| 102 | + |
| 103 | +proto-check: |
| 104 | + @if ! command -v buf > /dev/null; then \ |
| 105 | + echo "Error: buf is not installed. Please install buf first."; \ |
| 106 | + echo "Run: go install github.com/bufbuild/buf/cmd/buf@latest"; \ |
| 107 | + exit 1; \ |
| 108 | + fi |
| 109 | + @if [ ! -d proto/daemons ]; then \ |
| 110 | + echo "Error: proto/daemons directory does not exist."; \ |
| 111 | + exit 1; \ |
| 112 | + fi |
| 113 | + |
| 114 | +# Main proto target that depends on proto-gen |
| 115 | +proto: proto-check |
| 116 | + @echo "Running proto generation..." |
| 117 | + @$(MAKE) proto-gen |
| 118 | + @echo "Protocol buffers generated successfully" |
| 119 | + |
| 120 | +proto-deps: |
| 121 | + @echo "Installing protobuf dependencies..." |
| 122 | + @$(MAKE) proto-install |
0 commit comments