-
-
Notifications
You must be signed in to change notification settings - Fork 24
Expand file tree
/
Copy pathMakefile
More file actions
136 lines (110 loc) · 5 KB
/
Makefile
File metadata and controls
136 lines (110 loc) · 5 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
135
136
.PHONY: help build run test test-race test-coverage lint fmt vet check fuzz fuzz-nightly clean deps tidy update-deps generate docs site release snapshot install verify all
# Default target
.DEFAULT_GOAL := help
# Variables
BINARY_NAME=devtui
VERSION?=$(shell git describe --tags --always --dirty 2>/dev/null || echo "dev")
COMMIT?=$(shell git rev-parse --short HEAD 2>/dev/null || echo "unknown")
DATE?=$(shell date -u +"%Y-%m-%dT%H:%M:%SZ")
LDFLAGS=-ldflags "-X github.com/skatkov/devtui/cmd.version=$(VERSION) -X github.com/skatkov/devtui/cmd.commit=$(COMMIT) -X github.com/skatkov/devtui/cmd.date=$(DATE)"
FUZZTIME?=5s
NIGHTLY_FUZZTIME?=45s
help: ## Display this help message
@echo "DevTUI - Development targets:"
@echo ""
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf " \033[36m%-15s\033[0m %s\n", $$1, $$2}'
@echo ""
build: ## Build the project
@echo "Building $(BINARY_NAME)..."
go build -v $(LDFLAGS) -o $(BINARY_NAME) .
@echo "Build complete: ./$(BINARY_NAME)"
run: ## Run the TUI (main mode)
@echo "Running DevTUI..."
go run $(LDFLAGS) main.go
test: ## Run all tests
@echo "Running tests..."
go test -v -failfast ./...
test-race: ## Run tests with race detection (what CI uses)
@echo "Running tests with race detection..."
go test -v -failfast -race ./...
fuzz: ## Run fuzz tests (set FUZZTIME=30s for deeper runs)
@echo "Running fuzz tests (FUZZTIME=$(FUZZTIME))..."
go test ./internal/base64 -run=^$$ -fuzz=FuzzBase64RoundTrip -fuzztime=$(FUZZTIME)
go test ./internal/base64 -run=^$$ -fuzz=FuzzDecodeMatchesStdlibBehavior -fuzztime=$(FUZZTIME)
go test ./internal/csv2json -run=^$$ -fuzz=FuzzConvertDoesNotPanic -fuzztime=$(FUZZTIME)
go test ./internal/converter -run=^$$ -fuzz=FuzzYAMLToJSON -fuzztime=$(FUZZTIME)
go test ./internal/converter -run=^$$ -fuzz=FuzzJSONToYAML -fuzztime=$(FUZZTIME)
go test ./internal/converter -run=^$$ -fuzz=FuzzTOMLToJSON -fuzztime=$(FUZZTIME)
go test ./internal/converter -run=^$$ -fuzz=FuzzJSONToTOML -fuzztime=$(FUZZTIME)
go test ./internal/converter -run=^$$ -fuzz=FuzzXMLToJSON -fuzztime=$(FUZZTIME)
go test ./internal/converter -run=^$$ -fuzz=FuzzJSONToXML -fuzztime=$(FUZZTIME)
go test ./internal/converter -run=^$$ -fuzz=FuzzYAMLToTOML -fuzztime=$(FUZZTIME)
go test ./internal/converter -run=^$$ -fuzz=FuzzTOMLToYAML -fuzztime=$(FUZZTIME)
go test ./internal/yamlfmt -run=^$$ -fuzz=FuzzFormatYAML -fuzztime=$(FUZZTIME)
go test ./internal/htmlfmt -run=^$$ -fuzz=FuzzFormatHTML -fuzztime=$(FUZZTIME)
go test ./tui/jsonrepair -run=^$$ -fuzz=FuzzRepairJSONProducesValidJSON -fuzztime=$(FUZZTIME)
go test ./tui/json2toon -run=^$$ -fuzz=FuzzConvertNoPanic -fuzztime=$(FUZZTIME)
go test ./tui/json2toon -run=^$$ -fuzz=FuzzConvertWithOptionsNoPanic -fuzztime=$(FUZZTIME)
fuzz-nightly: ## Run extended fuzz tests (default NIGHTLY_FUZZTIME=45s)
@echo "Running nightly fuzz tests (NIGHTLY_FUZZTIME=$(NIGHTLY_FUZZTIME))..."
$(MAKE) fuzz FUZZTIME=$(NIGHTLY_FUZZTIME)
test-coverage: ## Run tests with coverage report
@echo "Running tests with coverage..."
go test -coverprofile=coverage.txt ./...
go tool cover -html=coverage.txt
lint: ## Run golangci-lint
@echo "Running linters..."
golangci-lint run
fmt: ## Format code with gofumpt and goimports
@echo "Formatting code..."
golangci-lint run --fix
vet: ## Run go vet
@echo "Running go vet..."
go vet ./...
check: lint test-race ## Run linters and tests with race detection
docs: ## Generate CLI and TUI documentation for the website
@echo "Generating documentation..."
cd docs && go run *.go
@echo "Documentation generated in site/"
site: docs ## Alias for docs target
clean: ## Clean build artifacts
@echo "Cleaning..."
rm -f $(BINARY_NAME)
rm -f coverage.txt
rm -rf dist/
@echo "Clean complete"
deps: ## Download dependencies
@echo "Downloading dependencies..."
go mod download
tidy: ## Run go mod tidy to clean up dependencies
@echo "Tidying dependencies..."
go mod tidy
@echo "Dependencies tidied"
update-deps: ## Update all dependencies to latest versions
@echo "Updating dependencies..."
go get -u ./...
go mod tidy
@echo "Dependencies updated"
generate: ## Run go generate
@echo "Running go generate..."
go generate ./...
release: ## Build release with goreleaser (creates binaries for all platforms)
@echo "Building release with goreleaser..."
goreleaser release --clean
snapshot: ## Build snapshot release with goreleaser (no publish)
@echo "Building snapshot release..."
goreleaser release --snapshot --clean
@echo "Snapshot built in dist/"
install: build ## Build and install to GOPATH/bin
@echo "Installing $(BINARY_NAME) to $(GOPATH)/bin..."
go install $(LDFLAGS) .
@echo "Installed: $(shell which $(BINARY_NAME))"
verify: generate tidy ## Verify go generate and go mod tidy don't create changes
@if [ -n "$$(git status --porcelain)" ]; then \
echo "Error: git status is not clean after generate and tidy"; \
git status --porcelain; \
exit 1; \
fi
@echo "Verification passed"
all: clean generate tidy build test lint ## Run all checks and build
@echo "All tasks complete"