-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathMakefile
More file actions
70 lines (54 loc) · 2.04 KB
/
Copy pathMakefile
File metadata and controls
70 lines (54 loc) · 2.04 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
# Makefile for Ceres
# Load .env file if it exists
-include .env
export
.PHONY: help build test fmt clippy clean docker-build docker-up docker-down migrate
help: ## Show this help message
@echo 'Usage: make [target]'
@echo ''
@echo 'Available targets:'
@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {printf " %-15s %s\n", $$1, $$2}' $(MAKEFILE_LIST)
build: ## Build the project
cargo build
release: ## Build the project in release mode
cargo build --release
test: ## Run tests
cargo test
fmt: ## Format code
cargo fmt
fmt-check: ## Check code formatting
cargo fmt --check
clippy: ## Run clippy lints
cargo clippy --all-targets --all-features -- -D warnings
clean: ## Clean build artifacts
cargo clean
docker-build: ## Build the Docker image
docker build -t ceres-server .
docker-up: ## Start services with docker compose
docker compose up -d
docker-down: ## Stop services
docker compose down
migrate: ## Run database migrations
@echo "Initializing migration tracking..."
@psql $$DATABASE_URL -v ON_ERROR_STOP=1 -c "CREATE TABLE IF NOT EXISTS schema_migrations (filename text PRIMARY KEY, applied_at timestamptz NOT NULL DEFAULT now());" > /dev/null
@echo "Checking for pending migrations..."
@for f in migrations/*.sql; do \
[ -f "$$f" ] || continue; \
filename=$$(basename "$$f"); \
escaped_filename=$$(printf '%s' "$$filename" | sed "s/'/''/g"); \
applied=$$(psql $$DATABASE_URL -t -A -c "SELECT 1 FROM schema_migrations WHERE filename = '$$escaped_filename'" 2>/dev/null || echo "0"); \
if [ "$$applied" = "1" ]; then \
echo " ✓ $$filename (already applied)"; \
else \
echo " → Running $$filename..."; \
if psql $$DATABASE_URL -v ON_ERROR_STOP=1 -f "$$f"; then \
psql $$DATABASE_URL -v ON_ERROR_STOP=1 -c "INSERT INTO schema_migrations (filename) VALUES ('$$escaped_filename');" > /dev/null; \
echo " ✓ $$filename (applied successfully)"; \
else \
echo " ✗ $$filename (failed)"; \
exit 1; \
fi; \
fi; \
done
@echo "Migration complete!"
all: fmt clippy test ## Run fmt, clippy, and tests