-
-
Notifications
You must be signed in to change notification settings - Fork 12
/
Makefile
71 lines (52 loc) · 2.91 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
# set all to phony
SHELL=bash
.PHONY: *
DOCKER_CGROUP:=$(shell cat /proc/1/cgroup | grep docker | wc -l)
COMPOSER_CACHE_DIR=$(shell composer config --global cache-dir -q || echo ${HOME}/.composer/cache)
ifneq ("$(wildcard /.dockerenv)","")
IN_DOCKER=TRUE
else ifneq ("$(DOCKER_CGROUP)","0")
IN_DOCKER=TRUE
else
IN_DOCKER=FALSe
endif
ifeq ("$(IN_DOCKER)","TRUE")
DOCKER_RUN=
else
DOCKER_RUN=docker run --rm -it \
-v "`pwd`:`pwd`" \
-v "${COMPOSER_CACHE_DIR}:/home/app/.composer/cache" \
-w "`pwd`" \
"wyrihaximusnet/php:8.2-nts-alpine-slim-dev"
endif
all: ## Runs everything ###
@grep -E '^[a-zA-Z0-9_-]+:.*?## .*$$' $(MAKEFILE_LIST) | grep -v "###" | awk 'BEGIN {FS = ":.*?## "}; {printf "%s\n", $$1}' | xargs --open-tty $(MAKE)
syntax-php: ## Lint PHP syntax
$(DOCKER_RUN) vendor/bin/parallel-lint --exclude vendor .
cs-fix: ## Fix any automatically fixable code style issues
$(DOCKER_RUN) vendor/bin/phpcbf --parallel=$(shell nproc)
cs: ## Check the code for code style issues
$(DOCKER_RUN) vendor/bin/phpcs --parallel=$(shell nproc)
stan: ## Run static analysis (PHPStan)
$(DOCKER_RUN) vendor/bin/phpstan analyse src tests --level max --ansi -c phpstan.neon
psalm: ## Run static analysis (Psalm)
$(DOCKER_RUN) vendor/bin/psalm --threads=$(shell nproc) --shepherd --stats
unit: ## Run tests
$(DOCKER_RUN) vendor/bin/phpunit --colors=always -c phpunit.xml.dist --coverage-text --coverage-html covHtml --coverage-clover ./build/logs/clover.xml
unit-ci: unit
if [ -f ./build/logs/clover.xml ]; then wget https://scrutinizer-ci.com/ocular.phar && sleep 3 && php ocular.phar code-coverage:upload --format=php-clover ./build/logs/clover.xml; fi
infection: ## Run mutation testing
$(DOCKER_RUN) vendor/bin/infection --ansi --min-msi=100 --min-covered-msi=100 --threads=$(shell nproc)
composer-require-checker: ## Ensure we require every package used in this package directly
$(DOCKER_RUN) vendor/bin/composer-require-checker --ignore-parse-errors --ansi -vvv --config-file=composer-require-checker.json
composer-unused: ## Ensure we don't require any package we don't use in this package directly
$(DOCKER_RUN) vendor/bin/composer-unused --ansi
backward-compatibility-check: ## Check code for backwards incompatible changes
$(DOCKER_RUN) vendor/bin/roave-backward-compatibility-check || true
shell: ## Provides Shell access in the expected environment ###
$(DOCKER_RUN) ash
task-list-ci: ## CI: Generate a JSON array of jobs to run, matches the commands run when running `make (|all)` ###
@grep -E '^[a-zA-Z0-9_-]+:.*?## .*$$' $(MAKEFILE_LIST) | grep -v "###" | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "%s\n", $$1}' | jq --raw-input --slurp -c 'split("\n")| .[0:-1]'
help: ## Show this help ###
@printf "\033[33mUsage:\033[0m\n make [target]\n\n\033[33mTargets:\033[0m\n"
@grep -E '^[a-zA-Z0-9_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf " \033[32m%-32s\033[0m %s\n", $$1, $$2}' | tr -d '#'