Skip to content

Commit 22b6dcc

Browse files
committed
Switch to centralized Makefiles
1 parent 68b88f2 commit 22b6dcc

File tree

1 file changed

+11
-60
lines changed

1 file changed

+11
-60
lines changed

Makefile

Lines changed: 11 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,12 @@ SHELL=bash
33

44
.PHONY: *
55

6-
COMPOSER_CACHE_DIR=$(shell composer config --global cache-dir -q || echo ${HOME}/.composer-php/cache)
76
COMPOSER_SHOW_EXTENSION_LIST=$(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/.$$//')
87
SLIM_DOCKER_IMAGE=$(shell php -r 'echo count(array_intersect(["gd", "vips"], explode(",", "${COMPOSER_SHOW_EXTENSION_LIST}"))) > 0 ? "" : "-slim";')
8+
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]);")
9+
CONTAINER_NAME=$(shell echo "ghcr.io/wyrihaximusnet/php:${PHP_VERSION}-nts-alpine${SLIM_DOCKER_IMAGE}-dev")
10+
COMPOSER_CACHE_DIR=$(shell composer config --global cache-dir -q || echo ${HOME}/.composer-php/cache)
11+
COMPOSER_CONTAINER_CACHE_DIR=$(shell docker run --rm -it ${CONTAINER_NAME} composer config --global cache-dir -q || echo ${HOME}/.composer-php/cache)
912

1013
ifneq ("$(wildcard /.you-are-in-a-wyrihaximus.net-php-docker-image)","")
1114
IN_DOCKER=TRUE
@@ -16,12 +19,11 @@ endif
1619
ifeq ("$(IN_DOCKER)","TRUE")
1720
DOCKER_RUN:=
1821
else
19-
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]);")
2022
DOCKER_RUN:=docker run --rm -it \
2123
-v "`pwd`:`pwd`" \
22-
-v "${COMPOSER_CACHE_DIR}:/home/app/.composer/cache" \
24+
-v "${COMPOSER_CACHE_DIR}:${COMPOSER_CONTAINER_CACHE_DIR}" \
2325
-w "`pwd`" \
24-
"ghcr.io/wyrihaximusnet/php:${PHP_VERSION}-nts-alpine${SLIM_DOCKER_IMAGE}-dev"
26+
${CONTAINER_NAME}
2527
endif
2628

2729
ifneq (,$(findstring icrosoft,$(shell cat /proc/version)))
@@ -30,59 +32,8 @@ else
3032
THREADS=$(shell nproc)
3133
endif
3234

33-
all: ## Runs everything ###
34-
@grep -E '^[a-zA-Z0-9_-]+:.*?## .*$$' $(MAKEFILE_LIST) | grep -v "###" | awk 'BEGIN {FS = ":.*?## "}; {printf "%s\n", $$1}' | xargs --open-tty $(MAKE)
35-
36-
syntax-php: ## Lint PHP syntax
37-
$(DOCKER_RUN) vendor/bin/parallel-lint --exclude vendor .
38-
39-
cs-fix: ## Fix any automatically fixable code style issues
40-
$(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
41-
42-
cs: ## Check the code for code style issues
43-
$(DOCKER_RUN) vendor/bin/phpcs --parallel=$(THREADS) --cache=./var/.phpcs.cache.json --standard=./etc/qa/phpcs.xml
44-
45-
stan: ## Run static analysis (PHPStan)
46-
$(DOCKER_RUN) vendor/bin/phpstan analyse src tests --level max --ansi -c ./etc/qa/phpstan.neon
47-
48-
psalm: ## Run static analysis (Psalm)
49-
$(DOCKER_RUN) vendor/bin/psalm --threads=$(THREADS) --shepherd --stats --config=./etc/qa/psalm.xml
50-
51-
unit-testing: ## Run tests
52-
$(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
53-
$(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
54-
55-
unit-testing-raw: ## Run tests ###
56-
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
57-
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
58-
59-
mutation-testing: ## Run mutation testing
60-
$(DOCKER_RUN) vendor/bin/roave-infection-static-analysis-plugin --ansi --log-verbosity=all --threads=$(THREADS) --psalm-config etc/qa/psalm.xml || (cat ./var/infection.log && false)
61-
62-
mutation-testing-raw: ## Run mutation testing ###
63-
php vendor/roave/infection-static-analysis-plugin/bin/roave-infection-static-analysis-plugin --ansi --log-verbosity=all --threads=$(THREADS) --psalm-config etc/qa/psalm.xml || (cat ./var/infection.log && false)
64-
65-
composer-require-checker: ## Ensure we require every package used in this package directly
66-
$(DOCKER_RUN) vendor/bin/composer-require-checker --ignore-parse-errors --ansi -vvv --config-file=./etc/qa/composer-require-checker.json
67-
68-
composer-unused: ## Ensure we don't require any package we don't use in this package directly
69-
$(DOCKER_RUN) vendor/bin/composer-unused --ansi --configuration=./etc/qa/composer-unused.php
70-
71-
composer-install: ## Install dependencies
72-
$(DOCKER_RUN) composer install --no-progress --ansi --no-interaction --prefer-dist -o
73-
74-
backward-compatibility-check: ## Check code for backwards incompatible changes
75-
$(MAKE) backward-compatibility-check-raw || true
76-
77-
backward-compatibility-check-raw: ## Check code for backwards incompatible changes, doesn't ignore the failure ###
78-
$(DOCKER_RUN) vendor/bin/roave-backward-compatibility-check
79-
80-
shell: ## Provides Shell access in the expected environment ###
81-
$(DOCKER_RUN) bash
82-
83-
task-list-ci: ## CI: Generate a JSON array of jobs to run, matches the commands run when running `make (|all)` ###
84-
@grep -E '^[a-zA-Z0-9_-]+:.*?## .*$$' $(MAKEFILE_LIST) | grep -v "###" | sort | awk 'BEGIN {FS = ":.*?## "}; {printf "%s\n", $$1}' | jq --raw-input --slurp -c 'split("\n")| .[0:-1]'
85-
86-
help: ## Show this help ###
87-
@printf "\033[33mUsage:\033[0m\n make [target]\n\n\033[33mTargets:\033[0m\n"
88-
@grep -E '^[a-zA-Z0-9_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf " \033[32m%-32s\033[0m %s\n", $$1, $$2}' | tr -d '#'
35+
include vendor/wyrihaximus/makefiles/includes/All.mk
36+
include vendor/wyrihaximus/makefiles/includes/PHP.mk
37+
include vendor/wyrihaximus/makefiles/includes/Shell.mk
38+
include vendor/wyrihaximus/makefiles/includes/Help.mk
39+
include vendor/wyrihaximus/makefiles/includes/TaskFinders.mk

0 commit comments

Comments
 (0)