-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
83 lines (65 loc) · 2.42 KB
/
Copy pathMakefile
File metadata and controls
83 lines (65 loc) · 2.42 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
.PHONY: build install test check fmt lint clean update-golden fetch-queries bootstrap cgo-free
# Build the binaries (set VERSION to inject a version string)
VERSION ?=
LDFLAGS := $(if $(VERSION),-ldflags "-X main.version=$(VERSION)",)
# All three frontends: the diff TUI (dfd), the ticket CLI (tdb), and the
# reviewparrot linter (rpt).
BINARIES := dfd tdb rpt
build:
@for b in $(BINARIES); do echo "building $$b"; go build $(LDFLAGS) -o $$b ./cmd/$$b/ || exit 1; done
# Install to GOPATH/bin
install:
go install $(LDFLAGS) ./cmd/dfd/ ./cmd/tdb/ ./cmd/rpt/
# Run all tests
test:
go test ./...
# Run tests with verbose output
test-v:
go test -v ./...
# Update golden files after intentional view changes
update-golden:
go test ./internal/tui/... -update
# Run all checks (fmt, vet, lint, cgo-free, test)
check: fmt-check vet lint cgo-free test
# tdb and rpt must build without cgo: tree-sitter (cgo) is a dfd-only dependency.
# This is a regression gate — neither tool should re-acquire a cgo import.
cgo-free:
CGO_ENABLED=0 go build -o /dev/null ./cmd/tdb/ ./cmd/rpt/
# Check formatting (fails if files need formatting)
fmt-check:
@test -z "$$(gofmt -l .)" || (echo "Files need formatting:"; gofmt -l .; exit 1)
# Format code
fmt:
gofmt -w .
# Run go vet
vet:
go vet ./...
# Run staticcheck if available
lint:
@which staticcheck > /dev/null && staticcheck ./... || echo "staticcheck not installed, skipping"
# Clean build artifacts
clean:
rm -f $(BINARIES)
go clean ./...
# Run the app on HEAD
run: build
./dfd
# Show test coverage
cover:
go test -coverprofile=coverage.out ./...
go tool cover -html=coverage.out -o coverage.html
@echo "Coverage report: coverage.html"
# Fetch syntax highlighting queries from upstream tree-sitter grammar repos.
# This downloads .scm query files for all supported languages.
# NOTE: We use upstream repos, NOT nvim-treesitter (which has Lua-specific predicates).
# WARNING: This overwrites local modifications! After running:
# 1. Check 'git diff pkg/highlight/queries/' for changes
# 2. Reorder patterns if needed (general before specific for "last match wins")
# 3. Re-apply any LOCAL MODIFICATION sections
# See pkg/highlight/queries/fetch_queries.sh for details.
# Download generated parser files that are too large to commit (e.g. SQL ~38MB).
# Run this once after cloning before building.
bootstrap:
go generate ./pkg/highlight/grammars/...
fetch-queries:
./pkg/highlight/queries/fetch_queries.sh