Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
159 lines (121 loc) · 5.96 KB
/
Copy pathMakefile
File metadata and controls
159 lines (121 loc) · 5.96 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
152
153
154
155
156
157
158
159
.PHONY: help start backend-start start-public stop setup setup-contrib import-profs import-course import-vacuum course-renames prof-aliases migrate test build-test docker-build-test logs clean
# Frontend-only commands must not load backend credentials. `start` delegates to
# `backend-start`, which loads them, so the frontend dev server never sees them.
.DEFAULT_GOAL := help
ifneq ($(strip $(filter-out help start frontend-% hooks migration-test,$(MAKECMDGOALS))),)
include .env
export
endif
# Docker compose command with proper file configuration
DOCKER_COMPOSE := docker-compose -f docker-compose.yml -f docker-compose.dev.yml
DOCKER_COMPOSE_PUBLIC := docker-compose -f docker-compose.yml
help: ## Show this help message
@echo 'Usage: make [target]'
@echo ''
@echo 'Available targets:'
@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {printf " %-20s %s\n", $$1, $$2}' $(MAKEFILE_LIST)
start: ## Start the backend services, then the frontend dev server (Ctrl-C stops the frontend only)
@$(MAKE) --no-print-directory backend-start
@$(MAKE) --no-print-directory frontend-start
backend-start: ## Start all backend services in development mode (without frontend)
@echo "Starting backend services in development mode..."
@$(DOCKER_COMPOSE) up -d api postgres hasura uw email
start-public: ## Start all services using public images
@echo "Pulling latest images..."
@$(DOCKER_COMPOSE_PUBLIC) pull
@echo "Starting services with public images..."
@$(DOCKER_COMPOSE_PUBLIC) up -d
stop: ## Stop all running services
@echo "Stopping all services..."
@docker-compose down
setup: ## Initialize database with backup data (maintainers)
@echo "Starting setup..."
@bash script/start.sh
@echo "Setup complete! Run 'make start' to start the backend and frontend."
setup-contrib: ## Initialize database from scratch using migrations and UW API (contributors)
@echo "Starting contributor setup..."
@bash script/setup-contrib.sh
import-profs: ## Add dummy professors to the local database
@echo "Adding dummy professor data..."
@bash script/import-prof.sh
import-course: ## Run UW course importer job (rebuilds importer service)
@echo "Rebuilding and running course import job..."
@$(DOCKER_COMPOSE) up -d --build uw
@docker exec uw /app/uw hourly
@echo "Course import complete!"
import-vacuum: ## Run UW importer vacuum job (rebuilds importer service)
@echo "Rebuilding and running vacuum job..."
@$(DOCKER_COMPOSE) up -d --build uw
@docker exec uw /app/uw vacuum
@echo "Vacuum complete!"
course-renames: ## Apply maintainer-declared course renames in hasura/course_renames.sql
@echo "Applying course renames..."
@docker exec -i postgres psql -v ON_ERROR_STOP=1 -U $(POSTGRES_USER) -d $(POSTGRES_DB) -p $(POSTGRES_PORT) < hasura/course_renames.sql
@echo "Course renames applied!"
prof-aliases: ## Apply maintainer-declared prof aliases and merges in hasura/prof_aliases.sql
@echo "Applying prof aliases..."
@docker exec -i postgres psql -v ON_ERROR_STOP=1 -U $(POSTGRES_USER) -d $(POSTGRES_DB) -p $(POSTGRES_PORT) < hasura/prof_aliases.sql
@echo "Prof aliases applied!"
migrate: ## Apply Hasura migrations
@echo "Applying Hasura migrations..."
@if ! command -v hasura >/dev/null 2>&1; then \
echo "Error: hasura CLI not found. Please install it first."; \
echo "Visit: https://hasura.io/docs/latest/hasura-cli/install-hasura-cli/"; \
exit 1; \
fi
@cd hasura && hasura migrate apply --database-name default --admin-secret $(HASURA_GRAPHQL_ADMIN_SECRET)
@cd hasura && hasura metadata apply --admin-secret $(HASURA_GRAPHQL_ADMIN_SECRET)
migrate-status: ## Check Hasura migration status
@echo "Checking migration status..."
@cd hasura && hasura migrate status --admin-secret $(HASURA_GRAPHQL_ADMIN_SECRET)
test: ## Run Go tests
@echo "Running Go tests in container..."
@docker exec api go test ./...
@echo "Tests complete!"
build-test: ## Test Go build compilation
@echo "Testing Go build in container..."
@docker exec api go build ./...
@echo "Build test complete!"
docker-build-test: ## Dry run Docker Compose build
@echo "Testing Docker build (dry run)..."
$(DOCKER_COMPOSE) build --dry-run
@echo "Docker build test complete!"
logs: ## Tail logs from all services
@docker-compose logs -f
logs-api: ## Tail logs from API service
@docker logs -f api
logs-hasura: ## Tail logs from Hasura service
@docker logs -f hasura
logs-uw: ## Tail logs from UW importer service
@docker logs -f uw
logs-email: ## Tail logs from email service
@docker logs -f email
clean: ## Remove all containers, volumes, and reset environment
@echo "Cleaning up..."
@docker-compose down --remove-orphans --volumes
@echo "Clean complete!"
ps: ## Show status of all services
@docker-compose ps
.PHONY: frontend-install frontend-start frontend-lint frontend-typecheck frontend-test frontend-check frontend-build frontend-generate hooks migration-test
frontend-install: ## Install frontend dependencies with the committed lockfile
cd frontend && bun install --frozen-lockfile
frontend-start: ## Start the frontend development server on port 3000
cd frontend && bun run start
frontend-lint: ## Check frontend lint without changing files
cd frontend && bun run lint-nofix
frontend-typecheck: ## Check frontend TypeScript
cd frontend && bun run typecheck
frontend-test: ## Run frontend unit tests
cd frontend && bun run test -- --runInBand
frontend-check: frontend-lint frontend-typecheck frontend-test ## Run frontend validation
frontend-build: ## Build frontend assets without uploading Sentry source maps
cd frontend && bun run build:vercel
frontend-generate: ## Generate GraphQL types from the matching local Hasura schema
cd frontend && bun run generate
hooks: ## Install the monorepo Git hooks for this clone
git config --local core.hooksPath .githooks
migration-test: ## Test build/deploy commands without touching Docker or production
python3 script/test-monorepo.py
.PHONY: frontend-container-test
frontend-container-test: ## Check the built frontend image with Nginx and disposable upstreams
python3 script/test-frontend-container.py