-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
98 lines (77 loc) · 2.78 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
.DEFAULT_GOAL := help
MAKEFLAGS += --silent --warn-undefined-variables
SHELL = /bin/bash
PHP_RUN := docker compose run --rm php-cli
ARGS ?= $(shell read -p "Additional arguments ([enter] for none): " args; echo $$args)
export HOST_UID := $(shell id -u)
export HOST_GID := $(shell id -g)
##>—— Building —————————————
## build: Build the docker containers
.PHONY: build
build:
docker compose build --pull
## setup: Sets up the project for you
.PHONY: setup
setup: build
${PHP_RUN} composer install --ansi
##>—— Debugging ————————————
## bash: Go into the container for running things manually
.PHONY: bash
bash:
${PHP_RUN} bash
## php: PHP
.PHONY: php
php:
${PHP_RUN} $(ARGS)
## php-modules: PHP modules
.PHONY: php-modules
php-modules:
${PHP_RUN} php -m
## composer: Runs composer through docker
.PHONY: composer
composer:
${PHP_RUN} composer $(ARGS) --ansi
##>—— Checks ———————————————
## tests: Runs PHPUnit tests
.PHONY: test tests
test: tests
tests:
${PHP_RUN} php vendor/bin/phpunit tests --testdox
## analyze: Runs PHPStan -> everything
.PHONY: analyse analyze
analyse: analyze
analyze:
echo "> all"
${PHP_RUN} php -d memory_limit=-1 vendor/bin/phpstan analyse --configuration=phpstan-all.neon
echo "> not cs fixer"
${PHP_RUN} php -d memory_limit=-1 vendor/bin/phpstan analyse --configuration=phpstan-not-cs-fixer.neon
echo "> not tests"
${PHP_RUN} php -d memory_limit=-1 vendor/bin/phpstan analyse --configuration=phpstan-not-tests.neon
## baseline: Runs PHPStan -> baseline
.PHONY: baseline
baseline:
${PHP_RUN} php -d memory_limit=-1 vendor/bin/phpstan analyse --configuration=phpstan-all.neon --generate-baseline=phpstan-all-baseline.neon --allow-empty-baseline
##>—— Styling ——————————————
## cs: Runs PHPCS through docker
.PHONY: cs
cs:
${PHP_RUN} php -d memory_limit=-1 vendor/bin/php-cs-fixer fix --verbose --dry-run --diff $(ARGS)
${PHP_RUN} php -d memory_limit=-1 vendor/bin/php-cs-fixer fix --verbose --dry-run --diff .php-cs-fixer.php
## cs-fix: Runs PHPCS with fixes through docker
.PHONY: cs-fix
cs-fix:
${PHP_RUN} php -d memory_limit=-1 vendor/bin/php-cs-fixer fix --verbose --diff $(ARGS)
${PHP_RUN} php -d memory_limit=-1 vendor/bin/php-cs-fixer fix --verbose --diff .php-cs-fixer.php
##>—— Extra ————————————————
## help: Print this message
.PHONY: help
help: Makefile
sed -n 's/^##//p' $<
## tab-makefile: Tabs the makefile descriptions
.PHONY: tab-makefile
tab-makefile:
sed -i 's/: /: /g' Makefile
## clear-local-branches: Removes all local branches
.PHONY: clear-local-branches
clear-local-branches:
git for-each-ref --format '%(refname:short)' refs/heads | grep -v main | xargs git branch -D