-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
134 lines (116 loc) · 3.34 KB
/
Makefile
File metadata and controls
134 lines (116 loc) · 3.34 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
121
122
123
124
125
126
127
128
129
130
131
132
133
134
# Makefile for ai-docs CLI
# Variables
BINARY_NAME=ai-docs
GO=go
GOFLAGS=-v
MAIN_PATH=.
INSTALL_PATH=$(GOPATH)/bin
# Build information
VERSION=$(shell git describe --tags --always --dirty 2>/dev/null || echo "dev")
BUILD_TIME=$(shell date -u '+%Y-%m-%d_%H:%M:%S')
LDFLAGS=-ldflags "-X main.Version=$(VERSION) -X main.BuildTime=$(BUILD_TIME)"
# Default target
.DEFAULT_GOAL := build
# Build the binary
.PHONY: build
build:
@echo "Building $(BINARY_NAME)..."
$(GO) build $(GOFLAGS) $(LDFLAGS) -o $(BINARY_NAME) $(MAIN_PATH)
@echo "Build complete: ./$(BINARY_NAME)"
# Run tests
.PHONY: test
test:
@echo "Running tests..."
$(GO) test $(GOFLAGS) ./...
# Run tests with coverage
.PHONY: test-coverage
test-coverage:
@echo "Running tests with coverage..."
$(GO) test -v -coverprofile=coverage.out ./...
$(GO) tool cover -html=coverage.out -o coverage.html
@echo "Coverage report generated: coverage.html"
# Run the application
.PHONY: run
run: build
@echo "Running $(BINARY_NAME)..."
./$(BINARY_NAME) $(ARGS)
# Install the binary to GOPATH/bin
.PHONY: install
install:
@echo "Installing $(BINARY_NAME) to $(INSTALL_PATH)..."
$(GO) install $(GOFLAGS) $(LDFLAGS) $(MAIN_PATH)
@echo "Installed to: $(INSTALL_PATH)/$(BINARY_NAME)"
# Clean build artifacts
.PHONY: clean
clean:
@echo "Cleaning..."
@rm -f $(BINARY_NAME)
@rm -f coverage.out coverage.html
@echo "Clean complete"
# Format code
.PHONY: fmt
fmt:
@echo "Formatting code..."
$(GO) fmt ./...
# Run linter
.PHONY: lint
lint:
@echo "Running linter..."
@if command -v golangci-lint >/dev/null 2>&1; then \
golangci-lint run; \
else \
echo "golangci-lint not installed. Install with: curl -sSfL https://raw.githubusercontent.com/golangci/golangci-lint/master/install.sh | sh -s -- -b $(go env GOPATH)/bin"; \
fi
# Download dependencies
.PHONY: deps
deps:
@echo "Downloading dependencies..."
$(GO) mod download
$(GO) mod tidy
# Update dependencies
.PHONY: deps-update
deps-update:
@echo "Updating dependencies..."
$(GO) get -u ./...
$(GO) mod tidy
# Run init command for testing
.PHONY: init
init: build
./$(BINARY_NAME) init -v
# Run sync command for testing (deprecated - use push/pull)
.PHONY: sync
sync: build
./$(BINARY_NAME) sync -v
# Run pull command for testing
.PHONY: pull
pull: build
./$(BINARY_NAME) pull -v
# Run push command for testing
.PHONY: push
push: build
./$(BINARY_NAME) push -v
# Display help
.PHONY: help
help:
@echo "Available targets:"
@echo " build - Build the binary"
@echo " test - Run tests"
@echo " test-coverage - Run tests with coverage report"
@echo " run - Build and run the binary (use ARGS=... to pass arguments)"
@echo " install - Install the binary to GOPATH/bin"
@echo " clean - Remove build artifacts"
@echo " fmt - Format code"
@echo " lint - Run linter (requires golangci-lint)"
@echo " deps - Download dependencies"
@echo " deps-update - Update dependencies"
@echo " init - Run 'ai-docs init' command"
@echo " sync - Run 'ai-docs sync' command (deprecated)"
@echo " pull - Run 'ai-docs pull' command"
@echo " push - Run 'ai-docs push' command"
@echo " help - Display this help message"
@echo ""
@echo "Examples:"
@echo " make build"
@echo " make test"
@echo " make run ARGS='--help'"
@echo " make run ARGS='init --dry-run'"