-
-
Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathMakefile
More file actions
118 lines (94 loc) · 3.5 KB
/
Makefile
File metadata and controls
118 lines (94 loc) · 3.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
# Makefile for Go project
APP_NAME=ggc
OUT?=coverage.out
.PHONY: install-tools deps build run test test-race test-integration vuln lint clean cover test-cover test-and-lint fmt docs demos
# Install required tools
install-tools:
@if ! command -v golangci-lint &> /dev/null; then \
echo "Installing required tools..."; \
go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@latest; \
echo "Tools installed successfully"; \
else \
echo "Tools already installed"; \
fi
# Install dependencies and tools
deps: install-tools
@echo "Installing dependencies..."
go mod download
go mod tidy
@echo "Dependencies installed successfully"
VERSION := $(shell git describe --tags --always --dirty)
COMMIT := $(shell git rev-parse --short HEAD)
# Full build with version info
build:
go build -ldflags="-X main.version=${VERSION} -X main.commit=${COMMIT}" -o $(APP_NAME)
run: build
./$(APP_NAME)
fmt:
go fmt ./...
test:
go test ./...
test-race:
go test -race ./...
vuln: install-tools
@echo "Installing latest govulncheck..."
@go install golang.org/x/vuln/cmd/govulncheck@latest
govulncheck ./...
# Run integration tests (BATS). Requires `bats` installed.
test-integration: build
@if ! command -v bats >/dev/null 2>&1; then \
echo "Error: bats is required. Install via 'brew install bats-core' or your package manager."; \
exit 1; \
fi
@echo "Running BATS integration tests..."
bats test/
lint: install-tools
golangci-lint run --max-issues-per-linter=0 --max-same-issues=0
clean:
rm -f $(APP_NAME)
cover:
go test $$(go list ./... | grep -v testutil) -coverprofile=coverage.out
go tool cover -func=coverage.out
test-cover:
go test $$(go list ./... | grep -v testutil) -coverprofile=$(OUT)
test-and-lint: test lint
@echo "All tests and lint checks passed"
# Update documentation and shell completions from registry
.PHONY: docs completions
docs:
@echo "Regenerating docs/guide/commands.md from registry..."
@go run tools/cmd/gendocs/main.go
@$(MAKE) completions
@echo "Documentation, completions updated successfully"
DEMO_SCENARIOS := cli-workflow interactive-overview branch-management stash-cycle
DEMO_WORKSPACE_ROOT := $(CURDIR)/docs/demos/workspaces
DEMO_OUTPUT_DIR := docs/demos/generated
# Generate VHS-powered demo assets
.PHONY: demos
demos: build
@if ! command -v vhs >/dev/null 2>&1; then \
echo "Error: vhs is required. Install https://github.com/charmbracelet/vhs"; \
exit 1; \
fi
@if ! command -v ttyd >/dev/null 2>&1; then \
echo "Error: ttyd is required by vhs. Install https://github.com/tsl0922/ttyd"; \
exit 1; \
fi
@if ! command -v ffmpeg >/dev/null 2>&1; then \
echo "Error: ffmpeg is required by vhs. Install it via your package manager."; \
exit 1; \
fi
@mkdir -p $(DEMO_OUTPUT_DIR)
@for scenario in $(DEMO_SCENARIOS); do \
echo "Preparing fixture for $$scenario"; \
./tools/demos/reset-fixture.sh $$scenario >/dev/null; \
done
@echo "Generating demo GIFs with vhs..."
@GGC_DEMO_CLI_WORKDIR=$(DEMO_WORKSPACE_ROOT)/cli-workflow PATH="$(CURDIR):$$PATH" vhs docs/demos/scripts/cli-workflow.tape
@GGC_DEMO_INTERACTIVE_WORKDIR=$(DEMO_WORKSPACE_ROOT)/interactive-overview PATH="$(CURDIR):$$PATH" vhs docs/demos/scripts/interactive-overview.tape
@GGC_DEMO_BRANCH_WORKDIR=$(DEMO_WORKSPACE_ROOT)/branch-management PATH="$(CURDIR):$$PATH" vhs docs/demos/scripts/branch-management.tape
@echo "Demo assets written to $(DEMO_OUTPUT_DIR)"
completions:
@echo "Generating shell completions from registry..."
@go run ./tools/cmd/gencompletions
@echo "Shell completions updated from registry"