@@ -3,15 +3,16 @@ SHELL=bash
33
44.PHONY : *
55
6+ DOCKER_AVAILABLE =$(shell ((command -v docker >/dev/null 2>&1) && echo 0 || echo 1))
67CONTAINER_REGISTRY_REPO ="ghcr.io/wyrihaximusnet/php"
7- COMPOSER_SHOW_EXTENSION_LIST_PROD =$(shell ((command -v docker >/dev/null 2>&1) && docker run --rm -v "` pwd ` :` pwd ` " -w ` pwd ` ${CONTAINER_REGISTRY_REPO}:8.4-nts-alpine-slim-dev 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/.$$//')
8- COMPOSER_SHOW_EXTENSION_LIST_DEV =$(shell ((command -v docker >/dev/null 2>&1) && docker run --rm -v "` pwd ` :` pwd ` " -w ` pwd ` ${CONTAINER_REGISTRY_REPO}:8.4-nts-alpine-slim-dev composer show -s) | grep -o "\(ext-\).\+" | sort | uniq | cut -d- -f2- | cut -d" " -f1 | xargs | sed -e 's/ /, /g' | tr -cd '[:alnum:],')
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:],')
910COMPOSER_SHOW_EXTENSION_LIST =$(shell echo "${COMPOSER_SHOW_EXTENSION_LIST_PROD},${COMPOSER_SHOW_EXTENSION_LIST_DEV}")
1011SLIM_DOCKER_IMAGE =$(shell php -r 'echo count(array_intersect(["gd", "vips"], explode(",", "${COMPOSER_SHOW_EXTENSION_LIST}") )) > 0 ? "" : "-slim";')
1112NTS_OR_ZTS_DOCKER_IMAGE =$(shell php -r 'echo count(array_intersect(["parallel"], explode(",", "${COMPOSER_SHOW_EXTENSION_LIST}") )) > 0 ? "zts" : "nts";')
1213PHP_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]);")
1314CONTAINER_NAME =$(shell echo "${CONTAINER_REGISTRY_REPO}:${PHP_VERSION}-${NTS_OR_ZTS_DOCKER_IMAGE}-alpine${SLIM_DOCKER_IMAGE}-dev")
14- COMPOSER_CACHE_DIR =$(shell (command -v docker >/dev/null 2>&1) && docker run --rm -v " ` pwd ` : ` pwd ` " -w ` pwd ` ${CONTAINER_REGISTRY_REPO}:8.4-nts-alpine-slim-dev composer config --global cache-dir -q || echo ${HOME}/.composer-php/cache)
15+ COMPOSER_CACHE_DIR =$(shell (command -v composer >/dev/null 2>&1) && composer config --global cache-dir -q || echo ${HOME}/.composer-php/cache)
1516COMPOSER_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)
1617
1718ifneq ("$(wildcard /.you-are-in-a-wyrihaximus.net-php-docker-image) ","")
@@ -23,12 +24,16 @@ endif
2324ifeq ("$(IN_DOCKER ) ","TRUE")
2425 DOCKER_RUN:=
2526else
26- DOCKER_RUN:=docker run --rm -it \
27- -v "`pwd`:`pwd`" \
28- -v "${COMPOSER_CACHE_DIR}:${COMPOSER_CONTAINER_CACHE_DIR}" \
29- -w "`pwd`" \
30- -e OTEL_PHP_FIBERS_ENABLED="true" \
31- "${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
3237endif
3338
3439ifneq (,$(findstring icrosoft,$(shell cat /proc/version) ) )
3843endif
3944
4045all : # # Runs everything ####
41- @grep -E ' ^[a-zA-Z0-9_-]+:.*?## .*$$' $(MAKEFILE_LIST ) | grep -v " ####" | awk ' BEGIN {FS = ":.*?## "}; {printf "%s\n", $$1}' | xargs -o $(MAKE )
46+ $(DOCKER_RUN ) make all-raw
47+ all-raw : # # The real runs everything, but due to sponge it has to be ran inside DOCKER_RUN ##U##
48+ (( command - v sponge >/ dev/ null 2 >& 1 ) && (sh - c '$(shell printf "% s % s" $(MAKE) $(shell cat $(MAKEFILE_LIST) | grep - E '^[a- zA- Z0 - 9 _- ]+: .*? ## .* $$ ' | grep - v "##* I* ##" | grep - v "####" | grep - v "##U##" | awk 'BEGIN {FS = ": .*? ## "}; {printf "% s\n", $$ 1 }' | sponge | tr '\r\n' '_') | tr '_' ' ')') || (grep - E '^[a- zA- Z0 - 9 _- ]+: .*? ## .* $$ ' $(MAKEFILE_LIST) | grep - v "##* I* ##" | grep - v "####" | grep - v "##U##" | awk 'BEGIN {FS = ": .*? ## "}; {printf "% s\n", $$ 1 }' | xargs - o $(MAKE)) )
4249
4350on-install-or-update : # # Runs everything ####
44- @ grep -E ' ^[a-zA-Z0-9_-]+:.*?## .*$$' $( MAKEFILE_LIST ) | grep -E " ##\*(I|ILH)\*##" | awk ' BEGIN {FS = ":.*?## "}; {printf "%s\n", $$1}' | xargs -o $(MAKE )
51+ (( command - v sponge >/ dev / null 2 >& 1 ) && (sh - c '$(shell printf " % s % s" $(MAKE) $(shell cat $(MAKEFILE_LIST) | grep - E '^[a- zA- Z0 - 9 _- ]+: .*? ## .* $$ ' | grep - E "##\ * (I | ILH)\ * ##" | awk 'BEGIN {FS = " : . *? ## "}; {printf " % s\n" , $$ 1 }' | sponge | tr '\r\n' '_') | tr '_' ' ')') || (grep - E '^[a - zA - Z 0 - 9 _ - ] +: . *? ## . * $$ ' $( MAKEFILE_LIST) | grep - E "##\* (I| ILH)\* ##" | awk 'BEGIN {FS = ": .*? ## "}; {printf "% s\n", $$ 1 }' | xargs - o $(MAKE)) )
4552
4653syntax-php : # # Lint PHP syntax ##*ILH*##
4754 $(DOCKER_RUN ) vendor/bin/parallel-lint --exclude vendor .
4855
4956composer-normalize : # ## Normalize composer.json ##*I*##
5057 $(DOCKER_RUN ) composer normalize
51- $(DOCKER_RUN ) composer update --lock --no-scripts
58+ $(DOCKER_RUN ) COMPOSER_DISABLE_NETWORK=1 composer update --lock --no-scripts
5259
5360rector-upgrade : # # Upgrade any automatically upgradable old code ##*I*##
5461 $(DOCKER_RUN ) vendor/bin/rector -c ./etc/qa/rector.php
@@ -60,7 +67,7 @@ cs: ## Check the code for code style issues ##*LCH*##
6067 $(DOCKER_RUN ) vendor/bin/phpcs --parallel=1 --cache=./var/.phpcs.cache.json --standard=./etc/qa/phpcs.xml
6168
6269stan : # # Run static analysis (PHPStan) ##*LCH*##
63- $(DOCKER_RUN ) vendor/bin/phpstan analyse etc src tests --level max -- ansi -c ./etc/qa/phpstan.neon
70+ $(DOCKER_RUN ) vendor/bin/phpstan analyse -- ansi --configuration= ./etc/qa/phpstan.neon
6471
6572unit-testing : # # Run tests ##*A*##
6673 $(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
@@ -69,10 +76,10 @@ unit-testing-raw: ## Run tests ##*D*## ####
6976 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
7077
7178mutation-testing : # # Run mutation testing ##*LCH*##
72- $(DOCKER_RUN ) vendor/bin/infection --ansi --log-verbosity=all --ignore-msi-with-no-mutations --threads=$(THREADS ) || (cat ./var/infection.log && false)
79+ $(DOCKER_RUN ) vendor/bin/infection --ansi --log-verbosity=all --ignore-msi-with-no-mutations --configuration=./etc/qa/infection.json5 --static-analysis-tool=phpstan --static-analysis-tool-options= " --memory-limit=-1 " -- threads=$(THREADS ) || (cat ./var/infection.log && false)
7380
7481mutation-testing-raw : # # Run mutation testing ####
75- vendor/bin/infection --ansi --log-verbosity=all --ignore-msi-with-no-mutations --threads=$(THREADS ) || (cat ./var/infection.log && false)
82+ vendor/bin/infection --ansi --log-verbosity=all --ignore-msi-with-no-mutations --configuration=./etc/qa/infection.json5 --static-analysis-tool=phpstan --static-analysis-tool-options= " --memory-limit=-1 " -- threads=$(THREADS ) || (cat ./var/infection.log && false)
7683
7784composer-require-checker : # # Ensure we require every package used in this package directly ##*C*##
7885 $(DOCKER_RUN ) vendor/bin/composer-require-checker --ignore-parse-errors --ansi -vvv --config-file=./etc/qa/composer-require-checker.json
@@ -101,20 +108,61 @@ shell: ## Provides Shell access in the expected environment ####
101108
102109help : # # Show this help ####
103110 @printf " \033[33mUsage:\033[0m\n make [target]\n\n\033[33mTargets:\033[0m\n"
104- @grep -E ' ^[a-zA-Z0-9_-]+:.*?## .*$$' $(MAKEFILE_LIST ) | sort | awk ' BEGIN {FS = ":.*?## "}; {printf " \033[32m%-32s\033[0m %s\n", $$1, $$2}' | tr -d ' #'
111+ @grep -E ' ^[a-zA-Z0-9_-]+:.*?## .*$$' $(MAKEFILE_LIST ) | grep -v " ##U## " | sort | awk ' BEGIN {FS = ":.*?## "}; {printf " \033[32m%-32s\033[0m %s\n", $$1, $$2}' | tr -d ' #'
105112
106113task-list-ci-all : # # CI: Generate a JSON array of jobs to run on all variations
107- @grep -E ' ^[a-zA-Z0-9_-]+:.*?## .*$$' $(MAKEFILE_LIST ) | grep -E " ##\*A\*##" | sort | awk ' BEGIN {FS = ":.*?## "}; {printf "%s\n", $$1}' | jq --raw-input --slurp -c ' split("\n")| .[0:-1]'
114+ @grep -E ' ^[a-zA-Z0-9_-]+:.*?## .*$$' $(MAKEFILE_LIST ) | grep -E " ##\*A\*##" | grep -v " ##U## " | sort | awk ' BEGIN {FS = ":.*?## "}; {printf "%s\n", $$1}' | jq --raw-input --slurp -c ' split("\n")| .[0:-1]'
108115
109116task-list-ci-dos : # # CI: Generate a JSON array of jobs to run Directly on the OS variations
110- @grep -E ' ^[a-zA-Z0-9_-]+:.*?## .*$$' $(MAKEFILE_LIST ) | grep -E " ##\*D\*##" | sort | awk ' BEGIN {FS = ":.*?## "}; {printf "%s\n", $$1}' | jq --raw-input --slurp -c ' split("\n")| .[0:-1]'
117+ @grep -E ' ^[a-zA-Z0-9_-]+:.*?## .*$$' $(MAKEFILE_LIST ) | grep -E " ##\*D\*##" | grep -v " ##U## " | sort | awk ' BEGIN {FS = ":.*?## "}; {printf "%s\n", $$1}' | jq --raw-input --slurp -c ' split("\n")| .[0:-1]'
111118
112119task-list-ci-low : # # CI: Generate a JSON array of jobs to run against the lowest dependencies on the primary threading target
113- @grep -E ' ^[a-zA-Z0-9_-]+:.*?## .*$$' $(MAKEFILE_LIST ) | grep -E " ##\*(L|LC|LCH|LH)\*##" | grep -v " ###" | sort | awk ' BEGIN {FS = ":.*?## "}; {printf "%s\n", $$1}' | jq --raw-input --slurp -c ' split("\n")| .[0:-1]'
120+ @grep -E ' ^[a-zA-Z0-9_-]+:.*?## .*$$' $(MAKEFILE_LIST ) | grep -E " ##\*(L|LC|LCH|LH)\*##" | grep -v " ###" | grep -v " ##U## " | sort | awk ' BEGIN {FS = ":.*?## "}; {printf "%s\n", $$1}' | jq --raw-input --slurp -c ' split("\n")| .[0:-1]'
114121
115122task-list-ci-locked : # # CI: Generate a JSON array of jobs to run against the locked dependencies on the primary threading target
116- @grep -E ' ^[a-zA-Z0-9_-]+:.*?## .*$$' $(MAKEFILE_LIST ) | grep -E " ##\*(C|LC|LCH|CH)\*##" | grep -v " ###" | sort | awk ' BEGIN {FS = ":.*?## "}; {printf "%s\n", $$1}' | jq --raw-input --slurp -c ' split("\n")| .[0:-1]'
123+ @grep -E ' ^[a-zA-Z0-9_-]+:.*?## .*$$' $(MAKEFILE_LIST ) | grep -E " ##\*(C|LC|LCH|CH)\*##" | grep -v " ###" | grep -v " ##U## " | sort | awk ' BEGIN {FS = ":.*?## "}; {printf "%s\n", $$1}' | jq --raw-input --slurp -c ' split("\n")| .[0:-1]'
117124
118125task-list-ci-high : # # CI: Generate a JSON array of jobs to run against the highest dependencies on the primary threading target
119- @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]'
126+ @grep -E ' ^[a-zA-Z0-9_-]+:.*?## .*$$' $(MAKEFILE_LIST ) | grep -E " ##\*(H|LH|LCH|LC)\*##" | grep -v " ###" | grep -v " ##U##" | sort | awk ' BEGIN {FS = ":.*?## "}; {printf "%s\n", $$1}' | jq --raw-input --slurp -c ' split("\n")| .[0:-1]'
127+
128+
129+ # # Temporary set of migrations to get all my repos in shape
130+ migrations-php-remove-psalm-xml-config : # ### Make sure we remove etc/qa/psalm.xml ##*I*##
131+ ($( DOCKER_RUN) rm etc/qa/psalm.xml || true)
132+
133+ migrations-php-move-infection : # ### Move infection.json.dist to etc/qa/infection.json5 ##*I*##
134+ ($( DOCKER_RUN) mv infection.json.dist etc/qa/infection.json5 || true)
135+
136+ migrations-php-remove-phpunit-config-dir-from-infection : # ### Drop XXX from etc/qa/infection.json5 ##*I*##
137+ ($( 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)
138+
139+ migrations-php-fix-logs-relative-paths-for-infection : # ### Fix logs paths in etc/qa/infection.json5 ##*I*##
140+ ($( 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)
141+
142+ migrations-php-add-github-true-to-for-infection : # ### Ensure we configure infection to emit logs to GitHub in etc/qa/infection.json5 ##*I*##
143+ ($( 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;} if (array_key_exists("github", $$json["logs"])) {exit;} $$json["logs"]["github"] = true; file_put_contents($$infectionFile, json_encode($$json, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES) . "\r\n");' || true)
144+
145+ migrations-php-set-phpunit-xsd-path-to-local : # ### Ensure that the PHPUnit XDS referred in etc/qa/phpunit.xml points to vendor/phpunit/phpunit/phpunit.xsd so we don't go over the network ##*I*##
146+ ($( DOCKER_RUN) php -r ' $$phpUnitConfigFIle = "etc/qa/phpunit.xml"; if (!file_exists($$phpUnitConfigFIle)) {exit;} $$xml = file_get_contents($$phpUnitConfigFIle); if (!is_string($$xml)) {exit;} for ($$major = 0; $$major < 23; $$major++) { for ($$minor = 0; $$minor < 23; $$minor++) { $$xml = str_replace("https://schema.phpunit.de/" . $$major . "." . $$minor . "/phpunit.xsd", "../../vendor/phpunit/phpunit/phpunit.xsd", $$xml); } } file_put_contents($$phpUnitConfigFIle, $$xml);' || true)
147+
148+ migrations-php-set-phpstan-paths-in-config : # ### Ensure PHPStan config has the etc, src, and tests paths set in etc/qa/phpstan.neon ##*I*##
149+ ($( DOCKER_RUN) php -r ' $$phpStanConfigFIle = "etc/qa/phpstan.neon"; $$pathsString = "\n\tpaths:\n\t\t- ../../etc\n\t\t- ../../src\n\t\t- ../../tests"; if (!file_exists($$phpStanConfigFIle)) {exit;} $$neon = file_get_contents($$phpStanConfigFIle); if (!is_string($$neon)) {exit;} if (strpos($$neon, $$pathsString) !== false) {exit;} $$neon = str_replace("parameters:", "parameters:" . $$pathsString, $$neon); file_put_contents($$phpStanConfigFIle, $$neon);' || true)
150+
151+ migrations-php-set-phpstan-level-max-in-config : # ### Ensure PHPStan config has level set to max in etc/qa/phpstan.neon ##*I*##
152+ ($( DOCKER_RUN) php -r ' $$phpStanConfigFIle = "etc/qa/phpstan.neon"; $$levelString = "\n\tlevel: max"; if (!file_exists($$phpStanConfigFIle)) {exit;} $$neon = file_get_contents($$phpStanConfigFIle); if (!is_string($$neon)) {exit;} if (strpos($$neon, $$levelString) !== false) {exit;} $$neon = str_replace("parameters:", "parameters:" . $$levelString, $$neon); file_put_contents($$phpStanConfigFIle, $$neon);' || true)
153+
154+ migrations-github-codeowners : # ### Ensure a CODEOWNERS file is present, create only if it doesn't exist yet ##*I*##
155+ ($( DOCKER_RUN) php -r ' $$codeOwnersFile = ".github/CODEOWNERS"; if (file_exists($$codeOwnersFile)) {exit;} file_put_contents($$codeOwnersFile, "* @WyriHaximus" . PHP_EOL);' || true)
156+
157+ migrations-github-actions-move-release-management : # ### Move .github/workflows/release-managment.yaml to .github/workflows/release-management.yaml ##*I*##
158+ ($( DOCKER_RUN) mv .github/workflows/release-managment.yaml .github/workflows/release-management.yaml || true)
159+
160+ migrations-github-actions-fix-management-in-release-management-referenced-workflow-file : # ### Fix management in release-management referenced workflow file ##*I*##
161+ ($( DOCKER_RUN) sed -i -e ' s/release-managment.yaml/release-management.yaml/g' .github/workflows/release-management.yaml || true)
162+
163+ migrations-renovate-move-config : # ### Move renovate.json to .github/renovate.json ##*I*##
164+ ($( DOCKER_RUN) mv renovate.json .github/renovate.json || true)
165+
166+ migrations-renovate-point-at-correct-config : # ### Ensure .github/renovate.json points at github>WyriHaximus/renovate-config:php-package instead of local>WyriHaximus/renovate-config ##*I*##
167+ ($( DOCKER_RUN) php -r ' $$renovateFIle = ".github/renovate.json"; if (!file_exists($$renovateFIle)) {exit;} file_put_contents($$renovateFIle, str_replace("local>WyriHaximus/renovate-config", "github>WyriHaximus/renovate-config:php-package", file_get_contents($$renovateFIle)));' || true)
120168
0 commit comments