forked from LukastGeorge/Grainlify-Backend
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
77 lines (48 loc) · 1.75 KB
/
Copy pathMakefile
File metadata and controls
77 lines (48 loc) · 1.75 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
.PHONY: run dev install-air lint build build-worker run-worker build-prod test openapi-validate openapi-sync
# Install air for live reload
install-air:
@echo "Installing air..."
@go install github.com/air-verse/air@latest
@echo "Air installed! Make sure ~/go/bin (or $${GOPATH}/bin) is in your PATH"
# Run with air (auto-reload on file changes)
dev:
@if command -v air > /dev/null; then \
air; \
else \
echo "Air not found. Installing..."; \
$(MAKE) install-air; \
echo "Please add ~/go/bin to your PATH or run: export PATH=\$$PATH:~/go/bin"; \
echo "Then run 'make dev' again"; \
fi
# Run without air (standard go run)
run:
@go run ./cmd/api
# Build the API binary
build:
@go build -o ./api ./cmd/api
# Build the binary with version metadata injected via ldflags.
build-prod:
@go build -ldflags="\
-X main.Version=$$(git describe --tags --always 2>/dev/null || echo dev) \
-X main.Commit=$$(git rev-parse --short HEAD) \
-X main.BuildTime=$$(date -u +%Y-%m-%dT%H:%M:%SZ)" \
-o ./api ./cmd/api
# Build the worker binary
build-worker:
@go build -o ./worker ./cmd/worker
# Run the worker (requires DB_URL and NATS_URL in env / .env)
run-worker:
@go run ./cmd/worker
# Run static analysis with the pinned golangci-lint configuration.
lint:
@golangci-lint run ./...
# Run unit tests with race detection; skips tests that require live network/DB.
test:
@go test -race -short ./...
# Validate the OpenAPI spec against the OpenAPI 3.x schema.
openapi-validate:
@go test -run TestOpenAPISpecValid ./internal/api/ -v
# Sync the root-level openapi.yaml mirror with the canonical copy.
openapi-sync:
@cp internal/api/openapi.yaml openapi.yaml 2>/dev/null || copy /y internal\api\openapi.yaml openapi.yaml >nul
@echo "openapi.yaml synced"