diff --git a/Makefile b/Makefile index e8e71a8..67346d1 100644 --- a/Makefile +++ b/Makefile @@ -3,15 +3,16 @@ SHELL=bash .PHONY: * +CONTAINER_REGISTRY_REPO="ghcr.io/wyrihaximusnet/php" 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:],') 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") +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 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) +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 @@ -37,15 +38,22 @@ 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 "####" | 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 ### +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*## @@ -56,11 +64,9 @@ stan: ## Run static analysis (PHPStan) ##*LCH*## 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) @@ -74,9 +80,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 diff --git a/composer.json b/composer.json index 0a042ec..86437a3 100644 --- a/composer.json +++ b/composer.json @@ -17,7 +17,7 @@ }, "require-dev": { "wyrihaximus/async-test-utilities": "^9.4.2", - "wyrihaximus/makefiles": "^0.4.3" + "wyrihaximus/makefiles": "^0.5.0" }, "autoload": { "psr-4": { diff --git a/composer.lock b/composer.lock index 6feec54..7c7a1dc 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": "65c1a1e98ff7e873e0832e2418f891ba", + "content-hash": "6b0fee384ced908d4aa9cca9c4c91070", "packages": [ { "name": "clue/redis-protocol", @@ -9846,16 +9846,16 @@ }, { "name": "wyrihaximus/makefiles", - "version": "0.4.3", + "version": "0.5.0", "source": { "type": "git", "url": "https://github.com/WyriHaximus/Makefiles.git", - "reference": "8c917764c88465d3029c417c42af9885ec6442f7" + "reference": "5717bc0de6496a12734cf3f2de20859a692297f0" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/WyriHaximus/Makefiles/zipball/8c917764c88465d3029c417c42af9885ec6442f7", - "reference": "8c917764c88465d3029c417c42af9885ec6442f7", + "url": "https://api.github.com/repos/WyriHaximus/Makefiles/zipball/5717bc0de6496a12734cf3f2de20859a692297f0", + "reference": "5717bc0de6496a12734cf3f2de20859a692297f0", "shasum": "" }, "require": { @@ -9864,7 +9864,7 @@ "php": "^8.3" }, "require-dev": { - "wyrihaximus/test-utilities": "^7.5.1" + "wyrihaximus/test-utilities": "^7.5.2" }, "type": "composer-plugin", "extra": { @@ -9888,7 +9888,7 @@ "description": "🛠️ Test utilities for api-clients packages", "support": { "issues": "https://github.com/WyriHaximus/Makefiles/issues", - "source": "https://github.com/WyriHaximus/Makefiles/tree/0.4.3" + "source": "https://github.com/WyriHaximus/Makefiles/tree/0.5.0" }, "funding": [ { @@ -9896,7 +9896,7 @@ "type": "github" } ], - "time": "2025-06-23T09:26:35+00:00" + "time": "2025-08-15T05:34:56+00:00" }, { "name": "wyrihaximus/phpstan-react",