@@ -4,25 +4,26 @@ SHELL=bash
4
4
.PHONY : *
5
5
6
6
DOCKER_CGROUP: =$(shell cat /proc/1/cgroup | grep docker | wc -l)
7
- COMPOSER_CACHE_DIR =$(shell composer config --global cache-dir -q || echo ${HOME}/.composer/cache)
7
+ COMPOSER_CACHE_DIR: =$(shell composer config --global cache-dir -q || echo ${HOME}/.composer/cache)
8
8
9
9
ifneq ("$(wildcard /.dockerenv) ","")
10
- IN_DOCKER =TRUE
10
+ IN_DOCKER: =TRUE
11
11
else ifneq ("$(DOCKER_CGROUP)","0")
12
- IN_DOCKER=TRUE
12
+ IN_DOCKER: =TRUE
13
13
else
14
- IN_DOCKER =FALSe
14
+ IN_DOCKER: =FALSE
15
15
endif
16
16
17
17
ifeq ("$(IN_DOCKER ) ","TRUE")
18
- DOCKER_RUN=
18
+ DOCKER_RUN: =
19
19
else
20
- DOCKER_RUN=docker run --rm -it \
20
+ PHP_VERSION:=$(shell docker run --rm -v "`pwd`:`pwd`" jess/jq jq -r -c '.config.platform.php' "`pwd`/composer.json" | php -r "echo str_replace('|', '.', explode('.', implode('|', explode('.', stream_get_contents(STDIN), 2)), 2)[0]);")
21
+ DOCKER_RUN:=docker run --rm -it \
21
22
-v "`pwd`:`pwd`" \
22
23
-v "${COMPOSER_CACHE_DIR}:/home/app/.composer/cache" \
23
24
-w "`pwd`" \
24
25
-e "FORCE_GENERATION=$$FORCE_GENERATION" \
25
- "wyrihaximusnet/php:8.2 -nts-alpine-slim-dev"
26
+ "ghcr.io/ wyrihaximusnet/php:${PHP_VERSION} -nts-alpine-slim-dev"
26
27
endif
27
28
28
29
all : # # Runs everything ###
@@ -32,31 +33,23 @@ syntax-php: ## Lint PHP syntax
32
33
$(DOCKER_RUN ) vendor/bin/parallel-lint --exclude vendor .
33
34
34
35
cs-fix : # # Fix any automatically fixable code style issues
35
- $(DOCKER_RUN ) vendor/bin/phpcbf --parallel=$(shell nproc)
36
+ $(DOCKER_RUN ) vendor/bin/phpcbf --parallel=$(shell nproc) --standard=./etc/qa/phpcs.xml || $( DOCKER_RUN ) vendor/bin/phpcbf --parallel= $( shell nproc) --standard=./etc/qa/phpcs.xml || $( DOCKER_RUN ) vendor/bin/phpcbf --parallel= $( shell nproc) --standard=./etc/qa/phpcs.xml -vvv
36
37
37
38
cs : # # Check the code for code style issues
38
- $(DOCKER_RUN ) vendor/bin/phpcs --parallel=$(shell nproc)
39
+ $(DOCKER_RUN ) vendor/bin/phpcs --parallel=$(shell nproc) --standard=./etc/qa/phpcs.xml
39
40
40
41
stan : # # Run static analysis (PHPStan)
41
- $(DOCKER_RUN ) vendor/bin/phpstan analyse src tests --level max --ansi -c phpstan.neon
42
+ $(DOCKER_RUN ) vendor/bin/phpstan analyse src tests --level max --ansi -c ./etc/qa/ phpstan.neon
42
43
43
44
psalm : # # Run static analysis (Psalm)
44
- $(DOCKER_RUN ) vendor/bin/psalm --threads=$(shell nproc) --shepherd --stats
45
+ $(DOCKER_RUN ) vendor/bin/psalm --threads=$(shell nproc) --shepherd --stats --config=./etc/qa/psalm.xml
45
46
46
- unit : # # Run tests
47
- $(DOCKER_RUN ) vendor/bin/phpunit --colors=always -c phpunit.xml.dist --coverage-text --coverage-html covHtml --coverage-clover ./build/logs/clover.xml
47
+ unit-testing : # # Run tests
48
+ $(DOCKER_RUN ) vendor/bin/phpunit --colors=always -c ./etc/qa/phpunit.xml
49
+ $(DOCKER_RUN ) test -n " $( COVERALLS_REPO_TOKEN) " && test -n " $( COVERALLS_RUN_LOCALLY) " && test -f ./var/tests-unit-clover-coverage.xml && vendor/bin/php-coveralls -v --coverage_clover ./build/logs/clover.xml --json_path ./var/tests-unit-clover-coverage-upload.json || true
48
50
49
- unit-ci : unit
50
- 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
51
-
52
- infection : # # Run mutation testing
53
- $(DOCKER_RUN ) vendor/bin/infection --ansi --min-msi=100 --min-covered-msi=100 --threads=$(shell nproc)
54
-
55
- composer-require-checker : # # Ensure we require every package used in this package directly
56
- $(DOCKER_RUN ) vendor/bin/composer-require-checker --ignore-parse-errors --ansi -vvv --config-file=composer-require-checker.json
57
-
58
- composer-unused : # # Ensure we don't require any package we don't use in this package directly
59
- $(DOCKER_RUN ) composer unused --ansi
51
+ mutation-testing : # # Run mutation testing
52
+ $(DOCKER_RUN ) vendor/bin/infection --ansi --min-msi=100 --min-covered-msi=100 --threads=$(shell nproc) --ignore-msi-with-no-mutations || (cat ./var/infection.log && false)
60
53
61
54
backward-compatibility-check : # # Check code for backwards incompatible changes
62
55
$(DOCKER_RUN ) vendor/bin/roave-backward-compatibility-check || true
0 commit comments