-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathMakefile
More file actions
103 lines (85 loc) · 2.53 KB
/
Makefile
File metadata and controls
103 lines (85 loc) · 2.53 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
# Makefile for valkey-ai-tasks project
# Go parameters
GOCMD=go
GOBUILD=$(GOCMD) build
GOTEST=$(GOCMD) test
GOGET=$(GOCMD) get
GOMOD=$(GOCMD) mod
GOFMT=$(GOCMD) fmt
# Project directories
TEST_DIR=./tests
INTEG_TEST_DIR=$(TEST_DIR)/integration
# Test parameters
COVERAGE_DIR=./coverage
COVERAGE_FILE=$(COVERAGE_DIR)/coverage.out
COVERAGE_HTML=$(COVERAGE_DIR)/coverage.html
# Default filter is empty (run all tests)
filter?=.
# Default verbosity is off
verbose?=
# Set verbosity flag if verbose is set
ifdef verbose
VERBOSE_FLAG=-v
else
VERBOSE_FLAG=
endif
.PHONY: all build test integ-test clean fmt tidy coverage lint lint-install
# Default target
all: build test lint
# Build the application
build:
@echo "Building application..."
@$(GOBUILD) ./...
# Run all tests
test:
@echo "Running all tests..."
@$(GOTEST) $(VERBOSE_FLAG) ./... -run $(filter)
# Run only integration tests
integ-test:
@echo "Running integration tests..."
@$(GOTEST) $(VERBOSE_FLAG) ./tests/integration/... -run $(filter)
# Run tests with coverage
coverage:
@echo "Running tests with coverage..."
@mkdir -p $(COVERAGE_DIR)
@$(GOTEST) -coverprofile=$(COVERAGE_FILE) ./...
@$(GOCMD) tool cover -html=$(COVERAGE_FILE) -o $(COVERAGE_HTML)
@echo "Coverage report generated at $(COVERAGE_HTML)"
# Format code
fmt:
@echo "Formatting code..."
gofumpt -w .
golines -w --shorten-comments -m 127 .
# Update dependencies
tidy:
@echo "Updating dependencies..."
@$(GOMOD) tidy
# Clean build artifacts
clean:
@echo "Cleaning build artifacts..."
@rm -rf $(COVERAGE_DIR)
@find . -type f -name "*.test" -delete
run:
@echo "Running application..."
@go run cmd/mcpserver/main.go
# Lint code using golangci-lint
lint:
@echo "Linting code..."
@golangci-lint run $(if $(verbose),-v,) $(if $(fix),--fix,)
# Help target
help:
@echo "Available targets:"
@echo " all : Build, test, and lint the application"
@echo " build : Build the application"
@echo " test : Run all tests"
@echo " Usage: make test [filter=TestName] [verbose=1]"
@echo " integ-test : Run integration tests only"
@echo " Usage: make integ-test [filter=TestName] [verbose=1]"
@echo " coverage : Generate test coverage report"
@echo " lint : Run linters on the code"
@echo " Usage: make lint [verbose=1] [fix=1]"
@echo " lint-install: Install golangci-lint"
@echo " fmt : Format code"
@echo " tidy : Update dependencies"
@echo " clean : Clean build artifacts"
@echo " help : Show this help message"