|
| 1 | +# set all to phony |
| 2 | +SHELL=bash |
| 3 | + |
| 4 | +.PHONY: * |
| 5 | + |
| 6 | +DOCKER_CGROUP:=$(shell cat /proc/1/cgroup | grep docker | wc -l) |
| 7 | +COMPOSER_CACHE_DIR=$(shell composer config --global cache-dir -q || echo ${HOME}/.composer/cache) |
| 8 | + |
| 9 | +ifneq ("$(wildcard /.dockerenv)","") |
| 10 | + IN_DOCKER=TRUE |
| 11 | +else ifneq ("$(DOCKER_CGROUP)","0") |
| 12 | + IN_DOCKER=TRUE |
| 13 | +else |
| 14 | + IN_DOCKER=FALSe |
| 15 | +endif |
| 16 | + |
| 17 | +ifeq ("$(IN_DOCKER)","TRUE") |
| 18 | + DOCKER_RUN= |
| 19 | +else |
| 20 | + DOCKER_RUN=docker run --rm -it \ |
| 21 | + -v "`pwd`:`pwd`" \ |
| 22 | + -v "${COMPOSER_CACHE_DIR}:/home/app/.composer/cache" \ |
| 23 | + -w "`pwd`" \ |
| 24 | + "wyrihaximusnet/php:8.2-nts-alpine-slim-dev" |
| 25 | +endif |
| 26 | + |
| 27 | +all: ## Runs everything ### |
| 28 | + @grep -E '^[a-zA-Z0-9_-]+:.*?## .*$$' $(MAKEFILE_LIST) | grep -v "###" | awk 'BEGIN {FS = ":.*?## "}; {printf "%s\n", $$1}' | xargs --open-tty $(MAKE) |
| 29 | + |
| 30 | +syntax-php: ## Lint PHP syntax |
| 31 | + $(DOCKER_RUN) vendor/bin/parallel-lint --exclude vendor . |
| 32 | + |
| 33 | +cs-fix: ## Fix any automatically fixable code style issues |
| 34 | + $(DOCKER_RUN) vendor/bin/phpcbf --parallel=$(shell nproc) |
| 35 | + |
| 36 | +cs: ## Check the code for code style issues |
| 37 | + $(DOCKER_RUN) vendor/bin/phpcs --parallel=$(shell nproc) |
| 38 | + |
| 39 | +stan: ## Run static analysis (PHPStan) |
| 40 | + $(DOCKER_RUN) vendor/bin/phpstan analyse src tests --level max --ansi -c phpstan.neon |
| 41 | + |
| 42 | +psalm: ## Run static analysis (Psalm) |
| 43 | + $(DOCKER_RUN) vendor/bin/psalm --threads=$(shell nproc) --shepherd --stats |
| 44 | + |
| 45 | +unit: ## Run tests |
| 46 | + $(DOCKER_RUN) vendor/bin/phpunit --colors=always -c phpunit.xml.dist --coverage-text --coverage-html covHtml --coverage-clover ./build/logs/clover.xml |
| 47 | + |
| 48 | +unit-ci: unit |
| 49 | + if [ -f ./build/logs/clover.xml ]; then wget https://scrutinizer-ci.com/ocular.phar && sleep 3 && php ocular.phar code-coverage:upload --format=php-clover ./build/logs/clover.xml; fi |
| 50 | + |
| 51 | +infection: ## Run mutation testing |
| 52 | + $(DOCKER_RUN) vendor/bin/infection --ansi --min-msi=100 --min-covered-msi=100 --threads=$(shell nproc) |
| 53 | + |
| 54 | +composer-require-checker: ## Ensure we require every package used in this package directly |
| 55 | + $(DOCKER_RUN) vendor/bin/composer-require-checker --ignore-parse-errors --ansi -vvv --config-file=composer-require-checker.json |
| 56 | + |
| 57 | +composer-unused: ## Ensure we don't require any package we don't use in this package directly |
| 58 | + $(DOCKER_RUN) composer unused --ansi |
| 59 | + |
| 60 | +backward-compatibility-check: ## Check code for backwards incompatible changes |
| 61 | + $(DOCKER_RUN) vendor/bin/roave-backward-compatibility-check || true |
| 62 | + |
| 63 | +shell: ## Provides Shell access in the expected environment ### |
| 64 | + $(DOCKER_RUN) ash |
| 65 | + |
| 66 | +task-list-ci: ## CI: Generate a JSON array of jobs to run, matches the commands run when running `make (|all)` ### |
| 67 | + @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]' |
| 68 | + |
| 69 | +help: ## Show this help ### |
| 70 | + @printf "\033[33mUsage:\033[0m\n make [target]\n\n\033[33mTargets:\033[0m\n" |
| 71 | + @grep -E '^[a-zA-Z0-9_-]+:.*?## .*$$' $(MAKEFILE_LIST) | sort | awk 'BEGIN {FS = ":.*?## "}; {printf " \033[32m%-32s\033[0m %s\n", $$1, $$2}' | tr -d '#' |
| 72 | + |
| 73 | +generate-clients: |
| 74 | + ls ./etc/clients | xargs -I % ./vendor/bin/openapi-client-generator ./etc/clients/% |
0 commit comments