-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
150 lines (110 loc) · 5.55 KB
/
Makefile
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
.DEFAULT_GOAL = help
.PHONY : help
# Executables
COMPOSER = composer
DOCKER = docker
DOCKER_COMP = docker compose
PHP = php
SYMFONY = symfony
YARN = yarn
# Alias
CONSOLE = $(SYMFONY) console
# Vendor executables
PHPMD = ./vendor/bin/phpmd
PHPUNIT = ./vendor/bin/phpunit
PHPSTAN = ./vendor/bin/phpstan
PHP_CS_FIXER = ./vendor/bin/php-cs-fixer
PSALM = ./vendor/bin/psalm
RECTOR = ./vendor/bin/rector
TWIG_CS_FIXER = ./vendor/bin/twig-cs-fixer
# Docker containers
PHP_CONT = $(DOCKER_COMP) exec php
## —— 🎵 🐳 The Symfony Docker makefile 🐳 🎵 ——————————————————————————————————
help: ## Outputs this help screen
@grep -E '(^[a-zA-Z0-9\./_-]+:.*?##.*$$)|(^##)' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}{printf "\033[32m%-30s\033[0m %s\n", $$1, $$2}' | sed -e 's/\[32m##/[33m/'
## —— Project setup 🚀 ——————————————————————————————————————————————————————————
setup: ## Setup the whole project
@$(COMPOSER) install --no-interaction
@$(COMPOSER) setup-env
setup-dev: ## Setup the dev environment for the project
@$(COMPOSER) install --no-interaction
@$(COMPOSER) setup-env
@$(COMPOSER) setup-test-env
@$(COMPOSER) load-fixtures
@$(YARN) install
warmup-dev: ## Warmup the dev environment (e.g. after purge)
@$(COMPOSER) setup-env
@$(COMPOSER) load-fixtures
@$(CONSOLE) asset-map:compile
@$(CONSOLE) cache:warmup
## —— Project pipelines 🚇 ——————————————————————————————————————————————————————
checks: lint cs static-analysis ## Run check-styles and static-analysis
ci: checks test ## Run CI pipeline
reset: purge warmup-dev ## Reset pipeline for the whole project (caution!)
## —— Docker 🐳 ————————————————————————————————————————————————————————————————
start: build up ## Build and start the containers
build: ## Builds the Docker images
@$(DOCKER_COMP) build --pull --no-cache
up: ## Start the docker hub in detached mode (no logs)
@$(DOCKER_COMP) up --detach
down: ## Stop the docker hub
@$(DOCKER_COMP) down --remove-orphans
logs: ## Show live logs
@$(DOCKER_COMP) logs --tail=0 --follow
sh: ## Connect to the PHP FPM container
@$(PHP_CONT) sh
## —— Composer 🧙 ——————————————————————————————————————————————————————————————
vendor: composer.lock ## Install vendors according to the current composer.lock file
@$(COMPOSER) install --prefer-dist --no-dev --no-progress --no-interaction
## —— Symfony 🎵 ———————————————————————————————————————————————————————————————
compile: ## Execute some tasks before deployment
rm -rf public/assets/*
@$(CONSOLE) asset-map:compile
@$(CONSOLE) cache:clear
@$(CONSOLE) cache:warmup
consume: ## Consume messages from symfony messenger
@$(CONSOLE) messenger:consume async -vvv
trans: ## Extract translations from symfony
@$(CONSOLE) translation:extract --dump-messages --force --sort=asc en
## —— Coding standards ✨ ——————————————————————————————————————————————————————
cs: rector fix-php fix-twig eslint phpmd ## Run all coding standards checks
static-analysis: phpstan psalm ## Run the static analysis
lint: lint-composer lint-php lint-twig ## Run the linting tools
eslint: ## Run ESLint
@$(YARN) run eslint assets
eslint-fix: ## Run ESLint with fixes
@$(YARN) run eslint assets --fix
fix-php: ## Fix files with php-cs-fixer
@$(PHP_CS_FIXER) fix --allow-risky=yes --config=php-cs-fixer.php
fix-twig: ## Fix files with php-cs-fixer
@$(TWIG_CS_FIXER) --fix
lint-composer: ## Lint files with composer
@$(COMPOSER) lint
lint-php: ## Lint files with php-cs-fixer
@$(PHP_CS_FIXER) fix --allow-risky=yes --dry-run --config=php-cs-fixer.php
lint-twig: ## Lint files with php-cs-fixer
@$(TWIG_CS_FIXER)
phpmd: ## Run PHP Mess detector
@$(PHPMD) src/ html phpmd.xml --report-file var/report/phpmd.html --ignore-violations-on-exit
phpstan: ## Run PHPStan
@$(PHPSTAN) analyse --memory-limit=-1
psalm: ## Run Psalm
@$(PSALM)
rector: ## Run Rector
@$(RECTOR)
## —— Tests ✅ —————————————————————————————————————————————————————————————————
test: ## Run tests
@$(PHPUNIT) --stop-on-failure -d memory_limit=-1
testdox: ## Run tests with testdox
@$(PHPUNIT) --testdox -d memory_limit=-1
coverage: ## Run tests with Coverage reports
@XDEBUG_MODE=coverage $(PHPUNIT) -d memory_limit=-1
## —— Cleanup 🚮 ————————————————————————————————————————————————————————————————
purge: ## Purge temporary files
@rm -rf public/assets/*
@rm -rf var/cache/* var/logs/*
clear: ## Cleanup everything (except docker)
@rm -rf vendor/*
@rm -rf node_modules/*
@rm -rf public/assets/*
@rm -rf var/cache/* var/logs/*