-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMakefile
More file actions
134 lines (111 loc) · 3.61 KB
/
Makefile
File metadata and controls
134 lines (111 loc) · 3.61 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
# Copyright (C) 2025, Lux Partners Limited. All rights reserved.
# See the file LICENSE for licensing terms.
.PHONY: all build test lint clean install
# Go parameters
GOCMD=go
GOBUILD=$(GOCMD) build
GOTEST=$(GOCMD) test
GOGET=$(GOCMD) get
GOMOD=$(GOCMD) mod
GOFMT=gofmt
GOLINT=golangci-lint
GOVET=$(GOCMD) vet
# Build parameters
BINARY_NAME=lux-sdk
VERSION?=$(shell git describe --tags --always --dirty)
BUILD_TIME=$(shell date -u '+%Y-%m-%d_%H:%M:%S')
LDFLAGS=-ldflags "-X main.Version=$(VERSION) -X main.BuildTime=$(BUILD_TIME)"
# Directories
SRC_DIR=.
TEST_DIR=./tests
EXAMPLES_DIR=./examples
all: clean lint test build
build:
@echo "Building SDK..."
$(GOBUILD) -v $(LDFLAGS) -o $(BINARY_NAME) $(SRC_DIR)
@echo "Building examples..."
cd $(EXAMPLES_DIR)/boot-mainnet && $(GOBUILD) -v ./...
test:
@echo "Running unit tests..."
$(GOTEST) -v -race -coverprofile=coverage.out -covermode=atomic ./blockchain ./network ./heap ./crypto ./internal/...
test-integration:
@echo "Running full integration tests..."
$(GOTEST) -v -tags=integration -timeout=30m $(TEST_DIR)
test-coverage:
@echo "Running tests with coverage..."
$(GOTEST) -v -race -coverprofile=coverage.out -covermode=atomic ./...
$(GOCMD) tool cover -html=coverage.out -o coverage.html
@echo "Coverage report generated: coverage.html"
benchmark:
@echo "Running benchmarks..."
$(GOTEST) -bench=. -benchmem -run=^$$ ./... | tee benchmark.txt
lint:
@echo "Running linters..."
$(GOFMT) -s -w .
$(GOVET) ./...
$(GOLINT) run --timeout=10m
lint-fix:
@echo "Fixing lint issues..."
$(GOFMT) -s -w .
$(GOLINT) run --fix
deps:
@echo "Installing dependencies..."
$(GOMOD) download
$(GOMOD) tidy
deps-update:
@echo "Updating dependencies..."
$(GOMOD) get -u ./...
$(GOMOD) tidy
install-tools:
@echo "Installing development tools..."
go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
go install github.com/golang/mock/mockgen@latest
go install gotest.tools/gotestsum@latest
generate:
@echo "Generating code..."
go generate ./...
clean:
@echo "Cleaning..."
$(GOCMD) clean
rm -f $(BINARY_NAME)
rm -f coverage.out coverage.html
rm -f benchmark.txt
install: build
@echo "Installing SDK..."
$(GOCMD) install $(LDFLAGS) $(SRC_DIR)
docker-build:
@echo "Building Docker image..."
docker build -t luxfi/sdk:$(VERSION) -t luxfi/sdk:latest .
docker-test:
@echo "Running tests in Docker..."
docker-compose -f tests/docker-compose.yml up --build --abort-on-container-exit
docker-compose -f tests/docker-compose.yml down
ci-local:
@echo "Running CI checks locally..."
make lint
make test
make test-coverage
make build
release-dry-run:
@echo "Running release dry run..."
goreleaser release --snapshot --skip-publish --rm-dist
help:
@echo "Available targets:"
@echo " all - Clean, lint, test, and build"
@echo " build - Build the SDK and examples"
@echo " test - Run unit tests"
@echo " test-integration - Run integration tests"
@echo " test-coverage - Run tests with coverage report"
@echo " benchmark - Run benchmarks"
@echo " lint - Run linters"
@echo " lint-fix - Fix lint issues"
@echo " deps - Download dependencies"
@echo " deps-update - Update dependencies"
@echo " install-tools - Install development tools"
@echo " generate - Generate code"
@echo " clean - Clean build artifacts"
@echo " install - Install the SDK"
@echo " docker-build - Build Docker image"
@echo " docker-test - Run tests in Docker"
@echo " ci-local - Run CI checks locally"
@echo " help - Show this help message"