-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
126 lines (102 loc) · 3.97 KB
/
Makefile
File metadata and controls
126 lines (102 loc) · 3.97 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
GO ?= go
PKG ?= ./...
BIN ?= grimnirradio
GOFLAGS ?=
RACE ?= 1
PROTO_DIR ?= proto
PROTO_OUT ?= proto
.PHONY: help fmt fmt-check vet lint tidy test coverage coverage-check test-e2e test-frontend build build-mediascan verify ci proto proto-clean \
dev-db dev-redis dev-stack run-control run-media
help:
@echo "Common targets:"
@echo " make verify # tidy, fmt, vet, (lint), test"
@echo " make fmt # gofmt -s -w"
@echo " make vet # go vet ./..."
@echo " make lint # golangci-lint run (if installed)"
@echo " make test # go test (-race)"
@echo " make coverage # run coverage report (default target 80%)"
@echo " make coverage-check # enforce coverage threshold (set COVERAGE_MIN)"
@echo " make build # build cmd/$(BIN)"
@echo ""
@echo "Frontend testing targets:"
@echo " make test-e2e # Run E2E browser tests (go-rod)"
@echo " make test-routes # Quick route verification (no browser)"
@echo ""
@echo "Development targets:"
@echo " make dev-db # Start PostgreSQL container"
@echo " make dev-redis # Start Redis container"
@echo " make dev-stack # Start full dev stack (docker-compose)"
@echo " make run-control # Run control plane locally"
@echo " make run-media # Run media engine locally"
fmt:
@files=$$(git ls-files '*.go'); \
gofmt -s -w $$files
fmt-check:
@files=$$(git ls-files '*.go'); \
unformatted=$$(gofmt -l $$files); \
if [ -n "$$unformatted" ]; then \
echo "Unformatted Go files:"; echo "$$unformatted"; \
exit 1; \
fi
vet:
@$(GO) vet $(GOFLAGS) $(PKG)
lint:
@command -v golangci-lint >/dev/null 2>&1 && golangci-lint run || echo "golangci-lint not found; skipping lint"
tidy:
@$(GO) mod tidy
test:
@$(GO) test $(GOFLAGS) $(if $(filter 1,$(RACE)),-race,) $(PKG)
coverage:
@COVERAGE_ENFORCE=0 COVERAGE_MIN=$${COVERAGE_MIN:-80} ./scripts/coverage.sh
coverage-check:
@COVERAGE_ENFORCE=1 COVERAGE_MIN=$${COVERAGE_MIN:-80} ./scripts/coverage.sh
build:
@$(GO) build $(GOFLAGS) -o ./grimnirradio ./cmd/grimnirradio
@$(GO) build $(GOFLAGS) -o ./mediaengine ./cmd/mediaengine
build-mediascan:
@$(GO) build $(GOFLAGS) -o ./bin/mediascan ./cmd/mediascan
verify: tidy fmt vet lint test
ci: verify fmt-check
proto:
@echo "Generating protobuf code..."
@PATH="$$PATH:$$HOME/go/bin" protoc --go_out=. --go_opt=paths=source_relative \
--go-grpc_out=. --go-grpc_opt=paths=source_relative \
$(PROTO_DIR)/mediaengine/v1/*.proto
proto-clean:
@find $(PROTO_OUT) -name '*.pb.go' -delete
@echo "Cleaned generated protobuf files"
# Development targets
dev-db:
@docker run -d --name grimnir-postgres \
-e POSTGRES_USER=grimnir \
-e POSTGRES_PASSWORD=grimnir_secret \
-e POSTGRES_DB=grimnir \
-p 5432:5432 \
postgres:15-alpine || docker start grimnir-postgres
@echo "PostgreSQL running on localhost:5432"
dev-redis:
@docker run -d --name grimnir-redis \
-p 6379:6379 \
redis:7-alpine || docker start grimnir-redis
@echo "Redis running on localhost:6379"
dev-stack:
@docker compose up -d postgres redis
@echo "Dev stack running (postgres + redis)"
run-control:
@if [ -f .env ]; then set -a; . ./.env; set +a; fi; \
GRIMNIR_DB_DSN="host=localhost port=5432 user=grimnir password=$${POSTGRES_PASSWORD:-grimnir_secret} dbname=grimnir sslmode=disable" \
GRIMNIR_REDIS_ADDR="localhost:6379" \
GRIMNIR_MEDIA_ENGINE_GRPC_ADDR="localhost:9091" \
GRIMNIR_JWT_SIGNING_KEY="$${GRIMNIR_JWT_SIGNING_KEY:-dev-secret-key}" \
$(GO) run ./cmd/grimnirradio serve
run-media:
$(GO) run ./cmd/mediaengine
# Frontend testing targets
test-e2e:
@echo "Running E2E frontend tests..."
@E2E_HEADLESS=true TEST_DB_DSN="host=localhost user=postgres password=postgres dbname=postgres sslmode=disable" $(GO) test $(GOFLAGS) -v ./test/e2e/...
test-frontend: test-e2e
# Test all routes are working (quick HTTP check without browser)
test-routes:
@echo "Running route tests..."
@TEST_DB_DSN="host=localhost user=postgres password=postgres dbname=postgres sslmode=disable" $(GO) test $(GOFLAGS) -v -run TestTemplateRendering ./test/e2e/...