-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
133 lines (100 loc) · 3.78 KB
/
Copy pathMakefile
File metadata and controls
133 lines (100 loc) · 3.78 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
.PHONY: all web css generate build docker-build clean dev test test-web test-short test-all test-browser bench cover lint vet fmt tsc deps watch help
BINARY := /tmp/s3-server
WEB_DIR := web
GO := go
TEMPL := $(GO) tool templ
# --- Full build pipeline ---
# Full build: deps → frontend bundle → CSS → generate → Go binary
all: web css generate build
# --- Dependencies ---
deps:
bun install
$(GO) mod download
# --- Frontend ---
# Install deps and build Vite bundle (sodium, sia SDK, ky → web/dist)
web:
cd $(WEB_DIR) && bun run build
# Build minified Tailwind v4 CSS — @source directives in input.css handle content scanning
css:
bun run build:css
# --- Code generation ---
# Generate build metadata (s3d version from go.mod) + templ files
generate:
$(GO) generate ./internal/build
$(TEMPL) generate
# --- Go build ---
build:
$(GO) build -o $(BINARY) ./cmd/s3-server/
# Build Docker image
docker-build:
docker compose build
# --- Development ---
# Watch mode: templ + Go hot reload (requires air: go install github.com/air-verse/air@latest)
watch:
$(TEMPL) generate && air -start
# Quick dev: build everything and run
dev: css web generate build
$(BINARY) serve --listen-addr 0.0.0.0:8080 --data-dir /tmp/s3-server-test-data
# --- Testing ---
# Go tests with race detector
test:
TEST_SECRET_KEY=test-key-not-for-prod TEST_ACCESS_KEY=test-key-not-for-prod $(GO) test -count=1 -race ./...
# Frontend tests (real Chromium via Playwright)
test-web: test-browser
# Go tests in short mode (skip integration)
test-short:
$(GO) test -count=1 -short ./...
# All tests: Go + browser
test-all: test test-browser
# Browser tests with real Chromium via Playwright
test-browser:
cd $(WEB_DIR) && PATH="$$HOME/.local/bin:$$PATH" PLAYWRIGHT_BROWSERS_PATH=$$HOME/.cache/ms-playwright bunx vitest run --config vitest.browser.config.ts browser/
# Go benchmarks with memory allocation stats
bench:
$(GO) test -bench=. -benchmem ./...
# Go test coverage (collect only, no gate)
cover:
$(GO) test -count=1 -coverprofile=coverage.out ./...
$(GO) tool cover -func=coverage.out | tail -1
@echo "Coverage report: coverage.out (run 'go tool cover -html=coverage.out' to view)"
# TypeScript type check
tsc:
cd $(WEB_DIR) && bun x tsc --noEmit
# --- Linting & formatting ---
fmt:
$(GO) fmt ./...
$(TEMPL) fmt .
vet:
$(GO) vet ./...
lint: vet
@command -v golangci-lint >/dev/null 2>&1 && golangci-lint run ./... || echo "golangci-lint not installed, skipping"
# --- Cleanup ---
clean:
rm -f $(BINARY)
rm -rf /tmp/s3-server-test-data
rm -rf internal/views/web/dist
rm -f internal/views/*_templ.go
rm -f internal/build/build_gen.go
# --- Help ---
help:
@echo "s3-server build targets:"
@echo " all - Full build: web + css + generate + build"
@echo " deps - Install JS + Go dependencies"
@echo " web - Build Vite frontend bundle"
@echo " css - Build minified Tailwind CSS"
@echo " generate - Run go:generate + templ generate"
@echo " build - Build Go binary"
@echo " dev - Full build + run locally"
@echo " watch - Hot reload mode (requires air)"
@echo " test - Run Go tests with race detector"
@echo " test-web - Run frontend tests (real Chromium via Playwright)"
@echo " test-short - Run Go tests (short mode, skip integration)"
@echo " test-all - Run Go + web unit tests"
@echo " test-browser - Run browser tests with real Chromium (Playwright)"
@echo " bench - Run Go benchmarks with memory stats"
@echo " cover - Run Go tests with coverage report"
@echo " tsc - TypeScript type check"
@echo " fmt - Format Go + templ files"
@echo " vet - Run go vet"
@echo " lint - Run golangci-lint (if installed)"
@echo " clean - Remove binary, dist, generated files"