-
Notifications
You must be signed in to change notification settings - Fork 47
/
Makefile
78 lines (63 loc) · 2.09 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
.DEFAULT_GOAL := help
UNAME := $(shell uname)
DOCKER_COMPOSE := docker compose
PHP_CLI := $(DOCKER_COMPOSE) run --rm app
include .env
.PHONY: help
help:
@grep -E '(^[a-zA-Z0-9_-]+:.*?##)|(^##)' $(firstword $(MAKEFILE_LIST)) | awk 'BEGIN {FS = ":.*?## "; printf "Usage: make \033[32m<target>\033[0m\n"}{printf "\033[32m%-20s\033[0m %s\n", $$1, $$2}' | sed -e 's/\[32m## /\n[33m/'
## Docker
.PHONY: up
up: ## Build and start containers.
$(DOCKER_COMPOSE) up -d --remove-orphans $(service)
.PHONY: down
down: ## Stop and remove containers.
$(DOCKER_COMPOSE) down --remove-orphans
.PHONY: ps
ps: ## List active containers.
$(DOCKER_COMPOSE) ps
.PHONY: build
build: ## Build images.
$(DOCKER_COMPOSE) build
## GdprDump
.PHONY: dump
dump: vendor ## Run bin/gdpr-dump command. Example: "make dump c=test.yaml"
@$(eval c ?=)
$(PHP_CLI) bin/gdpr-dump $(c)
.PHONY: compile
compile: ## Run bin/compile command.
$(PHP_CLI) composer install --no-dev
$(PHP_CLI) bin/compile $(c)
$(PHP_CLI) composer install
## Composer
.PHONY: composer
composer: ## Run composer. Example: "make composer c=update"
$(PHP_CLI) composer $(c)
## Code Quality
.PHONY: analyse
analyse: vendor ## Run code analysis tools (parallel-lint, phpcs, phpstan).
$(PHP_CLI) composer audit
$(PHP_CLI) vendor/bin/parallel-lint app bin src tests
$(PHP_CLI) vendor/bin/phpcs
$(PHP_CLI) vendor/bin/phpstan analyse
.PHONY: test
test: vendor ## Run phpunit.
$(PHP_CLI) vendor/bin/phpunit
## Database
.PHONY: db
db: service := --wait db
db: up ## Connect to the database.
$(DOCKER_COMPOSE) exec db sh -c 'mysql --password=$$MYSQL_ROOT_PASSWORD'
.PHONY: db-import
db-import: service := --wait db
db-import: up ## Execute a SQL file. Pass the parameter "filename=" to set the filename (default: dump.sql).
$(eval filename ?= dump.sql)
$(DOCKER_COMPOSE) exec -T db sh -c 'mysql --password=$$MYSQL_ROOT_PASSWORD' < $(filename)
vendor: | composer.json
$(PHP_CLI) composer install
.env: | .env.dist
@cp .env.dist .env
ifeq ($(UNAME), Linux)
@sed -i -e "s/^UID=.*/UID=$$(id -u)/" -e "s/^GID=.*/GID=$$(id -g)/" .env
endif
@echo ".env file was automatically created."