v0.20.1 d9a391f

Makefile RawHistoryFolder

1# Makefile for dumber (Clean Architecture - puregotk)
2
3.PHONY: build build-frontend test lint clean install-tools dev generate help init check-docs
4
5# Load local overrides from .env.local if present (Makefile syntax)
6ifneq (,$(wildcard .env.local))
7include .env.local
8export
9endif
10
11# Variables
12BINARY_NAME=dumber
13MAIN_PATH=./cmd/dumber
14DIST_DIR=dist
15
16# Detect number of CPU cores for parallel compilation
17NPROCS?=$(shell nproc 2>/dev/null || echo 1)
18
19# Version information from git
20VERSION=$(shell git describe --tags --always --dirty 2>/dev/null || echo "v0.0.0-dev")
21COMMIT=$(shell git rev-parse --short HEAD 2>/dev/null || echo "unknown")
22BUILD_DATE=$(shell date -u +"%Y-%m-%dT%H:%M:%SZ")
23
24# Linker flags
25LDFLAGS=-ldflags "-s -w -X main.version=$(VERSION) -X main.commit=$(COMMIT) -X main.buildDate=$(BUILD_DATE)"
26
27# Default target
28help: ## Show this help message
29	@echo "Available targets:"
30	@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {printf "  \033[36m%-15s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST)
31
32# Build targets
33build: build-frontend ## Build the application (pure Go, no CGO)
34	@echo "Building $(BINARY_NAME) $(VERSION) using $(NPROCS) cores..."
35	@mkdir -p $(DIST_DIR)
36	CGO_ENABLED=0 go build -p $(NPROCS) $(LDFLAGS) -o $(DIST_DIR)/$(BINARY_NAME) $(MAIN_PATH)
37	@echo "Build successful! Binary: $(DIST_DIR)/$(BINARY_NAME)"
38
39build-frontend: ## Build homepage and error pages
40	@echo "Building webui pages (homepage + error)..."
41	@cd webui && npm install --silent && npm run build
42	@echo "Frontend build complete"
43
44build-quick: ## Build without frontend (faster for backend development)
45	@echo "Building $(BINARY_NAME) $(VERSION) (quick, no frontend)..."
46	@mkdir -p $(DIST_DIR)
47	CGO_ENABLED=0 go build -p $(NPROCS) $(LDFLAGS) -o $(DIST_DIR)/$(BINARY_NAME) $(MAIN_PATH)
48	@echo "Build successful! Binary: $(DIST_DIR)/$(BINARY_NAME)"
49
50# Development targets
51dev: ## Run in development mode
52	@echo "Running in development mode..."
53	go run $(MAIN_PATH)
54
55run: build-quick ## Build and run
56	@echo "Running $(BINARY_NAME)..."
57	$(DIST_DIR)/$(BINARY_NAME)
58
59generate: ## Generate code (SQLC)
60	@echo "Generating code with SQLC..."
61	sqlc generate
62	@echo "Code generation complete"
63
64mocks: ## Generate mock implementations with mockery
65	@echo "Generating mocks with mockery..."
66	mockery
67	@echo "Mock generation complete"
68
69# Testing
70test: ## Run tests
71	@echo "Running tests..."
72	go test -v ./...
73
74check-docs: ## Verify README/docs match code
75	@go run ./dev/check-docs.go --fail-on-error
76
77test-race: ## Run tests with race detection
78	@echo "Running tests with race detection..."
79	go test -race -v ./...
80
81test-cover: ## Run tests with coverage
82	@echo "Running tests with coverage..."
83	go test -coverprofile=coverage.out ./...
84	go tool cover -html=coverage.out -o coverage.html
85	@echo "Coverage report: coverage.html"
86
87# Linting
88lint: ## Run golangci-lint
89	@echo "Running golangci-lint..."
90	golangci-lint run
91
92lint-fix: ## Run golangci-lint with --fix
93	@echo "Running golangci-lint with --fix..."
94	golangci-lint run --fix
95
96# Format code
97fmt: ## Format Go code with gofmt
98	@echo "Formatting Go code..."
99	go fmt ./...
100
101# Tools installation
102install-tools: ## Install development tools
103	@echo "Installing development tools..."
104	go install github.com/sqlc-dev/sqlc/cmd/sqlc@latest
105	go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
106	@echo "Tools installed successfully"
107
108# Cleanup
109clean: ## Clean build artifacts
110	@echo "Cleaning build artifacts..."
111	rm -rf $(DIST_DIR)
112	rm -f $(BINARY_NAME)
113	rm -rf webui/dist webui/node_modules
114	rm -f assets/webui/homepage.min.js assets/webui/error.min.js assets/webui/config.min.js assets/webui/index.html assets/webui/error.html assets/webui/config.html assets/webui/style.css
115	rm -f coverage.out coverage.html
116	go clean -cache
117	go clean -testcache
118
119# Project initialization
120init: install-tools ## Initialize project dependencies and tools
121	@echo "Initializing project..."
122	go mod tidy
123	@echo "Project initialized! Run 'make help' for available commands."
124
125# Check setup
126check: ## Check that all tools and dependencies are working
127	@echo "Checking project setup..."
128	@echo "Go version:"
129	@go version
130	@echo "\nSQLC version:"
131	@sqlc version
132	@echo "\nGolangci-lint version:"
133	@golangci-lint version
134	@echo "\nBuilding project..."
135	@$(MAKE) build-quick
136	@echo "\nRunning tests..."
137	@$(MAKE) test
138	@echo "\nAll checks passed!"
139
140# Native release targets
141.PHONY: release-snapshot release
142
143release-snapshot: build-frontend ## Build snapshot using goreleaser
144	@echo "Building snapshot with goreleaser..."
145	goreleaser release --snapshot --clean
146
147release: ## Create full release using goreleaser
148	@echo "Building release with goreleaser..."
149	GITHUB_TOKEN=$$(gh auth token) goreleaser release --clean

Keyboard shortcuts

Single-key shortcuts are on. ctrl k and esc work whatever this says.

ctrl k :
go to a section, branch, tag, file or repository
?
this list
j k
move the row cursor down / up
enter
open the row under the cursor; on Files, a directory opens or closes in place
↑ ↓ ← → home end
in the file tree (focus on a row): previous / next row, close / open a directory or go to its parent / first entry, first / last row. They never open a file
l h
on Files: open a directory or a file / close a directory or go up to its parent, then to the parent page. Elsewhere: into the side panel (on a merge request, its files) / back to the content; there j k move between its controls
g g G
first / last row
/
filter the list; on Files, find a file anywhere in the repository (esc clears, enter opens the best match)
b
switch branch or tag
g s g f g c g b g m g i g r g a
tabs: summary, files, commits, branches & tags, merge requests, issues, releases, actions (when available)
g h
home
w
wide mode: use the whole width of the screen, or not (remembered)
y
copy a permalink pinned to the commit
d u x
diff: split / unified / collapse or expand all
e E
diff: the whole file in view / every file, with the lines the hunks hide
n
merge request: next note in the diff
esc
close a dialog, leave a field

Branches 8

Tags 42

↑↓ moveenter openesc close