1+ # PartDB Makefile for Test Environment Management
2+
3+ .PHONY : help test-setup test-clean test-db-create test-db-migrate test-cache-clear test-fixtures test-run dev-setup dev-clean dev-db-create dev-db-migrate dev-cache-clear dev-warmup dev-reset deps-install
4+
5+ # Default target
6+ help :
7+ @echo " PartDB Test Environment Management"
8+ @echo " =================================="
9+ @echo " "
10+ @echo " Available targets:"
11+ @echo " deps-install - Install PHP dependencies with unlimited memory"
12+ @echo " "
13+ @echo " Development Environment:"
14+ @echo " dev-setup - Complete development environment setup (clean, create DB, migrate, warmup)"
15+ @echo " dev-clean - Clean development cache and database files"
16+ @echo " dev-db-create - Create development database (if not exists)"
17+ @echo " dev-db-migrate - Run database migrations for development environment"
18+ @echo " dev-cache-clear - Clear development cache"
19+ @echo " dev-warmup - Warm up development cache"
20+ @echo " dev-reset - Quick development reset (clean + migrate)"
21+ @echo " "
22+ @echo " Test Environment:"
23+ @echo " test-setup - Complete test environment setup (clean, create DB, migrate, load fixtures)"
24+ @echo " test-clean - Clean test cache and database files"
25+ @echo " test-db-create - Create test database (if not exists)"
26+ @echo " test-db-migrate - Run database migrations for test environment"
27+ @echo " test-cache-clear- Clear test cache"
28+ @echo " test-fixtures - Load test fixtures"
29+ @echo " test-run - Run PHPUnit tests"
30+ @echo " "
31+ @echo " help - Show this help message"
32+
33+ # Install PHP dependencies with unlimited memory
34+ deps-install :
35+ @echo " 📦 Installing PHP dependencies..."
36+ COMPOSER_MEMORY_LIMIT=-1 composer install
37+ @echo " ✅ Dependencies installed"
38+
39+ # Complete test environment setup
40+ test-setup : deps-install test-clean test-db-create test-db-migrate test-fixtures
41+ @echo " ✅ Test environment setup complete!"
42+
43+ # Clean test environment
44+ test-clean :
45+ @echo " 🧹 Cleaning test environment..."
46+ rm -rf var/cache/test
47+ rm -f var/app_test.db
48+ @echo " ✅ Test environment cleaned"
49+
50+ # Create test database
51+ test-db-create :
52+ @echo " 🗄️ Creating test database..."
53+ -php bin/console doctrine:database:create --if-not-exists --env test || echo " ⚠️ Database creation failed (expected for SQLite) - continuing..."
54+
55+ # Run database migrations for test environment
56+ test-db-migrate :
57+ @echo " 🔄 Running database migrations..."
58+ php -d memory_limit=1G bin/console doctrine:migrations:migrate -n --env test
59+
60+ # Clear test cache
61+ test-cache-clear :
62+ @echo " 🗑️ Clearing test cache..."
63+ rm -rf var/cache/test
64+ @echo " ✅ Test cache cleared"
65+
66+ # Load test fixtures
67+ test-fixtures :
68+ @echo " 📦 Loading test fixtures..."
69+ php bin/console partdb:fixtures:load -n --env test
70+
71+ # Run PHPUnit tests
72+ test-run :
73+ @echo " 🧪 Running tests..."
74+ php bin/phpunit
75+
76+ test-typecheck :
77+ @echo " 🧪 Running type checks..."
78+ COMPOSER_MEMORY_LIMIT=-1 composer phpstan
79+
80+ # Quick test reset (clean + migrate + fixtures, skip DB creation)
81+ test-reset : test-cache-clear test-db-migrate test-fixtures
82+ @echo " ✅ Test environment reset complete!"
83+
84+ # Development helpers
85+ dev-setup : deps-install dev-clean dev-db-create dev-db-migrate dev-warmup
86+ @echo " ✅ Development environment setup complete!"
87+
88+ dev-clean :
89+ @echo " 🧹 Cleaning development environment..."
90+ rm -rf var/cache/dev
91+ rm -f var/app_dev.db
92+ @echo " ✅ Development environment cleaned"
93+
94+ dev-db-create :
95+ @echo " 🗄️ Creating development database..."
96+ -php bin/console doctrine:database:create --if-not-exists --env dev || echo " ⚠️ Database creation failed (expected for SQLite) - continuing..."
97+
98+ dev-db-migrate :
99+ @echo " 🔄 Running database migrations..."
100+ php -d memory_limit=1G bin/console doctrine:migrations:migrate -n --env dev
101+
102+ dev-cache-clear :
103+ @echo " 🗑️ Clearing development cache..."
104+ php -d memory_limit=1G bin/console cache:clear --env dev -n
105+ @echo " ✅ Development cache cleared"
106+
107+ dev-warmup :
108+ @echo " 🔥 Warming up development cache..."
109+ php -d memory_limit=1G bin/console cache:warmup --env dev -n
110+
111+ dev-reset : dev-cache-clear dev-db-migrate
112+ @echo " ✅ Development environment reset complete!"
0 commit comments