From 57123b45e4ac8cddf1111060747c4e0e81fba83d Mon Sep 17 00:00:00 2001 From: Sergei Predvoditelev Date: Sat, 30 Aug 2025 19:57:58 +0300 Subject: [PATCH 1/2] Use only one goal in Makefile --- Makefile | 38 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) diff --git a/Makefile b/Makefile index ad8d66a9..cec9f4e9 100644 --- a/Makefile +++ b/Makefile @@ -3,6 +3,8 @@ CLI_ARGS := $(wordlist 2,$(words $(MAKECMDGOALS)),$(MAKECMDGOALS)) $(eval $(CLI_ARGS):;@:) +PRIMARY_GOAL := $(firstword $(MAKECMDGOALS)) + include docker/.env # Current user ID and group ID except MacOS where it conflicts with Docker abilities @@ -22,70 +24,106 @@ DOCKER_COMPOSE_TEST := docker compose -f docker/compose.yml -f docker/test/compo # Development # +ifeq ($(PRIMARY_GOAL),build) build: ## Build docker images $(DOCKER_COMPOSE_DEV) build $(CLI_ARGS) +endif +ifeq ($(PRIMARY_GOAL),up) up: ## Up the dev environment $(DOCKER_COMPOSE_DEV) up -d --remove-orphans +endif +ifeq ($(PRIMARY_GOAL),down) down: ## Down the dev environment $(DOCKER_COMPOSE_DEV) down --remove-orphans +endif +ifeq ($(PRIMARY_GOAL),clear) clear: ## Remove development docker containers and volumes $(DOCKER_COMPOSE_DEV) down --volumes --remove-orphans +endif +ifeq ($(PRIMARY_GOAL),shell) shell: ## Get into container shell $(DOCKER_COMPOSE_DEV) exec app /bin/bash +endif +ifeq ($(PRIMARY_GOAL),yii) yii: ## Execute Yii command $(DOCKER_COMPOSE_DEV) run --rm app ./yii $(CLI_ARGS) .PHONY: yii +endif +ifeq ($(PRIMARY_GOAL),composer) composer: ## Run Composer $(DOCKER_COMPOSE_DEV) run --rm app composer $(CLI_ARGS) +endif +ifeq ($(PRIMARY_GOAL),rector) rector: ## Run Rector $(DOCKER_COMPOSE_DEV) run --rm app ./vendor/bin/rector $(CLI_ARGS) +endif +ifeq ($(PRIMARY_GOAL),cs-fix) cs-fix: ## Run PHP CS Fixer $(DOCKER_COMPOSE_DEV) run --rm app ./vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.php --diff +endif # # Tests and analysis # +ifeq ($(PRIMARY_GOAL),test) test: $(DOCKER_COMPOSE_TEST) run --rm app ./vendor/bin/codecept run $(CLI_ARGS) +endif +ifeq ($(PRIMARY_GOAL),test-coverage) test-coverage: $(DOCKER_COMPOSE_TEST) run --rm app ./vendor/bin/codecept run --coverage --coverage-html --disable-coverage-php +endif +ifeq ($(PRIMARY_GOAL),codecept) codecept: ## Run Codeception $(DOCKER_COMPOSE_TEST) run --rm app ./vendor/bin/codecept $(CLI_ARGS) +endif +ifeq ($(PRIMARY_GOAL),psalm) psalm: ## Run Psalm $(DOCKER_COMPOSE_DEV) run --rm app ./vendor/bin/psalm $(CLI_ARGS) +endif +ifeq ($(PRIMARY_GOAL),composer-dependency-analyser) composer-dependency-analyser: ## Run Composer Dependency Analyser $(DOCKER_COMPOSE_DEV) run --rm app ./vendor/bin/composer-dependency-analyser --config=composer-dependency-analyser.php $(CLI_ARGS) +endif # # Production # +ifeq ($(PRIMARY_GOAL),prod-build) prod-build: ## PROD | Build an image docker build --file docker/Dockerfile --target prod --pull -t ${IMAGE}:${IMAGE_TAG} . +endif +ifeq ($(PRIMARY_GOAL),prod-push) prod-push: ## PROD | Push image to repository docker push ${IMAGE}:${IMAGE_TAG} +endif +ifeq ($(PRIMARY_GOAL),prod-deploy) prod-deploy: ## PROD | Deploy to production docker -H ${PROD_SSH} stack deploy --with-registry-auth -d -c docker/compose.yml -c docker/prod/compose.yml ${STACK_NAME} +endif # # Other # +ifeq ($(PRIMARY_GOAL),help) # Output the help for each task, see https://marmelab.com/blog/2016/02/29/auto-documented-makefile.html help: ## This help. @awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST) +endif From 68663d7ef51aced6efefe32facf9e1232b313984 Mon Sep 17 00:00:00 2001 From: Sergei Predvoditelev Date: Sat, 30 Aug 2025 19:59:18 +0300 Subject: [PATCH 2/2] changelog --- CHANGELOG.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 7575a0ef..1f8cfb86 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,7 +2,7 @@ ## 1.0.1 under development -- no changes in this release. +- Bug #402: Always use only one goal in Makefile (@vjik) ## 1.0.0 August 25, 2025