-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
83 lines (70 loc) · 2.16 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
# This file is part of Minz.
# Copyright 2020-2024 Marien Fressinaud
# SPDX-License-Identifier: AGPL-3.0-or-later
.DEFAULT_GOAL := help
USER = $(shell id -u):$(shell id -g)
DOCKER_COMPOSE = docker compose -f docker/development/docker-compose.yml
ifdef NODOCKER
PHP = php
COMPOSER = composer
else
PHP = ./docker/bin/php
COMPOSER = ./docker/bin/composer
endif
ifdef PGSQL
DB_DSN='pgsql:host=database;port=5432;dbname=minz_test'
DB_USERNAME='postgres'
DB_PASSWORD='postgres'
else
DB_DSN='sqlite::memory:'
DB_USERNAME=none
DB_PASSWORD=none
endif
.PHONY: docker-build
docker-build: ## Rebuild the Docker images
$(DOCKER_COMPOSE) build --pull
.PHONY: docker-pull
docker-pull: ## Pull the Docker images from the Docker Hub
$(DOCKER_COMPOSE) pull --ignore-buildable
.PHONY: docker-clean
docker-clean: ## Clean the Docker stuff
$(DOCKER_COMPOSE) down -v
.PHONY: install
install: ## Install the dependencies
$(COMPOSER) install
.PHONY: test
test: FILE ?= ./tests
ifdef FILTER
test: override FILTER := --filter=$(FILTER)
endif
test: COVERAGE ?= --coverage-html ./coverage
test: ## Run the tests suite (can take FILE, FILTER and COVERAGE arguments)
DB_DSN=$(DB_DSN) DB_USERNAME=$(DB_USERNAME) DB_PASSWORD=$(DB_PASSWORD) \
$(PHP) ./vendor/bin/phpunit \
-c .phpunit.xml \
$(COVERAGE) \
$(FILTER) \
$(FILE)
.PHONY: lint
lint: LINTER ?= all
lint: ## Run the linters on the PHP files (can take a LINTER argument)
ifeq ($(LINTER), $(filter $(LINTER), all phpstan))
$(PHP) ./vendor/bin/phpstan analyse --memory-limit 1G -c .phpstan.neon
endif
ifeq ($(LINTER),$(filter $(LINTER), all rector))
$(PHP) vendor/bin/rector process --dry-run --config .rector.php
endif
ifeq ($(LINTER), $(filter $(LINTER), all phpcs))
$(PHP) ./vendor/bin/phpcs
endif
.PHONY: lint-fix
lint-fix: ## Fix the errors raised by the linter (can take a LINTER argument)
ifeq ($(LINTER), $(filter $(LINTER), all rector))
$(PHP) vendor/bin/rector process --config .rector.php
endif
ifeq ($(LINTER), $(filter $(LINTER), all phpcs))
$(PHP) ./vendor/bin/phpcbf
endif
.PHONY: help
help:
@grep -h -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "\033[36m%-30s\033[0m %s\n", $$1, $$2}'