-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
68 lines (53 loc) · 1.72 KB
/
Makefile
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
# Go parameters
GOCMD=go
GOBUILD=$(GOCMD) build
GOCLEAN=$(GOCMD) clean
GOTEST=$(GOCMD) test
GOGET=$(GOCMD) get
BINARY_NODE_NAME=dht_node
BINARY_BOOTSTRAP_NAME=bootstrap_node
CONFIG_FILE=config.ini
TEST_REPORT_DIR=test_results
TEST_REPORT=$(TEST_REPORT_DIR)/test_result_report.xml
TEST_OUTPUT=$(TEST_REPORT_DIR)/test_output.txt
# Build both dht_node and bootstrap_node
build: build_node build_bootstrap_node
build_node:
$(GOBUILD) -o $(BINARY_NODE_NAME) ./cmd/node/main.go
build_bootstrap_node:
$(GOBUILD) -o $(BINARY_BOOTSTRAP_NAME) ./cmd/bootstrap_node/main.go
# Run the dht_node project
run_node: build_node
./$(BINARY_NODE_NAME) -c $(CONFIG_FILE)
# Run the bootstrap_node project
run_bootstrap: build_bootstrap_node
./$(BINARY_BOOTSTRAP_NAME) -c $(CONFIG_FILE)
# Test the project and generate a report
test:
mkdir -p $(TEST_REPORT_DIR)
$(GOTEST) -v ./tests/... | tee $(TEST_OUTPUT) | go-junit-report > $(TEST_REPORT)
@echo "Test report generated at $(TEST_REPORT)"
# Clean build artifacts
clean:
rm -f $(BINARY_NODE_NAME) $(BINARY_BOOTSTRAP_NAME)
rm -rf $(TEST_REPORT_DIR)
# Install dependencies
deps:
$(GOGET) -v ./...
# Format the code
fmt:
$(GOCMD) fmt ./...
# Lint the code
lint:
golangci-lint run
# Documentation server
doc:
godoc -http=:6060
# Generate HTML test report
test_and_report: test
xsltproc ./project_utils/junit-xml-to-html.xsl $(TEST_REPORT) > $(TEST_REPORT_DIR)/test_result_report.html
open $(TEST_REPORT_DIR)/test_result_report.html
test_report:
xsltproc ./project_utils/junit-xml-to-html.xsl $(TEST_REPORT) > $(TEST_REPORT_DIR)/test_result_report.html
open $(TEST_REPORT_DIR)/test_result_report.html
.PHONY: build build_node build_bootstrap_node run_node run_bootstrap test clean deps fmt lint doc test_report