@@ -3,15 +3,17 @@ SHELL=bash
33
44.PHONY : *
55
6- COMPOSER_SHOW_EXTENSION_LIST_PROD =$(shell composer show -t | grep -o "\-\-\(ext-\) .\+" | sort | uniq | cut -d- -f4- | tr -d '\n' | grep . | sed '/^$$/d' | xargs | sed -e 's/ /, /g' | tr -cd '[:alnum:],' | sed 's/.$$//')
7- COMPOSER_SHOW_EXTENSION_LIST_DEV =$(shell composer show -s | grep -o "\(ext-\) .\+" | sort | uniq | cut -d- -f2- | cut -d" " -f1 | xargs | sed -e 's/ /, /g' | tr -cd '[:alnum:],')
6+ DOCKER_AVAILABLE =$(shell ((command -v docker >/dev/null 2>&1) && echo 0 || echo 1))
7+ CONTAINER_REGISTRY_REPO ="ghcr.io/wyrihaximusnet/php"
8+ COMPOSER_SHOW_EXTENSION_LIST_PROD =$(shell (((command -v composer >/dev/null 2>&1) && composer show -t --no-plugins) || docker run --rm -v "` pwd ` :` pwd ` " -w ` pwd ` ${CONTAINER_REGISTRY_REPO}:8.4-nts-alpine-slim-dev composer show -t --no-plugins) | grep -o "\-\-\(ext-\).\+" | sort | uniq | cut -d- -f4- | tr -d '\n' | grep . | sed '/^$$/d' | xargs | sed -e 's/ /, /g' | tr -cd '[:alnum:],' | sed 's/.$$//')
9+ COMPOSER_SHOW_EXTENSION_LIST_DEV =$(shell (((command -v composer >/dev/null 2>&1) && composer show -s --no-plugins) || docker run --rm -v "` pwd ` :` pwd ` " -w ` pwd ` ${CONTAINER_REGISTRY_REPO}:8.4-nts-alpine-slim-dev composer show -s --no-plugins) | grep -o "\(ext-\).\+" | sort | uniq | cut -d- -f2- | cut -d" " -f1 | xargs | sed -e 's/ /, /g' | tr -cd '[:alnum:],')
810COMPOSER_SHOW_EXTENSION_LIST =$(shell echo "${COMPOSER_SHOW_EXTENSION_LIST_PROD},${COMPOSER_SHOW_EXTENSION_LIST_DEV}")
911SLIM_DOCKER_IMAGE =$(shell php -r 'echo count(array_intersect(["gd", "vips"], explode(",", "${COMPOSER_SHOW_EXTENSION_LIST}") )) > 0 ? "" : "-slim";')
1012NTS_OR_ZTS_DOCKER_IMAGE =$(shell php -r 'echo count(array_intersect(["parallel"], explode(",", "${COMPOSER_SHOW_EXTENSION_LIST}") )) > 0 ? "zts" : "nts";')
11- 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]);")
12- CONTAINER_NAME =$(shell echo "ghcr.io/wyrihaximusnet/php :${PHP_VERSION}-${NTS_OR_ZTS_DOCKER_IMAGE}-alpine${SLIM_DOCKER_IMAGE}-dev")
13- COMPOSER_CACHE_DIR =$(shell composer config --global cache-dir -q || echo ${HOME}/.composer-php/cache)
14- COMPOSER_CONTAINER_CACHE_DIR =$(shell docker run --rm -it ${CONTAINER_NAME} composer config --global cache-dir -q || echo ${HOME}/.composer-php/cache)
13+ PHP_VERSION: =$(shell (((command -v docker >/dev/null 2>&1) && docker run --rm -v "` pwd ` :` pwd ` " ${CONTAINER_REGISTRY_REPO}:8.4-nts-alpine-slim php -r "echo json_decode(file_get_contents(' ` pwd ` /composer.json'), true)[' config'][' platform'][' php'];") || echo "8.3") | php -r "echo str_replace('|', '.', explode('.', implode('|', explode('.', stream_get_contents(STDIN), 2)), 2)[0]);")
14+ CONTAINER_NAME =$(shell echo "${CONTAINER_REGISTRY_REPO} :${PHP_VERSION}-${NTS_OR_ZTS_DOCKER_IMAGE}-alpine${SLIM_DOCKER_IMAGE}-dev")
15+ COMPOSER_CACHE_DIR =$(shell (command -v composer >/dev/null 2>&1) && composer config --global cache-dir -q || echo ${HOME}/.composer-php/cache)
16+ COMPOSER_CONTAINER_CACHE_DIR =$(shell ((command -v docker >/dev/null 2>&1) && docker run --rm -it ${CONTAINER_NAME} composer config --global cache-dir -q) || echo ${HOME}/.composer-php/cache)
1517
1618ifneq ("$(wildcard /.you-are-in-a-wyrihaximus.net-php-docker-image) ","")
1719 IN_DOCKER =TRUE
@@ -22,12 +24,16 @@ endif
2224ifeq ("$(IN_DOCKER ) ","TRUE")
2325 DOCKER_RUN:=
2426else
25- DOCKER_RUN:=docker run --rm -it \
26- -v "`pwd`:`pwd`" \
27- -v "${COMPOSER_CACHE_DIR}:${COMPOSER_CONTAINER_CACHE_DIR}" \
28- -w "`pwd`" \
29- -e OTEL_PHP_FIBERS_ENABLED="true" \
30- "${CONTAINER_NAME}"
27+ ifeq ($(DOCKER_AVAILABLE),0)
28+ DOCKER_RUN: =docker run --rm -it \
29+ -v "` pwd ` :` pwd ` " \
30+ -v "${COMPOSER_CACHE_DIR}:${COMPOSER_CONTAINER_CACHE_DIR}" \
31+ -w "` pwd ` " \
32+ -e OTEL_PHP_FIBERS_ENABLED="true" \
33+ "${CONTAINER_NAME}"
34+ else
35+ DOCKER_RUN: =
36+ endif
3137endif
3238
3339ifneq (,$(findstring icrosoft,$(shell cat /proc/version) ) )
3743endif
3844
3945all : # # Runs everything ####
40- @grep -E ' ^[a-zA-Z0-9_-]+:.*?## .*$$' $(MAKEFILE_LIST ) | grep -v " ####" | awk ' BEGIN {FS = ":.*?## "}; {printf "%s\n", $$1}' | xargs --open-tty $(MAKE )
46+ @grep -E ' ^[a-zA-Z0-9_-]+:.*?## .*$$' $(MAKEFILE_LIST ) | grep -v " ##*I* ##" | grep -v " #### " | awk ' BEGIN {FS = ":.*?## "}; {printf "%s\n", $$1}' | xargs -o $(MAKE )
4147
42- syntax-php : # # Lint PHP syntax ##*LH*##
48+ on-install-or-update : # # Runs everything ####
49+ @grep -E ' ^[a-zA-Z0-9_-]+:.*?## .*$$' $(MAKEFILE_LIST ) | grep -E " ##\*(I|ILH)\*##" | awk ' BEGIN {FS = ":.*?## "}; {printf "%s\n", $$1}' | xargs -o $(MAKE )
50+
51+ syntax-php : # # Lint PHP syntax ##*ILH*##
4352 $(DOCKER_RUN ) vendor/bin/parallel-lint --exclude vendor .
4453
45- rector-upgrade : # # Upgrade any automatically upgradable old code ###
54+ composer-normalize : # ## Normalize composer.json ##*I*##
55+ $(DOCKER_RUN ) composer normalize
56+ $(DOCKER_RUN ) composer update --lock --no-scripts
57+
58+ rector-upgrade : # # Upgrade any automatically upgradable old code ##*I*##
4659 $(DOCKER_RUN ) vendor/bin/rector -c ./etc/qa/rector.php
4760
48- cs-fix : # # Fix any automatically fixable code style issues ###
61+ cs-fix : # # Fix any automatically fixable code style issues ##*I*# #
4962 $(DOCKER_RUN ) vendor/bin/phpcbf --parallel=1 --cache=./var/.phpcs.cache.json --standard=./etc/qa/phpcs.xml || $(DOCKER_RUN ) vendor/bin/phpcbf --parallel=1 --cache=./var/.phpcs.cache.json --standard=./etc/qa/phpcs.xml || $(DOCKER_RUN ) vendor/bin/phpcbf --parallel=1 --cache=./var/.phpcs.cache.json --standard=./etc/qa/phpcs.xml -vvvv
5063
5164cs : # # Check the code for code style issues ##*LCH*##
@@ -56,27 +69,22 @@ stan: ## Run static analysis (PHPStan) ##*LCH*##
5669
5770unit-testing : # # Run tests ##*A*##
5871 $(DOCKER_RUN ) vendor/bin/phpunit --colors=always -c ./etc/qa/phpunit.xml --coverage-text --coverage-html ./var/tests-unit-coverage-html --coverage-clover ./var/tests-unit-clover-coverage.xml
59- $(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
6072
6173unit-testing-raw : # # Run tests ##*D*## ####
6274 php vendor/phpunit/phpunit/phpunit --colors=always -c ./etc/qa/phpunit.xml --coverage-text --coverage-html ./var/tests-unit-coverage-html --coverage-clover ./var/tests-unit-clover-coverage.xml
63- 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
6475
6576mutation-testing : # # Run mutation testing ##*LCH*##
66- $(DOCKER_RUN ) vendor/bin/infection --ansi --log-verbosity=all --ignore-msi-with-no-mutations --threads=$(THREADS ) || (cat ./var/infection.log && false)
77+ $(DOCKER_RUN ) vendor/bin/infection --ansi --log-verbosity=all --ignore-msi-with-no-mutations --configuration=./etc/qa/infection.json5 -- threads=$(THREADS ) || (cat ./var/infection.log && false)
6778
6879mutation-testing-raw : # # Run mutation testing ####
69- vendor/bin/infection --ansi --log-verbosity=all --ignore-msi-with-no-mutations --threads=$(THREADS ) || (cat ./var/infection.log && false)
80+ vendor/bin/infection --ansi --log-verbosity=all --ignore-msi-with-no-mutations --configuration=./etc/qa/infection.json5 -- threads=$(THREADS ) || (cat ./var/infection.log && false)
7081
7182composer-require-checker : # # Ensure we require every package used in this package directly ##*C*##
7283 $(DOCKER_RUN ) vendor/bin/composer-require-checker --ignore-parse-errors --ansi -vvv --config-file=./etc/qa/composer-require-checker.json
7384
7485composer-unused : # # Ensure we don't require any package we don't use in this package directly ##*C*##
7586 $(DOCKER_RUN ) vendor/bin/composer-unused --ansi --configuration=./etc/qa/composer-unused.php
7687
77- libyear : # ## Calculate how many libyear this package is behind with dependencies
78- $(DOCKER_RUN ) vendor/bin/libyear
79-
8088backward-compatibility-check : # # Check code for backwards incompatible changes ##*C*##
8189 $(MAKE ) backward-compatibility-check-raw || true
8290
@@ -115,3 +123,14 @@ task-list-ci-locked: ## CI: Generate a JSON array of jobs to run against the loc
115123task-list-ci-high : # # CI: Generate a JSON array of jobs to run against the highest dependencies on the primary threading target
116124 @grep -E ' ^[a-zA-Z0-9_-]+:.*?## .*$$' $(MAKEFILE_LIST ) | grep -E " ##\*(H|LH|LCH|LC)\*##" | grep -v " ###" | sort | awk ' BEGIN {FS = ":.*?## "}; {printf "%s\n", $$1}' | jq --raw-input --slurp -c ' split("\n")| .[0:-1]'
117125
126+
127+ # # Temporary set of migrations to get all my repos in shape
128+ php-migrations-move-infection : # ### Move infection.json.dist to etc/qa/infection.json5 ##*I*##
129+ ($( DOCKER_RUN) mv infection.json.dist etc/qa/infection.json5 || true)
130+
131+ php-migrations-remove-phpunit-config-dir-from-infection : # ### Drop XXX from etc/qa/infection.json5 ##*I*##
132+ ($( DOCKER_RUN) php -r ' $$infectionFile = "etc/qa/infection.json5"; if (!file_exists($$infectionFile)) {exit;} $$json = json_decode(file_get_contents($$infectionFile), true); if (!is_array($$json)) {exit;} if (!array_key_exists("phpUnit", $$json)) {exit;} unset($$json["phpUnit"]); file_put_contents($$infectionFile, json_encode($$json, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES) . "\r\n");' || true)
133+
134+ php-migrations-fix-logs-relative-paths-for-infection : # ### Fix logs paths in etc/qa/infection.json5 ##*I*##
135+ ($( DOCKER_RUN) php -r ' $$infectionFile = "etc/qa/infection.json5"; if (!file_exists($$infectionFile)) {exit;} $$json = json_decode(file_get_contents($$infectionFile), true); if (!is_array($$json)) {exit;} if (!array_key_exists("logs", $$json)) {exit;} foreach ($$json["logs"] as $$logsKey => $$logsPath) { if (is_string($$json["logs"][$$logsKey]) && str_starts_with($$json["logs"][$$logsKey], "./var/infection")) { $$json["logs"][$$logsKey] = str_replace("./var/infection", "../../var/infection", $$json["logs"][$$logsKey]); } } file_put_contents($$infectionFile, json_encode($$json, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES) . "\r\n");' || true)
136+
0 commit comments