-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
101 lines (80 loc) · 4.23 KB
/
Makefile
File metadata and controls
101 lines (80 loc) · 4.23 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
.PHONY: build test lint e2e up down clean coverage coverage-e2e coverage-all gui-dev gui-build gui-bindings ubuntu-22 ubuntu-24 x11-setup help
.DEFAULT_GOAL := help
# Detect host OS for linting
UNAME_S := $(shell uname -s)
ifeq ($(UNAME_S),Darwin)
HOST_GOOS := darwin
else ifeq ($(UNAME_S),Linux)
HOST_GOOS := linux
else ifeq ($(UNAME_S),FreeBSD)
HOST_GOOS := freebsd
else
HOST_GOOS := windows
endif
SUVE_LOCALSTACK_EXTERNAL_PORT ?= 4566
COVERPKG = $(shell go list ./... | grep -v testutil | grep -v /e2e | grep -v internal/gui | grep -v /cmd/ | tr '\n' ',')
help: ## Show this help
@grep -E '^[a-zA-Z0-9_-]+:.*## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*## "}; {printf "\033[36m%-20s\033[0m %s\n", $$1, $$2}'
%:
@echo "make: *** Unknown target '$@'. See available targets below:" >&2
@echo "" >&2
@$(MAKE) -s help >&2
@exit 1
build: ## Build CLI binary
go build -o bin/suve ./cmd/suve
test: ## Run unit tests
go test $(shell go list ./... | grep -v internal/gui | grep -v /cmd/)
lint: ## Run linter (host OS only, with all build tags)
GOOS=$(HOST_GOOS) golangci-lint run --build-tags=e2e,production ./...
up: ## Start localstack container
SUVE_LOCALSTACK_EXTERNAL_PORT=$(SUVE_LOCALSTACK_EXTERNAL_PORT) docker compose up -d
@echo "Waiting for localstack to be ready on port $(SUVE_LOCALSTACK_EXTERNAL_PORT)..."
@until curl -sf http://127.0.0.1:$(SUVE_LOCALSTACK_EXTERNAL_PORT)/_localstack/health > /dev/null 2>&1; do sleep 1; done
@echo "localstack is ready"
down: ## Stop localstack container
docker compose down
e2e: up ## Run E2E tests (starts localstack)
SUVE_LOCALSTACK_EXTERNAL_PORT=$(SUVE_LOCALSTACK_EXTERNAL_PORT) go test -tags=e2e -v ./e2e/...
clean: ## Clean build artifacts and stop containers
rm -rf bin/ *.out
docker compose down -v 2>/dev/null || true
coverage: ## Run unit tests with coverage
go test -coverprofile=coverage.out -coverpkg=$(COVERPKG) $(shell go list ./... | grep -v internal/gui | grep -v /cmd/)
go tool cover -func=coverage.out | grep total
coverage-e2e: up ## Run E2E tests with coverage
SUVE_LOCALSTACK_EXTERNAL_PORT=$(SUVE_LOCALSTACK_EXTERNAL_PORT) go test -tags=e2e -coverprofile=coverage-e2e.out -coverpkg=$(COVERPKG) ./e2e/...
go tool cover -func=coverage-e2e.out | grep total
coverage-all: up ## Run all tests with combined coverage
@echo "Running unit tests with coverage..."
go test -coverprofile=coverage-unit.out -covermode=atomic -coverpkg=$(COVERPKG) $(shell go list ./... | grep -v internal/gui | grep -v /cmd/)
@echo "Running E2E tests with coverage..."
SUVE_LOCALSTACK_EXTERNAL_PORT=$(SUVE_LOCALSTACK_EXTERNAL_PORT) go test -tags=e2e -coverprofile=coverage-e2e.out -covermode=atomic -coverpkg=$(COVERPKG) ./e2e/...
@echo "Merging coverage profiles..."
@go run github.com/wadey/gocovmerge@latest coverage-unit.out coverage-e2e.out > coverage-all.out
go tool cover -func=coverage-all.out | grep total
gui-dev: ## Start GUI development server
cd gui && wails dev -skipbindings -tags dev
gui-build: ## Build GUI for production
cd gui && wails build -tags production -skipbindings
gui-bindings: ## Regenerate GUI bindings
@echo "Temporarily removing build constraints..."
@find gui internal/gui -name '*.go' -exec sed -i.bak 's|^//go:build.*||' {} \;
@echo "Generating bindings..."
@cd gui && timeout 30 wails dev -tags dev 2>&1 | head -30 || true
@echo "Restoring build constraints..."
@find gui internal/gui -name '*.go.bak' -exec sh -c 'mv "$$1" "$${1%.bak}"' _ {} \;
@echo "Done. Check internal/gui/frontend/wailsjs/go/ for updated bindings."
# Linux GUI test environment
# Prerequisites (macOS):
# 1. brew install --cask xquartz
# 2. XQuartz preferences -> Security -> "Allow connections from network clients"
# 3. Restart XQuartz after changing the setting
x11-setup:
@echo "Setting up X11 forwarding for Linux GUI..."
@xhost +localhost 2>/dev/null || true
ubuntu-22: x11-setup ## Start Ubuntu 22.04 desktop (webkit2gtk-4.0, requires XQuartz)
@echo "Starting Ubuntu 22.04 desktop..."
HOST_DISPLAY=host.docker.internal:0 docker compose --profile ubuntu-22 run --rm ubuntu-22
ubuntu-24: x11-setup ## Start Ubuntu 24.04 desktop (webkit2gtk-4.1, requires XQuartz)
@echo "Starting Ubuntu 24.04 desktop..."
HOST_DISPLAY=host.docker.internal:0 docker compose --profile ubuntu-24 run --rm ubuntu-24