diff --git a/Makefile b/Makefile index df45366..b683e03 100644 --- a/Makefile +++ b/Makefile @@ -3,15 +3,17 @@ SHELL=bash .PHONY: * -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/.$$//') -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:],') +DOCKER_AVAILABLE=$(shell ((command -v docker >/dev/null 2>&1) && echo 0 || echo 1)) +CONTAINER_REGISTRY_REPO="ghcr.io/wyrihaximusnet/php" +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/.$$//') +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:],') COMPOSER_SHOW_EXTENSION_LIST=$(shell echo "${COMPOSER_SHOW_EXTENSION_LIST_PROD},${COMPOSER_SHOW_EXTENSION_LIST_DEV}") SLIM_DOCKER_IMAGE=$(shell php -r 'echo count(array_intersect(["gd", "vips"], explode(",", "${COMPOSER_SHOW_EXTENSION_LIST}"))) > 0 ? "" : "-slim";') NTS_OR_ZTS_DOCKER_IMAGE=$(shell php -r 'echo count(array_intersect(["parallel"], explode(",", "${COMPOSER_SHOW_EXTENSION_LIST}"))) > 0 ? "zts" : "nts";') -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]);") -CONTAINER_NAME=$(shell echo "ghcr.io/wyrihaximusnet/php:${PHP_VERSION}-${NTS_OR_ZTS_DOCKER_IMAGE}-alpine${SLIM_DOCKER_IMAGE}-dev") -COMPOSER_CACHE_DIR=$(shell composer config --global cache-dir -q || echo ${HOME}/.composer-php/cache) -COMPOSER_CONTAINER_CACHE_DIR=$(shell docker run --rm -it ${CONTAINER_NAME} composer config --global cache-dir -q || echo ${HOME}/.composer-php/cache) +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]);") +CONTAINER_NAME=$(shell echo "${CONTAINER_REGISTRY_REPO}:${PHP_VERSION}-${NTS_OR_ZTS_DOCKER_IMAGE}-alpine${SLIM_DOCKER_IMAGE}-dev") +COMPOSER_CACHE_DIR=$(shell (command -v composer >/dev/null 2>&1) && composer config --global cache-dir -q || echo ${HOME}/.composer-php/cache) +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) ifneq ("$(wildcard /.you-are-in-a-wyrihaximus.net-php-docker-image)","") IN_DOCKER=TRUE @@ -22,11 +24,16 @@ endif ifeq ("$(IN_DOCKER)","TRUE") DOCKER_RUN:= else - DOCKER_RUN:=docker run --rm -it \ - -v "`pwd`:`pwd`" \ - -v "${COMPOSER_CACHE_DIR}:${COMPOSER_CONTAINER_CACHE_DIR}" \ - -w "`pwd`" \ - "${CONTAINER_NAME}" + ifeq ($(DOCKER_AVAILABLE),0) + DOCKER_RUN:=docker run --rm -it \ + -v "`pwd`:`pwd`" \ + -v "${COMPOSER_CACHE_DIR}:${COMPOSER_CONTAINER_CACHE_DIR}" \ + -w "`pwd`" \ + -e OTEL_PHP_FIBERS_ENABLED="true" \ + "${CONTAINER_NAME}" + else + DOCKER_RUN:= + endif endif ifneq (,$(findstring icrosoft,$(shell cat /proc/version))) @@ -36,36 +43,41 @@ else 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) + @grep -E '^[a-zA-Z0-9_-]+:.*?## .*$$' $(MAKEFILE_LIST) | grep -v "##*I*##" | grep -v "####" | awk 'BEGIN {FS = ":.*?## "}; {printf "%s\n", $$1}' | xargs -o $(MAKE) -syntax-php: ## Lint PHP syntax ##*LH*## +on-install-or-update: ## Runs everything #### + @grep -E '^[a-zA-Z0-9_-]+:.*?## .*$$' $(MAKEFILE_LIST) | grep -E "##\*(I|ILH)\*##" | awk 'BEGIN {FS = ":.*?## "}; {printf "%s\n", $$1}' | xargs -o $(MAKE) + +syntax-php: ## Lint PHP syntax ##*ILH*## $(DOCKER_RUN) vendor/bin/parallel-lint --exclude vendor . -rector-upgrade: ## Upgrade any automatically upgradable old code ### +composer-normalize: ### Normalize composer.json ##*I*## + $(DOCKER_RUN) composer normalize + $(DOCKER_RUN) composer update --lock --no-scripts + +rector-upgrade: ## Upgrade any automatically upgradable old code ##*I*## $(DOCKER_RUN) vendor/bin/rector -c ./etc/qa/rector.php -cs-fix: ## Fix any automatically fixable code style issues ### - $(DOCKER_RUN) vendor/bin/phpcbf --parallel=$(THREADS) --cache=./var/.phpcs.cache.json --standard=./etc/qa/phpcs.xml || $(DOCKER_RUN) vendor/bin/phpcbf --parallel=$(THREADS) --cache=./var/.phpcs.cache.json --standard=./etc/qa/phpcs.xml || $(DOCKER_RUN) vendor/bin/phpcbf --parallel=$(THREADS) --cache=./var/.phpcs.cache.json --standard=./etc/qa/phpcs.xml -vvvv +cs-fix: ## Fix any automatically fixable code style issues ##*I*## + $(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 cs: ## Check the code for code style issues ##*LCH*## - $(DOCKER_RUN) vendor/bin/phpcs --parallel=$(THREADS) --cache=./var/.phpcs.cache.json --standard=./etc/qa/phpcs.xml + $(DOCKER_RUN) vendor/bin/phpcs --parallel=1 --cache=./var/.phpcs.cache.json --standard=./etc/qa/phpcs.xml stan: ## Run static analysis (PHPStan) ##*LCH*## $(DOCKER_RUN) vendor/bin/phpstan analyse etc src tests --level max --ansi -c ./etc/qa/phpstan.neon unit-testing: ## Run tests ##*A*## $(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 - $(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 unit-testing-raw: ## Run tests ##*D*## #### 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 - 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 mutation-testing: ## Run mutation testing ##*LCH*## - $(DOCKER_RUN) vendor/bin/infection --ansi --log-verbosity=all --ignore-msi-with-no-mutations --threads=$(THREADS) || (cat ./var/infection.log && false) + $(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) mutation-testing-raw: ## Run mutation testing #### - vendor/bin/infection --ansi --log-verbosity=all --ignore-msi-with-no-mutations --threads=$(THREADS) || (cat ./var/infection.log && false) + vendor/bin/infection --ansi --log-verbosity=all --ignore-msi-with-no-mutations --configuration=./etc/qa/infection.json5 --threads=$(THREADS) || (cat ./var/infection.log && false) composer-require-checker: ## Ensure we require every package used in this package directly ##*C*## $(DOCKER_RUN) vendor/bin/composer-require-checker --ignore-parse-errors --ansi -vvv --config-file=./etc/qa/composer-require-checker.json @@ -73,9 +85,6 @@ composer-require-checker: ## Ensure we require every package used in this packag composer-unused: ## Ensure we don't require any package we don't use in this package directly ##*C*## $(DOCKER_RUN) vendor/bin/composer-unused --ansi --configuration=./etc/qa/composer-unused.php -libyear: ### Calculate how many libyear this package is behind with dependencies - $(DOCKER_RUN) vendor/bin/libyear - backward-compatibility-check: ## Check code for backwards incompatible changes ##*C*## $(MAKE) backward-compatibility-check-raw || true @@ -114,3 +123,14 @@ task-list-ci-locked: ## CI: Generate a JSON array of jobs to run against the loc task-list-ci-high: ## CI: Generate a JSON array of jobs to run against the highest dependencies on the primary threading target @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]' + +## Temporary set of migrations to get all my repos in shape +php-migrations-move-infection: #### Move infection.json.dist to etc/qa/infection.json5 ##*I*## + ($(DOCKER_RUN) mv infection.json.dist etc/qa/infection.json5 || true) + +php-migrations-remove-phpunit-config-dir-from-infection: #### Drop XXX from etc/qa/infection.json5 ##*I*## + ($(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) + +php-migrations-fix-logs-relative-paths-for-infection: #### Fix logs paths in etc/qa/infection.json5 ##*I*## + ($(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) + diff --git a/composer.json b/composer.json index 62530f7..f3ced10 100644 --- a/composer.json +++ b/composer.json @@ -26,7 +26,7 @@ "require-dev": { "react-parallel/pool-tests": "^5.0.0", "wyrihaximus/async-test-utilities": "^9.3.0", - "wyrihaximus/makefiles": "^0.4.2" + "wyrihaximus/makefiles": "^0.7.5" }, "autoload": { "psr-4": { diff --git a/composer.lock b/composer.lock index ad0149c..3bcd788 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "abeb94ce96e92f4b8f9cdc3104132e0e", + "content-hash": "0b01d1140c8989407cef11218494b594", "packages": [ { "name": "lcobucci/clock", @@ -9901,25 +9901,25 @@ }, { "name": "wyrihaximus/makefiles", - "version": "0.4.2", + "version": "0.7.5", "source": { "type": "git", "url": "https://github.com/WyriHaximus/Makefiles.git", - "reference": "6641d81adf2fd286fa05893072596f9e55a0c888" + "reference": "c843ab1522637130075a79de221f3b86118b09f9" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/WyriHaximus/Makefiles/zipball/6641d81adf2fd286fa05893072596f9e55a0c888", - "reference": "6641d81adf2fd286fa05893072596f9e55a0c888", + "url": "https://api.github.com/repos/WyriHaximus/Makefiles/zipball/c843ab1522637130075a79de221f3b86118b09f9", + "reference": "c843ab1522637130075a79de221f3b86118b09f9", "shasum": "" }, "require": { "composer-plugin-api": "^2", - "ext-json": "^8.3", - "php": "^8.3" + "ext-json": "^8.4", + "php": "^8.4" }, "require-dev": { - "wyrihaximus/test-utilities": "^7.0.0" + "wyrihaximus/test-utilities": "^8.1.0" }, "type": "composer-plugin", "extra": { @@ -9940,10 +9940,10 @@ "email": "ceesjank@gmail.com" } ], - "description": "🛠️ Test utilities for api-clients packages", + "description": "🧱 Makefile building blocks", "support": { "issues": "https://github.com/WyriHaximus/Makefiles/issues", - "source": "https://github.com/WyriHaximus/Makefiles/tree/0.4.2" + "source": "https://github.com/WyriHaximus/Makefiles/tree/0.7.5" }, "funding": [ { @@ -9951,7 +9951,7 @@ "type": "github" } ], - "time": "2025-05-05T12:59:35+00:00" + "time": "2025-09-07T16:20:50+00:00" }, { "name": "wyrihaximus/phpstan-react", @@ -10269,7 +10269,7 @@ ], "aliases": [], "minimum-stability": "stable", - "stability-flags": [], + "stability-flags": {}, "prefer-stable": false, "prefer-lowest": false, "platform": { @@ -10277,7 +10277,7 @@ "ext-parallel": "*", "ext-random": "*" }, - "platform-dev": [], + "platform-dev": {}, "platform-overrides": { "php": "8.3.13" },