-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathMakefile
More file actions
151 lines (124 loc) · 4.69 KB
/
Copy pathMakefile
File metadata and controls
151 lines (124 loc) · 4.69 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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
.PHONY: all build test lint clean dev docker-up docker-down migrate seed help
# Variables
BACKEND_DIR := backend
FRONTEND_DIR := frontend
BIN_DIR := bin
TOOLS_DIR := tools
# Default target
all: lint test build
# Help
help:
@echo "OpenPairing - Chess Tournament Management Platform"
@echo ""
@echo "Usage:"
@echo " make dev - Start development environment"
@echo " make build - Build all services"
@echo " make test - Run all tests"
@echo " make lint - Run linters"
@echo " make clean - Clean build artifacts"
@echo " make docker-up - Start Docker services"
@echo " make docker-down - Stop Docker services"
@echo " make migrate-up - Run database migrations"
@echo " make migrate-down - Rollback database migrations"
@echo " make seed - Seed database with demo data"
@echo " make seed-force - Force seed (clear existing data)"
@echo ""
@echo "Pairing tools ($(TOOLS_DIR)/):"
@echo " - javafo.jar - JaVaFo Swiss pairing engine"
@echo " - bbpPairings.exe - bbpPairings Swiss pairing engine"
@echo ""
# Development
dev: docker-up
@echo "Starting development servers..."
@echo "Pairing tools: $(TOOLS_DIR)/javafo.jar, $(TOOLS_DIR)/bbpPairings.exe"
@cd $(BACKEND_DIR) && JAVAFO_PATH=$(PWD)/$(TOOLS_DIR)/javafo.jar BBP_PATH=$(PWD)/$(TOOLS_DIR)/bbpPairings.exe go run ./cmd/api &
@cd $(FRONTEND_DIR) && npm run dev
# Build targets
build: build-backend build-frontend
build-backend:
@echo "Building backend services..."
@mkdir -p $(BIN_DIR)
cd $(BACKEND_DIR) && CGO_ENABLED=0 go build -ldflags="-w -s" -o ../$(BIN_DIR)/api ./cmd/api
cd $(BACKEND_DIR) && CGO_ENABLED=0 go build -ldflags="-w -s" -o ../$(BIN_DIR)/chess ./cmd/chess
cd $(BACKEND_DIR) && CGO_ENABLED=0 go build -ldflags="-w -s" -o ../$(BIN_DIR)/worker ./cmd/worker
@echo "Backend built successfully"
build-frontend:
@echo "Building frontend..."
cd $(FRONTEND_DIR) && npm ci && npm run build
@echo "Frontend built successfully"
# Test targets
test: test-backend test-frontend
test-backend:
@echo "Running backend tests..."
cd $(BACKEND_DIR) && JAVAFO_JAR_PATH=$(PWD)/$(TOOLS_DIR)/javafo.jar BBP_PATH=$(PWD)/$(TOOLS_DIR)/bbpPairings.exe go test -v -race -coverprofile=coverage.out ./...
test-frontend:
@echo "Running frontend tests..."
cd $(FRONTEND_DIR) && npm run test:coverage
# Lint targets
lint: lint-backend lint-frontend
lint-backend:
@echo "Linting backend..."
cd $(BACKEND_DIR) && golangci-lint run --timeout=5m
lint-frontend:
@echo "Linting frontend..."
cd $(FRONTEND_DIR) && npm run lint && npm run format:check && npm run typecheck
# Clean
clean:
@echo "Cleaning build artifacts..."
rm -rf $(BIN_DIR)
rm -rf $(FRONTEND_DIR)/.next
rm -rf $(FRONTEND_DIR)/node_modules
rm -rf $(BACKEND_DIR)/coverage.out
rm -rf $(FRONTEND_DIR)/coverage
# Docker targets
docker-up:
@echo "Starting Docker services..."
docker-compose up -d postgres redis minio
@echo "Waiting for services to be ready..."
@sleep 5
@echo "Services are ready"
docker-down:
@echo "Stopping Docker services..."
docker-compose down
docker-build:
@echo "Building Docker images..."
docker-compose build
docker-logs:
docker-compose logs -f
# Database migrations
migrate-up:
@echo "Running migrations..."
migrate -path $(BACKEND_DIR)/migrations -database "postgres://openpairing:openpairing_dev@localhost:5432/openpairing?sslmode=disable" up
migrate-down:
@echo "Rolling back migrations..."
migrate -path $(BACKEND_DIR)/migrations -database "postgres://openpairing:openpairing_dev@localhost:5432/openpairing?sslmode=disable" down 1
migrate-create:
@read -p "Enter migration name: " name; \
migrate create -ext sql -dir $(BACKEND_DIR)/migrations -seq $$name
# Database seeding
seed:
@echo "Seeding database with demo data..."
cd $(BACKEND_DIR) && go run ./cmd/seed --db-url="postgres://openpairing:openpairing_dev@localhost:5432/openpairing?sslmode=disable"
seed-force:
@echo "Force seeding database (clearing existing data)..."
cd $(BACKEND_DIR) && go run ./cmd/seed --force --db-url="postgres://openpairing:openpairing_dev@localhost:5432/openpairing?sslmode=disable"
# Install development tools
install-tools:
@echo "Installing development tools..."
go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
go install -tags 'postgres' github.com/golang-migrate/migrate/v4/cmd/migrate@latest
cd $(FRONTEND_DIR) && npm install
# Format code
fmt:
@echo "Formatting code..."
cd $(BACKEND_DIR) && go fmt ./...
cd $(FRONTEND_DIR) && npm run format
# Generate API docs
docs:
@echo "Generating API documentation..."
cd $(BACKEND_DIR) && swag init -g cmd/api/main.go -o api/docs
# Run security scan
security:
@echo "Running security scan..."
cd $(BACKEND_DIR) && gosec ./...
cd $(FRONTEND_DIR) && npm audit