1+ # Makefile for IceFireDB CRDT-KV
2+
3+ # Variables
4+ BINARY_NAME := icefiredb-crdt-kv
5+ EXAMPLE_BINARY := kvdb-example
6+ BUILD_DIR := ./build
7+ EXAMPLE_DIR := ./example/kvdb
8+
9+ # Go parameters
10+ GOCMD := go
11+ GOBUILD := $(GOCMD ) build
12+ GOCLEAN := $(GOCMD ) clean
13+ GOTEST := $(GOCMD ) test
14+ GOGET := $(GOCMD ) get
15+ GOMOD := $(GOCMD ) mod
16+
17+ # Default target
18+ all : build test
19+
20+ # Build the main library
21+ build :
22+ @echo " Building library..."
23+ mkdir -p $(BUILD_DIR )
24+ $(GOBUILD ) ./...
25+
26+ # Build the example application
27+ example :
28+ @echo " Building example application..."
29+ mkdir -p $(BUILD_DIR )
30+ cd $(EXAMPLE_DIR ) && $(GOBUILD ) -o ../../$(BUILD_DIR ) /$(EXAMPLE_BINARY )
31+
32+ # Run all tests
33+ test :
34+ @echo " Running all tests..."
35+ $(GOTEST ) -v -race ./...
36+
37+ # Run unit tests only (skip integration tests)
38+ test-unit :
39+ @echo " Running unit tests..."
40+ $(GOTEST ) -v -race -run " TestCRDTKeyValueDB_Mock|TestCRDTKeyValueDB_Fast|TestPrintVal|TestMainFunctionExists|TestPubSubHandleType|TestGenerateCID|TestNewP2P|TestP2P_Close|TestP2P_MultipleInstances|TestP2P_NetworkOperations|TestPubSubHandleType_String|TestP2P_ContextCancellation" ./...
41+
42+ # Run integration tests only
43+ test-integration :
44+ @echo " Running integration tests..."
45+ $(GOTEST ) -v -race -run " Integration|MultiNode|Concurrent" ./...
46+
47+ # Run tests with coverage
48+ test-coverage :
49+ @echo " Running tests with coverage..."
50+ $(GOTEST ) -v -race -coverprofile=coverage.out ./...
51+ $(GOCMD ) tool cover -html=coverage.out -o coverage.html
52+ @echo " Coverage report generated: coverage.html"
53+
54+ # Run tests with coverage and show summary
55+ test-coverage-summary :
56+ @echo " Running tests with coverage summary..."
57+ $(GOTEST ) -v -race -coverprofile=coverage.out ./...
58+ $(GOCMD ) tool cover -func=coverage.out
59+
60+ # Clean build artifacts
61+ clean :
62+ @echo " Cleaning..."
63+ $(GOCLEAN )
64+ rm -rf $(BUILD_DIR )
65+
66+ # Install dependencies
67+ deps :
68+ @echo " Installing dependencies..."
69+ $(GOMOD ) tidy
70+
71+ # Format code
72+ fmt :
73+ @echo " Formatting code..."
74+ $(GOCMD ) fmt ./...
75+
76+ # Vet code
77+ vet :
78+ @echo " Vetting code..."
79+ $(GOCMD ) vet ./...
80+
81+ # Lint and check code quality
82+ lint : fmt vet
83+
84+ # Run the example application
85+ run-example : example
86+ @echo " Running example application..."
87+ ./$(BUILD_DIR ) /$(EXAMPLE_BINARY )
88+
89+ # Build and run the example
90+ build-run : example run-example
91+
92+ # Show help
93+ help :
94+ @echo " Available targets:"
95+ @echo " all - Build and test everything"
96+ @echo " build - Build the main library"
97+ @echo " example - Build the example application"
98+ @echo " test - Run all tests with race detection"
99+ @echo " test-unit - Run unit tests only (skip integration)"
100+ @echo " test-integration - Run integration tests only"
101+ @echo " test-coverage - Run tests with HTML coverage report"
102+ @echo " test-coverage-summary - Run tests with coverage summary"
103+ @echo " clean - Clean build artifacts"
104+ @echo " deps - Install dependencies"
105+ @echo " fmt - Format code"
106+ @echo " vet - Vet code"
107+ @echo " lint - Lint and check code quality"
108+ @echo " run-example - Run the example application"
109+ @echo " build-run - Build and run the example"
110+ @echo " help - Show this help message"
111+
112+ .PHONY : all build example test test-coverage test-coverage-summary clean deps fmt vet lint run-example build-run help
0 commit comments