-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
128 lines (108 loc) · 4.96 KB
/
Copy pathMakefile
File metadata and controls
128 lines (108 loc) · 4.96 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
BINARY_NAME := tusk
BUILD_DIR := bin
GO := go
GOFLAGS := -v
.PHONY: all build clean test test-race vet lint fmt help docs web frontend \
devcontainer-up devcontainer-rebuild devcontainer-shell \
devcontainer-stop devcontainer-down devcontainer-nuke
DEVCONTAINER_CID := docker ps -a --filter "label=devcontainer.local_folder=$(CURDIR)" -q
DEVCONTAINER_VOLUMES := \
tusk-devcontainer-claude-home \
tusk-devcontainer-go-cache \
tusk-devcontainer-gh-config \
tusk-devcontainer-nvim-data \
tusk-devcontainer-nvim-state \
tusk-devcontainer-nvim-cache \
tusk-devcontainer-ollama
all: build
build:
@mkdir -p $(BUILD_DIR)
$(GO) build $(GOFLAGS) -o $(BUILD_DIR)/$(BINARY_NAME) ./cmd/tusk
clean:
rm -rf $(BUILD_DIR)
# v1 test target — populated as tests land
test:
@pkgs=$$($(GO) list ./... 2>/dev/null); [ -z "$$pkgs" ] && echo "no packages to test" || $(GO) test $(GOFLAGS) $$pkgs
test-race:
@pkgs=$$($(GO) list ./... 2>/dev/null); [ -z "$$pkgs" ] && echo "no packages to test" || $(GO) test $(GOFLAGS) -race $$pkgs
vet:
@pkgs=$$($(GO) list ./... 2>/dev/null); [ -z "$$pkgs" ] && echo "no packages to vet" || $(GO) vet $$pkgs
lint:
@command -v golangci-lint >/dev/null || { echo "golangci-lint not installed"; exit 0; }
@pkgs=$$($(GO) list ./... 2>/dev/null); [ -z "$$pkgs" ] && echo "no packages to lint" || golangci-lint run ./...
fmt:
@pkgs=$$($(GO) list ./... 2>/dev/null); [ -z "$$pkgs" ] && echo "no packages to fmt" || $(GO) fmt $$pkgs
web:
cd web && pnpm install --frozen-lockfile && pnpm build
# Aggregate target: builds every committed frontend dist. Drift guards
# (lefthook pre-push, CI's dist-drift job) call this instead of the
# individual targets so adding another frontend only means adding it here.
frontend: web
docs: build
$(BUILD_DIR)/$(BINARY_NAME) docgen man docs/cli
help:
@echo "v1 Make targets:"
@echo " build — compile the tusk binary (stub until Plan 1b)"
@echo " test — run unit tests"
@echo " test-race — run unit tests with race detector"
@echo " vet — run go vet"
@echo " lint — run golangci-lint"
@echo " fmt — run gofmt across the tree"
@echo " docs — regenerate man pages and markdown CLI reference"
@echo " clean — remove build artifacts"
@echo " web — build the unified web frontend into internal/webapp/dist"
@echo " frontend — build all committed frontend dists (web)"
@echo " devcontainer-up — build and start the dev container (uses BuildKit cache)"
@echo " devcontainer-rebuild — build and start the dev container from scratch (no cache)"
@echo " devcontainer-shell — open an interactive zsh inside the running dev container"
@echo " devcontainer-stop — stop the dev container (preserves state)"
@echo " devcontainer-down — stop and remove the dev container"
@echo " devcontainer-nuke — remove container, named volumes, and image"
devcontainer-up:
devcontainer up --workspace-folder $(CURDIR)
devcontainer-rebuild:
devcontainer up --workspace-folder $(CURDIR) --build-no-cache
devcontainer-shell:
@cid=$$($(DEVCONTAINER_CID)); \
if [ -z "$$cid" ]; then echo "no dev container; run 'make devcontainer-up' first" >&2; exit 1; fi; \
docker exec -it -u vscode -w /workspaces/tusk $$cid /bin/zsh
devcontainer-stop:
@cid=$$($(DEVCONTAINER_CID)); \
if [ -n "$$cid" ]; then docker stop $$cid; else echo "no dev container to stop"; fi
devcontainer-down:
@cid=$$($(DEVCONTAINER_CID)); \
if [ -n "$$cid" ]; then docker rm -f $$cid; else echo "no dev container to remove"; fi
# Nuke all local state for this project's dev container: the container
# (running or stopped), its built image, and the named volumes. After this,
# `make devcontainer-up` rebuilds from scratch with fresh volumes — nothing
# from the host leaks in.
devcontainer-nuke:
@imgs=""; \
for c in $$($(DEVCONTAINER_CID)); do \
img=$$(docker inspect --format '{{.Image}}' $$c 2>/dev/null); \
[ -n "$$img" ] && imgs="$$imgs $$img"; \
echo "removing container $$c (label match)"; \
docker rm -f $$c >/dev/null; \
done; \
for v in $(DEVCONTAINER_VOLUMES); do \
for c in $$(docker ps -a -q --filter volume=$$v); do \
img=$$(docker inspect --format '{{.Image}}' $$c 2>/dev/null); \
[ -n "$$img" ] && imgs="$$imgs $$img"; \
echo "removing container $$c (uses $$v)"; \
docker rm -f $$c >/dev/null; \
done; \
done; \
for v in $(DEVCONTAINER_VOLUMES); do \
if ! docker volume inspect $$v >/dev/null 2>&1; then \
echo "volume $$v not present"; \
elif docker volume rm -f $$v >/dev/null 2>&1; then \
echo "removed volume $$v"; \
else \
echo "FAILED to remove $$v — still referenced by:"; \
docker ps -a --filter volume=$$v --format ' {{.ID}} {{.Names}} ({{.Status}})'; \
fi; \
done; \
for img in $$(printf '%s\n' $$imgs | sort -u); do \
[ -z "$$img" ] && continue; \
docker rmi -f $$img >/dev/null 2>&1 && echo "removed image $$img" || echo "image $$img still in use"; \
done