-
Notifications
You must be signed in to change notification settings - Fork 29
Expand file tree
/
Copy pathMakefile
More file actions
120 lines (102 loc) · 2.87 KB
/
Makefile
File metadata and controls
120 lines (102 loc) · 2.87 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
.PHONY: build run test clean fmt vet lint help
# Binary name
BINARY_NAME=notex
# Go parameters
GOCMD=go
GOBUILD=$(GOCMD) build
GORUN=$(GOCMD) run
GOTEST=$(GOCMD) test
GOFMT=gofmt
GOVET=go vet
# Build the application
build:
@echo "Building $(BINARY_NAME)..."
$(GOBUILD) -o $(BINARY_NAME) backend/*.go
@echo "Build complete: $(BINARY_NAME)"
# Run the application in server mode
run:
@echo "Starting $(BINARY_NAME) server..."
$(GORUN) backend/*.go -server
# Run tests
test:
@echo "Running tests..."
$(GOTEST) -v ./...
# Run tests with coverage
test-coverage:
@echo "Running tests with coverage..."
$(GOTEST) -v -coverprofile=coverage.out ./...
$(GOCMD) tool coverage -html=coverage.out -o coverage.html
@echo "Coverage report: coverage.html"
# Format code
fmt:
@echo "Formatting code..."
$(GOFMT) -s -w .
# Check if code is formatted
fmt-check:
@echo "Checking code formatting..."
@test -z $$($(GOFMT) -l .) || (echo "Code is not formatted. Run 'make fmt'." && exit 1)
# Run go vet
vet:
@echo "Running go vet..."
$(GOVET) ./...
# Run linter (requires golangci-lint)
lint:
@echo "Running linter..."
@if command -v golangci-lint > /dev/null; then \
golangci-lint run; \
else \
echo "golangci-lint not installed. Run: go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest"; \
fi
# Run all checks
check: fmt-check vet lint
@echo "All checks passed!"
# Clean build artifacts
clean:
@echo "Cleaning..."
rm -f $(BINARY_NAME)
rm -f coverage.out coverage.html
rm -rf data/
@echo "Clean complete"
# Install dependencies
deps:
@echo "Installing dependencies..."
$(GOCMD) mod download
$(GOCMD) mod tidy
# Create data directory
init:
@echo "Initializing data directories..."
mkdir -p data/uploads
@echo "Initialized"
# Build and run (development)
dev: init run
# Run with OpenAI
run-openai:
@echo "Starting with OpenAI..."
@if [ -z "$$OPENAI_API_KEY" ]; then \
echo "Error: OPENAI_API_KEY not set"; \
exit 1; \
fi
$(GORUN) backend/*.go -server
# Run with Ollama
run-ollama:
@echo "Starting with Ollama..."
$(GORUN) backend/*.go -server
# Show help
help:
@echo "Available targets:"
@echo " build - Build the application"
@echo " run - Run the server"
@echo " dev - Initialize and run (development)"
@echo " run-openai - Run with OpenAI (requires OPENAI_API_KEY)"
@echo " run-ollama - Run with Ollama"
@echo " test - Run tests"
@echo " test-coverage - Run tests with coverage"
@echo " fmt - Format code"
@echo " fmt-check - Check if code is formatted"
@echo " vet - Run go vet"
@echo " lint - Run linter"
@echo " check - Run all checks (fmt, vet, lint)"
@echo " clean - Clean build artifacts"
@echo " deps - Install dependencies"
@echo " init - Create data directories"
@echo " help - Show this help message"