1+ .PHONY : up down build ensure-build ssh composer test test-coverage test-phpunit install update help
2+
3+ # Project variables
4+ DOCKER_COMPOSE = docker compose
5+ DOCKER_COMPOSE_FILE = docker-compose.yml
6+ DOCKER_SERVICE = fsrs
7+ COMPOSER = $(DOCKER_COMPOSE ) run --rm $(DOCKER_SERVICE ) composer
8+
9+ # # —— Docker Compose ————————————————————————————————————————————————————————————
10+ up : # # Start all containers in the background
11+ @$(DOCKER_COMPOSE ) -f $(DOCKER_COMPOSE_FILE ) up -d
12+
13+ up-verbose : # # Start all containers in the foreground
14+ @$(DOCKER_COMPOSE ) -f $(DOCKER_COMPOSE_FILE ) up
15+
16+ down : # # Stop and remove all containers
17+ @$(DOCKER_COMPOSE ) -f $(DOCKER_COMPOSE_FILE ) down
18+
19+ down-v : # # Stop and remove all containers and volumes
20+ @$(DOCKER_COMPOSE ) -f $(DOCKER_COMPOSE_FILE ) down -v
21+
22+ build : # # Rebuild the Docker containers
23+ @$(DOCKER_COMPOSE ) -f $(DOCKER_COMPOSE_FILE ) build --no-cache
24+
25+ ensure-build : # # Ensure the Docker image is built (uses cache)
26+ @$(DOCKER_COMPOSE ) -f $(DOCKER_COMPOSE_FILE ) build
27+
28+ ssh : up # # Get shell access to the container
29+ @$(DOCKER_COMPOSE ) -f $(DOCKER_COMPOSE_FILE ) exec $(DOCKER_SERVICE ) bash
30+
31+ # # —— Composer ——————————————————————————————————————————————————————————————————
32+ composer : # # Run composer commands
33+ @$(DOCKER_COMPOSE ) -f $(DOCKER_COMPOSE_FILE ) run --rm $(DOCKER_SERVICE ) composer $(filter-out $@ ,$(MAKECMDGOALS ) )
34+
35+ install : ensure-build # # Install dependencies
36+ @$(COMPOSER ) install --no-interaction --prefer-dist
37+
38+ update : # # Update dependencies
39+ @$(COMPOSER ) update
40+
41+ # # —— Testing ———————————————————————————————————————————————————————————————————
42+ test : # # Run all tests with coverage report
43+ $(DOCKER_COMPOSE ) run --rm $(DOCKER_SERVICE ) bash -c " cd /var/www && XDEBUG_MODE=coverage ./vendor/bin/phpunit --testdox --coverage-text"
44+
45+ test-coverage : # # Generate HTML test coverage report
46+ $(DOCKER_COMPOSE ) run --rm $(DOCKER_SERVICE ) bash -c " cd /var/www && XDEBUG_MODE=coverage ./vendor/bin/phpunit --coverage-html=coverage"
47+
48+ coverage : test-coverage # # Alias for test-coverage
49+
50+ open-coverage : test-coverage # # Open the coverage report in default browser
51+ @if command -v xdg-open > /dev/null; then \
52+ xdg-open coverage/index.html; \
53+ elif command -v open > /dev/null; then \
54+ open coverage/index.html; \
55+ else \
56+ echo " Please open coverage/index.html in your browser" ; \
57+ fi
58+
59+ test-phpunit : # # Run PHPUnit tests with optional arguments
60+ $(DOCKER_COMPOSE ) run --rm $(DOCKER_SERVICE ) bash -c " cd /var/www && ./vendor/bin/phpunit $( filter-out $@ ,$( MAKECMDGOALS) ) "
61+
62+ # # —— Help ——————————————————————————————————————————————————————————————————————
63+ help : # # Display this help screen
64+ @echo " \n\033[33mUsage:\033[0m\n make [command] [arguments...]\n"
65+ @echo " \033[33mAvailable commands:\033[0m"
66+ @awk ' BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {printf " \033[32m%-15s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST ) | sort
67+
68+ .DEFAULT_GOAL := help
69+
70+ % :
71+ @:
0 commit comments