Repository navigation
Expand file tree
/
Copy pathMakefile
More file actions
130 lines (98 loc) · 3.21 KB
/
Copy pathMakefile
File metadata and controls
130 lines (98 loc) · 3.21 KB
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
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
SHELL := /bin/sh
DOCKER ?= docker
DOCKER_COMPOSE ?= $(DOCKER) compose
export DOCKER_USER ?= $(shell id -u):$(shell id -g)
RUN ?= $(if $(IN_CONTAINER),,$(DOCKER_COMPOSE) run --rm php)
COMPOSER ?= $(RUN) composer
# Container
t: terminal
terminal: var ## (t) Open a shell in the PHP container
$(RUN) /bin/sh
.PHONY: t terminal
run: ## Run a command in the PHP container: CMD='php --version'
$(RUN) $(CMD)
.PHONY: run
up: ## Start services
$(DOCKER_COMPOSE) up --remove-orphans --build --detach
.PHONY: up
down: ## Stop services
$(DOCKER_COMPOSE) down --remove-orphans
.PHONY: down
# Dependencies
i: install
install: ## (i) Install dependencies
$(COMPOSER) install
@rm -f vendor/.lowest
@touch vendor
.PHONY: i install
u: update
update: ## (u) Update dependencies
$(COMPOSER) update
@rm -f vendor/.lowest
@touch vendor
.PHONY: u update
install-lowest: ## Install lowest possible dependencies
$(COMPOSER) update --prefer-lowest --prefer-stable
@touch vendor/.lowest
@touch vendor
.PHONY: install-lowest
# Quality tools
fixer: var ## Fix code style
$(RUN) php-cs-fixer fix --diff --verbose $(ARGS)
.PHONY: fixer
fixer-check: var ## Check code style
$(RUN) php-cs-fixer fix --diff --verbose --dry-run $(ARGS)
.PHONY: fixer-check
rector: var vendor ## Apply Rector rules
$(RUN) rector process $(ARGS)
.PHONY: rector
rector-check: var vendor ## Check Rector rules
$(RUN) rector process --dry-run $(ARGS)
.PHONY: rector-check
phpstan: var vendor ## Run static analysis
$(RUN) phpstan analyze --memory-limit=1G $(ARGS)
.PHONY: phpstan
test: var vendor up ## Run the test suite
$(RUN) vendor/bin/testo $(ARGS)
.PHONY: test
infect: var vendor up ## Run mutation testing
$(RUN) infection --show-mutations $(ARGS)
.PHONY: infect
deps-analyze: vendor ## Check for unused/missing dependencies
$(RUN) composer-dependency-analyser $(ARGS)
.PHONY: deps-analyze
composer-validate: ## Validate composer.json
$(COMPOSER) validate
.PHONY: composer-validate
composer-normalize: ## Normalize composer.json
$(COMPOSER) normalize --no-check-lock --no-update-lock --diff
.PHONY: composer-normalize
composer-normalize-check: ## Check composer.json is normalized
$(COMPOSER) normalize --diff --dry-run
.PHONY: composer-normalize-check
# CI
fix: fixer rector composer-normalize ## Fix code style and normalize composer.json
.PHONY: fix
check: fixer-check rector-check composer-validate composer-normalize-check deps-analyze phpstan test ## Run all checks
.PHONY: check
rescaffold:
$(DOCKER) run \
--rm --init \
--interactive --tty \
--user $(DOCKER_USER) \
--volume .:/project \
--pull always \
ghcr.io/phpyh/scaffolder:latest \
--user-name-default '$(shell git config user.name 2>/dev/null || whoami 2>/dev/null)' \
--user-email-default '$(shell git config user.email 2>/dev/null)'
git add --all 2>/dev/null || true
.PHONY: rescaffold
# ---
var:
mkdir -p var
vendor: composer.json $(wildcard composer.lock)
@if [ -f vendor/.lowest ]; then $(MAKE) install-lowest; else $(MAKE) install; fi
help:
@awk 'BEGIN {FS=":.*?## "} /^# [A-Za-z]/ {printf "%s\033[1;33m[%s]\033[0m\n", (s ? "\n" : ""), substr($$0, 3); s=1} /^[a-zA-Z0-9_-]+:.*## / {printf "\033[32m%-28s\033[0m %s\n", $$1, $$2}' $(MAKEFILE_LIST)
.PHONY: help
.DEFAULT_GOAL := help