Makefile

  1# Shelley Makefile
  2
  3.PHONY: build build-linux-aarch64 build-linux-x86 test test-go test-e2e ui serve clean help templates
  4
  5# Default target
  6all: build
  7
  8# Build templates into tarballs
  9templates:
 10	@for dir in templates/*/; do \
 11		name=$$(basename "$$dir"); \
 12		tar -czf "templates/$$name.tar.gz" -C "templates/$$name" --exclude='.DS_Store' .; \
 13	done
 14
 15# Build the UI and Go binary
 16build: ui templates
 17	@echo "Building Shelley..."
 18	go build -o bin/shelley ./cmd/shelley
 19
 20# Build for Linux (auto-detect architecture)
 21build-linux: ui templates
 22	@echo "Building Shelley for Linux..."
 23	@ARCH=$$(uname -m); \
 24	case $$ARCH in \
 25		x86_64) GOARCH=amd64 ;; \
 26		aarch64|arm64) GOARCH=arm64 ;; \
 27		*) echo "Unsupported architecture: $$ARCH" && exit 1 ;; \
 28	esac; \
 29	GOOS=linux GOARCH=$$GOARCH go build -o bin/shelley-linux ./cmd/shelley
 30
 31# Build for Linux ARM64
 32build-linux-aarch64: ui templates
 33	@echo "Building Shelley for Linux ARM64..."
 34	GOOS=linux GOARCH=arm64 go build -o bin/shelley-linux-aarch64 ./cmd/shelley
 35
 36# Build for Linux x86_64
 37build-linux-x86: ui templates
 38	@echo "Building Shelley for Linux x86_64..."
 39	GOOS=linux GOARCH=amd64 go build -o bin/shelley-linux-x86 ./cmd/shelley
 40
 41# Build UI
 42ui:
 43	@cd ui && pnpm install --frozen-lockfile --silent && pnpm run --silent build
 44
 45# Run Go tests
 46test-go: ui
 47	@echo "Running Go tests..."
 48	go test -v ./...
 49
 50# Run end-to-end tests
 51test-e2e: ui
 52	@echo "Running E2E tests..."
 53	cd ui && pnpm run test:e2e
 54
 55# Run E2E tests in headed mode (with visible browser)
 56test-e2e-headed: ui
 57	@echo "Running E2E tests (headed)..."
 58	cd ui && pnpm run test:e2e:headed
 59
 60# Run E2E tests in UI mode
 61test-e2e-ui: ui
 62	@echo "Opening E2E test UI..."
 63	cd ui && pnpm run test:e2e:ui
 64
 65# Run all tests
 66test: test-go test-e2e
 67
 68# Serve Shelley with predictable model for testing
 69serve-test: ui
 70	@echo "Starting Shelley with predictable model..."
 71	go run ./cmd/shelley --model predictable --db test.db serve
 72
 73# Serve Shelley normally
 74serve: ui
 75	@echo "Starting Shelley..."
 76	go run ./cmd/shelley serve
 77
 78# Clean build artifacts
 79clean:
 80	@echo "Cleaning..."
 81	rm -rf bin/
 82	rm -rf ui/dist/
 83	rm -rf ui/node_modules/
 84	rm -rf ui/test-results/
 85	rm -rf ui/playwright-report/
 86	rm -f *.db
 87	rm -f templates/*.tar.gz
 88
 89# Show help
 90help:
 91	@echo "Shelley Build Commands:"
 92	@echo ""
 93	@echo "  build         Build UI, templates, and Go binary"
 94	@echo "  build-linux-aarch64  Build for Linux ARM64"
 95	@echo "  build-linux-x86      Build for Linux x86_64"
 96	@echo "  ui            Build UI only"
 97	@echo "  templates     Build template tarballs"
 98	@echo "  test          Run all tests (Go + E2E)"
 99	@echo "  test-go       Run Go tests only"
100	@echo "  test-e2e      Run E2E tests (headless)"
101	@echo "  test-e2e-headed  Run E2E tests (visible browser)"
102	@echo "  test-e2e-ui   Open E2E test UI"
103	@echo "  serve         Start Shelley server"
104	@echo "  serve-test    Start Shelley with predictable model"
105	@echo "  clean         Clean build artifacts"
106	@echo "  help          Show this help"
107