Skip to content

Commit 01b22cd

Browse files
authored
Use only one goal in Makefile (#402)
1 parent dcdf779 commit 01b22cd

File tree

2 files changed

+39
-0
lines changed

2 files changed

+39
-0
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
## 1.0.1 under development
44

5+
- Bug #402: Always use only one goal in Makefile (@vjik)
56
- Bug #403: Add DI container delegates configuration (@vjik)
67
- Enh #399: Improve message for missing or invalid APP_ENV (@samdark)
78

Makefile

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
CLI_ARGS := $(wordlist 2,$(words $(MAKECMDGOALS)),$(MAKECMDGOALS))
44
$(eval $(CLI_ARGS):;@:)
55

6+
PRIMARY_GOAL := $(firstword $(MAKECMDGOALS))
7+
68
include docker/.env
79

810
# 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
2224
# Development
2325
#
2426

27+
ifeq ($(PRIMARY_GOAL),build)
2528
build: ## Build docker images
2629
$(DOCKER_COMPOSE_DEV) build $(CLI_ARGS)
30+
endif
2731

32+
ifeq ($(PRIMARY_GOAL),up)
2833
up: ## Up the dev environment
2934
$(DOCKER_COMPOSE_DEV) up -d --remove-orphans
35+
endif
3036

37+
ifeq ($(PRIMARY_GOAL),down)
3138
down: ## Down the dev environment
3239
$(DOCKER_COMPOSE_DEV) down --remove-orphans
40+
endif
3341

42+
ifeq ($(PRIMARY_GOAL),clear)
3443
clear: ## Remove development docker containers and volumes
3544
$(DOCKER_COMPOSE_DEV) down --volumes --remove-orphans
45+
endif
3646

47+
ifeq ($(PRIMARY_GOAL),shell)
3748
shell: ## Get into container shell
3849
$(DOCKER_COMPOSE_DEV) exec app /bin/bash
50+
endif
3951

52+
ifeq ($(PRIMARY_GOAL),yii)
4053
yii: ## Execute Yii command
4154
$(DOCKER_COMPOSE_DEV) run --rm app ./yii $(CLI_ARGS)
4255
.PHONY: yii
56+
endif
4357

58+
ifeq ($(PRIMARY_GOAL),composer)
4459
composer: ## Run Composer
4560
$(DOCKER_COMPOSE_DEV) run --rm app composer $(CLI_ARGS)
61+
endif
4662

63+
ifeq ($(PRIMARY_GOAL),rector)
4764
rector: ## Run Rector
4865
$(DOCKER_COMPOSE_DEV) run --rm app ./vendor/bin/rector $(CLI_ARGS)
66+
endif
4967

68+
ifeq ($(PRIMARY_GOAL),cs-fix)
5069
cs-fix: ## Run PHP CS Fixer
5170
$(DOCKER_COMPOSE_DEV) run --rm app ./vendor/bin/php-cs-fixer fix --config=.php-cs-fixer.php --diff
71+
endif
5272

5373
#
5474
# Tests and analysis
5575
#
5676

77+
ifeq ($(PRIMARY_GOAL),test)
5778
test:
5879
$(DOCKER_COMPOSE_TEST) run --rm app ./vendor/bin/codecept run $(CLI_ARGS)
80+
endif
5981

82+
ifeq ($(PRIMARY_GOAL),test-coverage)
6083
test-coverage:
6184
$(DOCKER_COMPOSE_TEST) run --rm app ./vendor/bin/codecept run --coverage --coverage-html --disable-coverage-php
85+
endif
6286

87+
ifeq ($(PRIMARY_GOAL),codecept)
6388
codecept: ## Run Codeception
6489
$(DOCKER_COMPOSE_TEST) run --rm app ./vendor/bin/codecept $(CLI_ARGS)
90+
endif
6591

92+
ifeq ($(PRIMARY_GOAL),psalm)
6693
psalm: ## Run Psalm
6794
$(DOCKER_COMPOSE_DEV) run --rm app ./vendor/bin/psalm $(CLI_ARGS)
95+
endif
6896

97+
ifeq ($(PRIMARY_GOAL),composer-dependency-analyser)
6998
composer-dependency-analyser: ## Run Composer Dependency Analyser
7099
$(DOCKER_COMPOSE_DEV) run --rm app ./vendor/bin/composer-dependency-analyser --config=composer-dependency-analyser.php $(CLI_ARGS)
100+
endif
71101

72102
#
73103
# Production
74104
#
75105

106+
ifeq ($(PRIMARY_GOAL),prod-build)
76107
prod-build: ## PROD | Build an image
77108
docker build --file docker/Dockerfile --target prod --pull -t ${IMAGE}:${IMAGE_TAG} .
109+
endif
78110

111+
ifeq ($(PRIMARY_GOAL),prod-push)
79112
prod-push: ## PROD | Push image to repository
80113
docker push ${IMAGE}:${IMAGE_TAG}
114+
endif
81115

116+
ifeq ($(PRIMARY_GOAL),prod-deploy)
82117
prod-deploy: ## PROD | Deploy to production
83118
docker -H ${PROD_SSH} stack deploy --with-registry-auth -d -c docker/compose.yml -c docker/prod/compose.yml ${STACK_NAME}
119+
endif
84120

85121
#
86122
# Other
87123
#
88124

125+
ifeq ($(PRIMARY_GOAL),help)
89126
# Output the help for each task, see https://marmelab.com/blog/2016/02/29/auto-documented-makefile.html
90127
help: ## This help.
91128
@awk 'BEGIN {FS = ":.*?## "} /^[a-zA-Z_-]+:.*?## / {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST)
129+
endif

0 commit comments

Comments
 (0)