-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMakefile
More file actions
114 lines (87 loc) · 3.12 KB
/
Makefile
File metadata and controls
114 lines (87 loc) · 3.12 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
.PHONY: all api cli run test test-services test-handlers test-integration check clean release openapi-gen openapi-check openapi-docs migrate migrate-plan migrate-check migrate-status migrate-lint migrate-guard migrate-snapshot migrate-drift-check migrate-ci-gate migrate-forward-compat test-migrations test-e2e-postgres test-e2e-sqlite
# Build the API server and the CLI tool
all: api cli
# Build the API server
api:
@echo "Building API server..."
@go build -o bin/ecommerce-api main.go
# Build the CLI tool
cli:
@echo "Building CLI tool..."
@go build -o bin/ecommerce-cli ./cmd/cli
# Run the API server
run: api
@./bin/ecommerce-api
# Run tests
test:
@go test ./...
test-services:
go test ./internal/services/...
test-handlers:
go test ./handlers
test-integration:
go test ./handlers -run Integration
check: openapi-check
go test ./internal/services/...
go test ./handlers
# Apply database migrations
migrate:
@go run ./cmd/migrate
# Print ordered pending database migrations
migrate-plan:
@go run ./cmd/migrate plan
# Ensure database is at latest migration version
migrate-check:
@go run ./cmd/migrate check
# Print migration status summary (known/applied/pending)
migrate-status:
@go run ./cmd/migrate status
# Lint migration definitions and conventions
migrate-lint:
@go run ./cmd/migrate lint
# Validate readiness checks for pending contract migrations
migrate-guard:
@go run ./cmd/migrate guard
# Generate canonical schema snapshot artifact from configured DB
migrate-snapshot:
@go run ./cmd/migrate snapshot
# Verify current DB schema matches committed snapshot artifact
migrate-drift-check:
@go run ./cmd/migrate drift-check
# Migration-focused backend tests
test-migrations:
@go test ./internal/migrations/... ./cmd/migrate/... ./cmd/cli/commands/...
# CI migration gate (tests + migrate check + replay + drift + forward-compat smoke)
migrate-ci-gate:
@./scripts/ci-migration-gate.sh
# Forward-compat smoke: previous commit DB -> current binary startup
migrate-forward-compat:
@./scripts/ci-forward-compat-smoke.sh
# Migration-sensitive E2E suite (required path for CI): Postgres only
test-e2e-postgres:
@cd frontend && E2E_DB_DRIVER=postgres bun run test:e2e
# Optional local API-behavior smoke path: SQLite only
test-e2e-sqlite:
@cd frontend && E2E_DB_DRIVER=sqlite bun run test:e2e
# Generate backend + frontend API contract types from OpenAPI
openapi-gen:
@./scripts/generate-api-contracts.sh
# Ensure generated contract files are up to date
openapi-check:
@./scripts/generate-api-contracts.sh
@if [ -n "$$(git status --porcelain -- internal/apicontract/openapi.gen.go frontend/src/lib/api/generated/openapi.ts)" ]; then \
echo "Generated API contract files are out of date."; \
git --no-pager diff -- internal/apicontract/openapi.gen.go frontend/src/lib/api/generated/openapi.ts; \
exit 1; \
fi
# Generate API documentation from OpenAPI
openapi-docs:
@./scripts/generate-api-docs.sh
# Clean build artifacts
clean:
@rm -rf bin/
# Build release version
release:
@echo "Building for release"
@go build -o bin/ecommerce-api -ldflags="-s -w" main.go
@go build -o bin/ecommerce-cli -ldflags="-s -w" ./cmd/cli/main.go