@@ -3,43 +3,64 @@ SHELL=bash
3
3
4
4
.PHONY : *
5
5
6
+ DOCKER_CGROUP: =$(shell cat /proc/1/cgroup | grep docker | wc -l)
7
+
6
8
ifneq ("$(wildcard /.dockerenv) ","")
7
- DOCKER_RUN =
9
+ IN_DOCKER =TRUE
10
+ else ifneq ("$(DOCKER_CGROUP)","0")
11
+ IN_DOCKER=TRUE
12
+ else
13
+ IN_DOCKER =FALSe
14
+ endif
15
+
16
+ ifeq ("$(IN_DOCKER ) ","TRUE")
17
+ DOCKER_RUN=
8
18
else
9
19
DOCKER_RUN=docker run --rm -it \
10
- -v `pwd`:`pwd` \
11
- -w `pwd` \
12
- "wyrihaximusnet/php:7.4-zts-alpine3.11 -dev"
20
+ -v " `pwd`:`pwd`" \
21
+ -w " `pwd`" \
22
+ "wyrihaximusnet/php:7.4-zts-alpine3.12 -dev"
13
23
endif
14
24
15
- all : lint cs-fix cs stan psalm unit infection composer-require-checker composer-unused
25
+ all : syntax-php cs-fix cs stan psalm unit infection composer-require-checker composer-unused backward-compatibility-check
16
26
17
- lint :
27
+ syntax-php : # # Lint PHP syntax
18
28
$(DOCKER_RUN ) vendor/bin/parallel-lint --exclude vendor .
19
29
20
- cs :
21
- $(DOCKER_RUN ) vendor/bin/phpcs --parallel=$(nproc )
30
+ cs : # # Check the code for code style issues
31
+ $(DOCKER_RUN ) vendor/bin/phpcs --parallel=$(shell nproc)
22
32
23
- cs-fix :
24
- $(DOCKER_RUN ) vendor/bin/phpcbf --parallel=$(nproc )
33
+ cs-fix : # # Fix any automatically fixable code style issues
34
+ $(DOCKER_RUN ) vendor/bin/phpcbf --parallel=$(shell nproc)
25
35
26
- stan :
36
+ stan : # # Run static analysis (PHPStan)
27
37
$(DOCKER_RUN ) vendor/bin/phpstan analyse src tests --level max --ansi -c phpstan.neon
28
38
29
- psalm :
30
- $(DOCKER_RUN ) vendor/bin/psalm --threads=$(nproc ) --shepherd --stats
39
+ psalm : # # Run static analysis (Psalm)
40
+ $(DOCKER_RUN ) vendor/bin/psalm --threads=$(shell nproc) --shepherd --stats
31
41
32
- unit :
42
+ unit : # # Run tests
33
43
$(DOCKER_RUN ) vendor/bin/phpunit --colors=always -c phpunit.xml.dist --coverage-text --coverage-html covHtml --coverage-clover ./build/logs/clover.xml
34
44
35
45
unit-ci : unit
36
46
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
37
47
38
- infection :
39
- $(DOCKER_RUN ) vendor/bin/infection --ansi --min-msi=100 --min-covered-msi=100 --threads=$(nproc )
48
+ infection : # # Run mutation testing
49
+ $(DOCKER_RUN ) vendor/bin/infection --ansi --min-msi=100 --min-covered-msi=100 --threads=$(shell nproc)
40
50
41
- composer-require-checker :
51
+ composer-require-checker : # # Ensure we require every package used in this package directly
42
52
$(DOCKER_RUN ) vendor/bin/composer-require-checker --ignore-parse-errors --ansi -vvv --config-file=composer-require-checker.json
43
53
44
- composer-unused :
54
+ composer-unused : # # Ensure we don't require any package we don't use in this package directly
45
55
$(DOCKER_RUN ) composer unused --ansi
56
+
57
+ backward-compatibility-check : # # Check code for backwards incompatible changes
58
+ $(DOCKER_RUN ) vendor/bin/roave-backward-compatibility-check || true
59
+
60
+ task-list-ci :
61
+ @grep -E ' ^[a-zA-Z0-9_-]+:.*?## .*$$' $(MAKEFILE_LIST ) | sort | awk ' BEGIN {FS = ":.*?## "}; {printf "%s\n", $$1}' | jq --raw-input --slurp -c ' split("\n")| .[0:-1]'
62
+
63
+ help :
64
+ @printf " \033[33mUsage:\033[0m\n make [target]\n\n\033[33mTargets:\033[0m\n"
65
+ @printf " \033[32m%-32s\033[0m %s\n" " all" " Runs everything"
66
+ @grep -E ' ^[a-zA-Z0-9_-]+:.*?## .*$$' $(MAKEFILE_LIST ) | sort | awk ' BEGIN {FS = ":.*?## "}; {printf " \033[32m%-32s\033[0m %s\n", $$1, $$2}'
0 commit comments