-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathMakefile
More file actions
112 lines (93 loc) · 3.29 KB
/
Makefile
File metadata and controls
112 lines (93 loc) · 3.29 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
# Makefile for IceFireDB CRDT-KV
# Variables
BINARY_NAME := icefiredb-crdt-kv
EXAMPLE_BINARY := kvdb-example
BUILD_DIR := ./build
EXAMPLE_DIR := ./example/kvdb
# Go parameters
GOCMD := go
GOBUILD := $(GOCMD) build
GOCLEAN := $(GOCMD) clean
GOTEST := $(GOCMD) test
GOGET := $(GOCMD) get
GOMOD := $(GOCMD) mod
# Default target
all: build test
# Build the main library
build:
@echo "Building library..."
mkdir -p $(BUILD_DIR)
$(GOBUILD) ./...
# Build the example application
example:
@echo "Building example application..."
mkdir -p $(BUILD_DIR)
cd $(EXAMPLE_DIR) && $(GOBUILD) -o ../../$(BUILD_DIR)/$(EXAMPLE_BINARY)
# Run all tests
test:
@echo "Running all tests..."
$(GOTEST) -v -race ./...
# Run unit tests only (skip integration tests)
test-unit:
@echo "Running unit tests..."
$(GOTEST) -v -race -run "TestCRDTKeyValueDB_Mock|TestCRDTKeyValueDB_Fast|TestPrintVal|TestMainFunctionExists|TestPubSubHandleType|TestGenerateCID|TestNewP2P|TestP2P_Close|TestP2P_MultipleInstances|TestP2P_NetworkOperations|TestPubSubHandleType_String|TestP2P_ContextCancellation" ./...
# Run integration tests only
test-integration:
@echo "Running integration tests..."
$(GOTEST) -v -race -run "Integration|MultiNode|Concurrent" ./...
# Run tests with coverage
test-coverage:
@echo "Running tests with coverage..."
$(GOTEST) -v -race -coverprofile=coverage.out ./...
$(GOCMD) tool cover -html=coverage.out -o coverage.html
@echo "Coverage report generated: coverage.html"
# Run tests with coverage and show summary
test-coverage-summary:
@echo "Running tests with coverage summary..."
$(GOTEST) -v -race -coverprofile=coverage.out ./...
$(GOCMD) tool cover -func=coverage.out
# Clean build artifacts
clean:
@echo "Cleaning..."
$(GOCLEAN)
rm -rf $(BUILD_DIR)
# Install dependencies
deps:
@echo "Installing dependencies..."
$(GOMOD) tidy
# Format code
fmt:
@echo "Formatting code..."
$(GOCMD) fmt ./...
# Vet code
vet:
@echo "Vetting code..."
$(GOCMD) vet ./...
# Lint and check code quality
lint: fmt vet
# Run the example application
run-example: example
@echo "Running example application..."
./$(BUILD_DIR)/$(EXAMPLE_BINARY)
# Build and run the example
build-run: example run-example
# Show help
help:
@echo "Available targets:"
@echo " all - Build and test everything"
@echo " build - Build the main library"
@echo " example - Build the example application"
@echo " test - Run all tests with race detection"
@echo " test-unit - Run unit tests only (skip integration)"
@echo " test-integration - Run integration tests only"
@echo " test-coverage - Run tests with HTML coverage report"
@echo " test-coverage-summary - Run tests with coverage summary"
@echo " clean - Clean build artifacts"
@echo " deps - Install dependencies"
@echo " fmt - Format code"
@echo " vet - Vet code"
@echo " lint - Lint and check code quality"
@echo " run-example - Run the example application"
@echo " build-run - Build and run the example"
@echo " help - Show this help message"
.PHONY: all build example test test-coverage test-coverage-summary clean deps fmt vet lint run-example build-run help