-
-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathMakefile
60 lines (44 loc) · 2.07 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
PHP_VERSION=8.3
PROJECT_NAME=$(shell basename $(CURDIR))
UID=$(shell id -u)
GID=$(shell id -g)
IMAGE="${PROJECT_NAME}:${PHP_VERSION}"
.PHONY: help
help:
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'
setup: build-php install ## Initialize project
build-php: ## Build PHP image
@echo "Build php ${PHP_VERSION}"
@DOCKER_BUILDKIT=1 docker build -t "${IMAGE}" --build-arg "VERSION=${PHP_VERSION}" --build-arg "UID=${UID}" --build-arg "GID=${GID}" .
install: ## Install PHP dependencies for given PHP version
rm -f composer.lock
@$(call run-php,composer install --no-progress --prefer-dist --optimize-autoloader)
rm -f tools/composer.lock
@$(call run-php,composer --working-dir=tools install --no-progress --prefer-dist --optimize-autoloader)
shell: ## Execute shell in given PHP version container
@$(call run-php,bash)
test: ## Execute tests for given PHP version
@$(call run-php,composer test $(filter-out $@,$(MAKECMDGOALS)))
test-update: ## Execute tests and update snapshots for given PHP version
@$(call run-php,composer test:update-snapshot $(filter-out $@,$(MAKECMDGOALS)))
lint: ## Execute lint for given PHP version
@$(call run-php,composer php-cs-fixer $(filter-out $@,$(MAKECMDGOALS)))
lint-fix: ## Execute lint fixing for given PHP version
@$(call run-php,composer php-cs-fixer:fix $(filter-out $@,$(MAKECMDGOALS)))
rector: ## Execute rector for given PHP version
@$(call run-php,composer rector $(filter-out $@,$(MAKECMDGOALS)))
rector-fix: ## Execute rector fixing for given PHP version
@$(call run-php,composer rector:fix $(filter-out $@,$(MAKECMDGOALS)))
phpstan: ## Execute PHPStan for given PHP version
@$(call run-php,composer phpstan $(filter-out $@,$(MAKECMDGOALS)))
ci: ## Execute CI scripts for given PHP version
@$(call run-php,composer ci $(filter-out $@,$(MAKECMDGOALS)))
## Run PHP for given version
define run-php
@docker run -it --rm -v ${PWD}:${PWD} -w ${PWD} "${IMAGE}" $(1)
endef
#############################
# Argument fix workaround
#############################
%:
@: