forked from kaamelott-gifboard/kaamelott-gifboard
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
100 lines (77 loc) · 2.31 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
COMPOSE=docker-compose
DOCKER_FLAGS ?= --rm
COMPOSER_HOME ?= ${HOME}/.config/composer
COMPOSER_CACHE_DIR ?= ${HOME}/.cache/composer
COMPOSE_EXEC_FLAGS =
DOCKER_RUN_COMPOSER = docker run ${DOCKER_FLAGS} \
--env COMPOSER_HOME \
--env COMPOSER_CACHE_DIR \
--volume ${COMPOSER_HOME}:${COMPOSER_HOME} \
--volume ${COMPOSER_CACHE_DIR}:${COMPOSER_CACHE_DIR} \
--volume ${PWD}:/app \
--user $(shell id -u):$(shell id -g) \
-w /app \
composer
INTERACTIVE := $(shell [ -t 0 ] && echo 1 || echo 0)
ifeq ($(INTERACTIVE), 0)
COMPOSE_EXEC_FLAGS += -T
endif
EXEC_APP = ${COMPOSE} exec ${COMPOSE_EXEC_FLAGS} app
## ------
##@ Docker
## ------
build: ## Build containers
${COMPOSE} build
.PHONY: build
start: vendor .env ## Start containers
${COMPOSE} up -d
.PHONY: start
stop: ## Stop containers
${COMPOSE} stop
.PHONY: stop
down: ## Remove containers
${COMPOSE} down
.PHONY: down
## ------
##@ Composer
## ------
.PHONY: composer
composer: .env ## Run composer commands. Example : `make composer c="require --dev some/package"`
${DOCKER_RUN_COMPOSER} $c
.env: ## Copy the docker/.env file to local
@if [ ! -f .env ]; then\
cp .env.dist .env;\
fi
vendor: composer.lock
${DOCKER_RUN_COMPOSER} install && touch vendor
composer.lock: composer.json
${DOCKER_RUN_COMPOSER} update --lock --no-scripts --no-interaction
install: vendor ## Install the project
.PHONY: install
## --
##@ QA
## --
cs-fixer: start ## Launch cs-fixer tool
${EXEC_APP} vendor/bin/php-cs-fixer fix
.PHONY: cs-fixer
cs-fixer-dry: start ## Launch cs-fixer tool (dry run)
${EXEC_APP} vendor/bin/php-cs-fixer fix --dry-run -v --ansi
.PHONY: cs-fixer-dry
test: start ## Launch the PhpUnit suite
${EXEC_APP} bin/phpunit
.PHONY: test
phpstan: start ## Launch the Phpstan tool
${EXEC_APP} vendor/bin/phpstan analyse -c phpstan.neon --memory-limit=-1
.PHONY: phpstan
psalm: start ## Launch the Psalm tool
${EXEC_APP} vendor/bin/psalm
.PHONY: psalm
## ----
##@ Misc
## ----
.DEFAULT_GOAL := help
.PHONY: help
# See https://www.thapaliya.com/en/writings/well-documented-makefiles/
help: ## Display this help
@awk 'BEGIN {FS = ":.* ##"; printf "\n\033[32;1m Kaamelott Gifboard\n ------------------\033[0m\n"} /^[%a-zA-Z_-]+:.* ## / { printf " \033[33m%-25s\033[0m %s\n", $$1, $$2 } /^##@/ { printf "\n\033[1m%s\033[0m\n", substr($$0, 5) } ' ${MAKEFILE_LIST}
##@